/* ============================================================
   TimeApp – delt stilark (ARK-1)
   ============================================================ */

:root {
    --primary: #6E2B32;
    --primary-dark: #5a2228;
    --primary-soft: #f4eced;
    --light: #ffffff;
    --gray: #f4f4f4;
    --text: #222;
    --border: #ccc;
    --line: #eee;
    --muted: #777;
    --ok-bg: #dff5dd;
    --ok-fg: #2d6a2d;
    --err-bg: #ffe0e0;
    --err-fg: #8a1f1f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background: var(--gray);
    color: var(--text);
}

/* ---- Navbar ---- */
.navbar {
    background: var(--primary);
    color: var(--light);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.navbar .brand { font-size: 1.3rem; font-weight: bold; letter-spacing: 0.5px; }
.navbar a {
    color: var(--light);
    text-decoration: none;
    margin-left: 20px;
    font-size: 0.95rem;
    transition: opacity 0.2s;
}
.navbar a:hover { opacity: 0.7; }
.nav-links { display: flex; align-items: center; }
.menu-toggle { display: none; font-size: 1.8rem; cursor: pointer; }

@media (max-width: 750px) {
    .nav-links {
        display: none;
        flex-direction: column;
        background: var(--primary);
        width: 100%;
        padding: 10px 0;
    }
    .nav-links a { margin: 10px 0; font-size: 1.1rem; }
    .menu-toggle { display: block; }
    .nav-open .nav-links { display: flex; }
}

.page { padding: 20px; }

/* ---- Containers ---- */
.report-container,
.admin-container,
.my-container { max-width: 1100px; margin: auto; }

/* ---- Kort / skjema ---- */
.form-card,
.filter-card,
.chart-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.form-card { padding: 25px; margin-bottom: 30px; }
.form-card--narrow { max-width: 600px; margin-left: auto; margin-right: auto; }
.filter-card { padding: 20px; margin-bottom: 25px; }

.form-card h2 { margin-top: 0; color: var(--primary); text-align: center; }
.form-card h3,
.filter-card h3 { margin-top: 0; color: var(--primary); margin-bottom: 18px; }

.form-group { margin-bottom: 18px; }

label { font-weight: 600; display: block; margin-bottom: 6px; color: #333; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 1rem;
    box-sizing: border-box;
    background: white;
    transition: border-color .2s, box-shadow .2s;
}
textarea { resize: vertical; }

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 4px rgba(110,43,50,0.4);
    outline: none;
}

input[type="checkbox"] { width: auto; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- Knappar ---- */
.btn-submit, .btn-login {
    background: var(--primary);
    color: white;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
}
.btn-login { padding: 14px; font-size: 1.1rem; }
.btn-submit:hover, .btn-login:hover { background: var(--primary-dark); }

.btn-export {
    background: #1d6f42;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    white-space: nowrap;
    text-decoration: none;
    text-align: center;
    display: inline-block;
}
.btn-export:hover { background: #155c35; }

.btn-pdf {
    background: #455a64;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    white-space: nowrap;
    text-decoration: none;
    text-align: center;
    display: inline-block;
}
.btn-pdf:hover { background: #37474f; }

.report-actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.report-actions .btn-submit,
.report-actions .btn-export,
.report-actions .btn-pdf { margin-top: 0; flex: 1; min-width: 160px; }

/* ---- Meldingar ---- */
.msg-success {
    background: var(--ok-bg);
    color: var(--ok-fg);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}
.msg-error {
    background: var(--err-bg);
    color: var(--err-fg);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

/* ---- Tabellar ---- */
.table-wrapper { overflow-x: auto; margin-top: 20px; }

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
th {
    background: var(--primary);
    color: white;
    padding: 12px;
    text-align: left;
    font-size: 0.9rem;
}
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}
tr:hover td { background: #fafafa; }
.total-row { background: #f4f4f4; font-weight: bold; }

.action-links a, .action-links button {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    margin-right: 10px;
    background: none;
    border: none;
    font-size: 0.95rem;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.action-links a:hover, .action-links button:hover { text-decoration: underline; }
.action-links form { display: inline; }
.action-links .danger { color: #b3261e; }

/* ---- Samandrag ---- */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}
.summary-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    padding: 18px;
}
.summary-card .num { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.summary-card .lbl { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.empty-msg {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    padding: 30px;
    text-align: center;
    color: var(--muted);
}

/* ---- Paginering ---- */
.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}
.pager-btn {
    background: white;
    border: 1px solid #e0d2d4;
    color: var(--primary);
    padding: 10px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
}
.pager-btn:hover { background: var(--primary-soft); }
.pager-btn.disabled { color: #bbb; border-color: #eee; pointer-events: none; }
.pager-info { color: var(--muted); font-size: 0.9rem; }

/* ---- Filter-grid + fleirval ---- */
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
    align-items: end;
}

.ms { position: relative; }
.ms-toggle {
    width: 100%;
    text-align: left;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ms-toggle:hover { border-color: var(--primary); }
.ms-title { font-weight: 600; color: #333; }
.ms-label { color: var(--primary); margin-left: auto; }
.ms-caret { color: #999; font-size: 0.8rem; }
.ms-panel {
    display: none;
    position: absolute;
    z-index: 50;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    padding: 10px;
    max-height: 320px;
    flex-direction: column;
}
.ms.open .ms-panel { display: flex; }
.ms-search {
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 0.95rem;
    box-sizing: border-box;
    margin-bottom: 8px;
}
.ms-actions { display: flex; gap: 12px; margin-bottom: 8px; font-size: 0.85rem; }
.ms-actions a { color: var(--primary); text-decoration: none; font-weight: 600; }
.ms-actions a:hover { text-decoration: underline; }
.ms-options { overflow-y: auto; }
.ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    padding: 6px 4px;
    margin: 0;
    border-radius: 6px;
    cursor: pointer;
}
.ms-option:hover { background: var(--primary-soft); }
.ms-option input { width: auto; margin: 0; }

/* ---- Snøggval (dato) + pillebrytarar ---- */
.date-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.date-presets button,
.group-toggle button {
    background: var(--primary-soft);
    color: var(--primary);
    border: 1px solid #e0d2d4;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
}
.date-presets button:hover,
.group-toggle button:hover { background: var(--primary); color: white; }
.group-toggle button.active { background: var(--primary); color: white; }

/* ---- Visningsbrytar ---- */
.view-toggle { display: flex; gap: 6px; margin-bottom: 20px; }
.view-toggle button {
    flex: 1;
    background: white;
    color: var(--primary);
    border: 1px solid #e0d2d4;
    padding: 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
.view-toggle button.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ---- Graf ---- */
.chart-card { padding: 18px; margin-bottom: 25px; }
.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.chart-head h3 { margin: 0; color: var(--primary); font-size: 1.05rem; }
.group-toggle { display: flex; gap: 6px; }
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart-hint { color: #999; font-size: 0.8rem; margin-top: 8px; }
.chart-tooltip {
    position: fixed;
    background: var(--primary);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s;
    white-space: nowrap;
    z-index: 2000;
}

/* ---- Tidskort (Mine timer) ---- */
.time-list { display: grid; gap: 20px; }
.time-card {
    background: white;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    border-left: 6px solid var(--primary);
    transition: transform .15s;
}
.time-card:hover { transform: translateY(-3px); }
.time-header {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary);
}
.time-row { margin-bottom: 6px; font-size: 0.95rem; }
.time-label { font-weight: 600; color: #444; }
.time-value { color: #222; }
.time-card .card-actions { margin-top: 10px; }
.time-card .card-actions a { color: var(--primary); font-weight: 600; text-decoration: none; }
.time-card .card-actions a:hover { text-decoration: underline; }

.time-calc-box {
    background: #f8f8f8;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
}

/* ---- Månadsfilter (Mine timer) ---- */
.month-filter {
    background: white;
    padding: 18px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 15px;
}
.month-filter .field { flex: 1; min-width: 180px; }
.month-total { text-align: right; }
.month-total .num { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1; }
.month-total .lbl { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

/* ---- Dashboard ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    border-left: 6px solid var(--primary);
    transition: transform .15s;
}
.card:hover { transform: translateY(-3px); }
.card-title { font-size: 0.9rem; color: #555; margin-bottom: 5px; }
.card-value { font-size: 2rem; font-weight: bold; color: var(--primary); }

.chart {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.chart-bars { display: flex; align-items: flex-end; gap: 20px; height: 200px; padding: 20px 0; }
.bar {
    flex: 1;
    background: var(--primary);
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    padding-bottom: 5px;
    transition: opacity .2s;
}
.bar:hover { opacity: 0.8; }
.chart-labels { display: flex; justify-content: space-between; margin-top: 10px; font-size: 0.9rem; color: #444; }

/* ---- Login ---- */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
    padding: 20px;
}
.login-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 420px;
}
.login-card h2 { text-align: center; margin-top: 0; margin-bottom: 25px; color: var(--primary); }

/* ---- Footer ---- */
.app-footer {
    text-align: center;
    padding: 15px;
    background: #eee;
    margin-top: 40px;
    font-size: 0.9rem;
    color: #555;
}

@media (max-width: 600px) {
    th, td { padding: 10px; font-size: 0.85rem; }
    .time-card { padding: 15px; }
    .time-header { flex-direction: column; gap: 5px; }
    .month-filter { flex-direction: column; align-items: stretch; }
    .month-total { text-align: left; }
    .report-actions { flex-direction: column; }
    .login-card { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---- Utskrift / PDF (ARK-2) ---- */
@media print {
    .navbar, .app-footer, .filter-card, .view-toggle,
    .chart-head .group-toggle, .pager, .report-actions, .chart-hint { display: none !important; }
    body { background: white; }
    .page { padding: 0; }
    table, .summary-card, .chart-card { box-shadow: none; }
    th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    a[href]:after { content: ""; }
}
