/* =============================================
   Ráðningaraðstoð — Icelandic Municipal Design
   Aesthetic: Nordic institutional — clean,
   authoritative, warm but professional.
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

/* ---- Theme variables ---- */
:root {
    --pico-font-family: 'Source Sans 3', -apple-system, sans-serif;
    --pico-font-size: 100%;
    --pico-line-height: 1.6;

    /* Nordic teal palette */
    --brand-900: #0a2e26;
    --brand-800: #0f4a3e;
    --brand-700: #146656;
    --brand-600: #1a826e;
    --brand-500: #1f9e86;
    --brand-400: #3db89e;
    --brand-300: #6fd4be;
    --brand-200: #a8e6d5;
    --brand-100: #d4f3eb;
    --brand-50:  #eefaf6;

    /* Warm sand accents */
    --sand-100: #faf8f5;
    --sand-200: #f0ece5;
    --sand-300: #e2dbd0;
    --sand-400: #c4b9a8;

    /* Status */
    --status-success: #1a7a5c;
    --status-success-bg: #e6f5ef;
    --status-warning: #8a6d00;
    --status-warning-bg: #fff8e1;
    --status-error: #b33b3b;
    --status-error-bg: #fde8e8;
    --status-info: #2c6fac;
    --status-info-bg: #e8f0fa;

    /* Override Pico primary to our brand */
    --pico-primary: var(--brand-700);
    --pico-primary-background: var(--brand-600);
    --pico-primary-border: var(--brand-600);
    --pico-primary-hover: var(--brand-800);
    --pico-primary-hover-background: var(--brand-700);
    --pico-primary-hover-border: var(--brand-700);
    --pico-primary-focus: rgba(20, 102, 86, 0.3);
    --pico-primary-inverse: #fff;
    --pico-text-selection-color: rgba(20, 102, 86, 0.15);

    /* Card & surface */
    --pico-card-background-color: #fff;
    --pico-card-border-color: var(--sand-200);
    --pico-card-sectioning-background-color: var(--sand-100);

    /* Subtle background texture */
    --surface-bg: var(--sand-100);
    --surface-raised: #fff;

    /* Spacing rhythm */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2.5rem;
    --space-2xl: 4rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(10, 46, 38, 0.06);
    --shadow-md: 0 2px 8px rgba(10, 46, 38, 0.08), 0 1px 2px rgba(10, 46, 38, 0.04);
    --shadow-lg: 0 8px 24px rgba(10, 46, 38, 0.1), 0 2px 8px rgba(10, 46, 38, 0.04);

    /* Borders */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

/* ---- Base ---- */
body {
    background: var(--surface-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.container {
    flex: 1;
    padding-top: var(--space-lg);
    padding-bottom: var(--space-2xl);
}

/* ---- Typography ---- */
h1, h2, h3 {
    font-family: 'DM Serif Display', Georgia, serif;
    font-weight: 400;
    color: var(--brand-900);
    letter-spacing: -0.01em;
}

h1 { font-size: 2.2rem; }
h2 { font-size: 1.65rem; margin-bottom: 0.3em; }
h3 { font-size: 1.25rem; }
h4, h5, h6 { font-family: 'Source Sans 3', sans-serif; font-weight: 600; }

hgroup > p {
    color: var(--brand-600);
    font-weight: 400;
}

/* ---- Navigation ---- */
nav.site-nav {
    background: var(--brand-900);
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(10, 46, 38, 0.15);
}

nav.site-nav ul {
    margin: 0;
    padding: 0;
}

nav.site-nav li {
    padding: var(--space-sm) 0;
}

nav.site-nav a {
    color: var(--brand-200);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s;
}

nav.site-nav a:hover {
    color: #fff;
}

nav.site-nav .brand-link {
    color: #fff;
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 1.15rem;
    letter-spacing: 0.01em;
}

nav.site-nav .nav-user {
    color: var(--brand-300);
    font-size: 0.85rem;
    opacity: 0.8;
}

nav.site-nav .btn-logout {
    color: var(--brand-300);
    border: 1px solid var(--brand-700);
    padding: 0.25em 0.75em;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
}

nav.site-nav .btn-logout:hover {
    background: var(--brand-800);
    color: #fff;
    border-color: var(--brand-600);
}

/* ---- Flash messages ---- */
.flash {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-lg);
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: flash-in 0.3s ease-out;
}

@keyframes flash-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.flash-success {
    background: var(--status-success-bg);
    border-left: 4px solid var(--status-success);
    color: #0f5132;
}

.flash-error {
    background: var(--status-error-bg);
    border-left: 4px solid var(--status-error);
    color: #842029;
}

.flash-info {
    background: var(--status-info-bg);
    border-left: 4px solid var(--status-info);
    color: #1a4a78;
}

.flash-warning {
    background: var(--status-warning-bg);
    border-left: 4px solid var(--status-warning);
    color: #664d03;
}

/* ---- Cards ---- */
article, .card {
    background: var(--surface-raised);
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

article header, .card header {
    background: var(--sand-100);
    border-bottom: 1px solid var(--sand-200);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

article header h3, .card header h3 {
    margin: 0;
    font-size: 1.05rem;
}

/* ---- Process cards ---- */
.process-card {
    background: var(--surface-raised);
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, border-color 0.2s;
    text-decoration: none;
    display: block;
}

.process-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--brand-300);
}

.process-card h3 {
    margin-bottom: 0.2rem;
    font-size: 1.15rem;
}

.process-card h3 a {
    color: var(--brand-800);
    text-decoration: none;
}

.process-card h3 a:hover {
    color: var(--brand-600);
}

.process-card .meta {
    color: #6b7280;
    font-size: 0.88rem;
    margin-bottom: 0.6rem;
}

.process-card .actions {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--sand-200);
}

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.2em 0.7em;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.badge-prep {
    background: var(--status-warning-bg);
    color: var(--status-warning);
}
.badge-prep::before { background: var(--status-warning); }

.badge-active {
    background: var(--status-success-bg);
    color: var(--status-success);
}
.badge-active::before { background: var(--status-success); }

.badge-done {
    background: var(--sand-200);
    color: #6b7280;
}
.badge-done::before { background: #9ca3af; }

.badge-admin {
    background: var(--brand-100);
    color: var(--brand-700);
}
.badge-admin::before { background: var(--brand-600); }

/* ---- Tabs ---- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--sand-200);
    margin-bottom: var(--space-lg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tabs a, .tabs button {
    padding: 0.7rem 1.3rem;
    text-decoration: none;
    color: #6b7280;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    font-family: 'Source Sans 3', sans-serif;
}

.tabs a:hover, .tabs button:hover {
    color: var(--brand-700);
}

.tabs a.active, .tabs button.active {
    color: var(--brand-700);
    border-bottom-color: var(--brand-600);
    font-weight: 600;
}

.tab-content {
    display: none;
    animation: tab-fade 0.25s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes tab-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- Tables ---- */
.score-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow-sm);
}

.score-table thead th {
    background: var(--brand-50);
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brand-800);
    padding: 0.7rem 0.85rem;
    border-bottom: 2px solid var(--brand-200);
    position: sticky;
    top: 0;
}

.score-table thead th a {
    color: var(--brand-800);
    text-decoration: none;
}

.score-table thead th a:hover {
    color: var(--brand-600);
}

.score-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--sand-200);
    font-size: 0.92rem;
    vertical-align: middle;
}

.score-table tbody tr:last-child td {
    border-bottom: none;
}

.score-table tbody tr:hover {
    background: var(--brand-50);
}

.score-table tr.top-ranked {
    background: var(--brand-100);
}

.score-table tr.top-ranked td:first-child {
    position: relative;
}

.score-table tr.top-ranked td:first-child::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--brand-600);
}

.score-table .score-cell {
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.score-table tfoot td {
    background: var(--sand-100);
    font-weight: 600;
    border-top: 2px solid var(--sand-300);
}

/* ---- Score radio groups ---- */
.score-radio-group {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.score-radio-group label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid var(--sand-300);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.15s;
    margin: 0;
    padding: 0;
}

.score-radio-group label:hover {
    border-color: var(--brand-400);
    background: var(--brand-50);
    color: var(--brand-700);
}

.score-radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.score-radio-group input[type="radio"]:checked + span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.score-radio-group label:has(input:checked) {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(20, 102, 86, 0.25);
}

.rubric-hint {
    font-size: 0.8rem;
    color: #9ca3af;
    font-style: italic;
    margin-top: 0.15rem;
    line-height: 1.4;
}

/* ---- Score preview bar ---- */
.score-preview-bar {
    background: linear-gradient(135deg, var(--brand-800), var(--brand-700));
    color: #fff;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem;
}

.score-preview-bar strong {
    color: var(--brand-200);
}

/* ---- Rökstuðningur letter ---- */
.letter-preview {
    background: #fff;
    border: 1px solid var(--sand-300);
    padding: 2.5rem 3rem;
    border-radius: var(--radius-sm);
    min-height: 400px;
    line-height: 1.8;
    white-space: pre-wrap;
    font-family: 'DM Serif Display', Georgia, 'Times New Roman', serif;
    font-size: 1.05rem;
    box-shadow: var(--shadow-md);
}

/* ---- Admin section ---- */
.admin-grid {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: var(--space-xl);
    min-height: 60vh;
}

.admin-sidebar {
    background: var(--surface-raised);
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-md);
    padding: var(--space-md) 0;
    align-self: start;
    position: sticky;
    top: 80px;
}

.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem var(--space-lg);
    color: #374151;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.admin-sidebar a:hover {
    background: var(--brand-50);
    color: var(--brand-700);
}

.admin-sidebar a.active {
    background: var(--brand-50);
    color: var(--brand-700);
    border-left-color: var(--brand-600);
    font-weight: 600;
}

.admin-sidebar .sidebar-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
    padding: var(--space-md) var(--space-lg) var(--space-xs);
}

.admin-content {
    min-width: 0;
}

/* ---- User management table ---- */
.user-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-100);
    color: var(--brand-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info .name {
    font-weight: 600;
    color: var(--brand-900);
    font-size: 0.92rem;
}

.user-info .detail {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ---- Buttons ---- */
.btn-sm {
    padding: 0.3em 0.85em !important;
    font-size: 0.82rem !important;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
}

.btn-danger {
    --pico-primary: var(--status-error);
    --pico-primary-background: var(--status-error);
    --pico-primary-border: var(--status-error);
    --pico-primary-hover-background: #922;
    --pico-primary-hover-border: #922;
}

/* ---- Actions row ---- */
.actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.actions a, .actions button {
    font-size: 0.85rem;
}

/* ---- Page header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.page-header hgroup {
    margin-bottom: 0;
}

.breadcrumb {
    font-size: 0.85rem;
    color: #9ca3af;
    margin-bottom: var(--space-sm);
}

.breadcrumb a {
    color: var(--brand-600);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ---- Stat cards ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--surface-raised);
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    color: var(--brand-700);
    line-height: 1.1;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.3rem;
}

/* ---- Empty states ---- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
    color: #9ca3af;
    background: var(--surface-raised);
    border: 2px dashed var(--sand-300);
    border-radius: var(--radius-lg);
}

.empty-state h3 {
    margin-bottom: var(--space-sm);
    color: #6b7280;
}

/* ---- Login page ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--brand-900) 0%, var(--brand-800) 40%, var(--brand-700) 100%);
    padding: var(--space-lg);
}

.login-card {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: var(--space-xl);
}

.login-card .login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-card .login-header h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--brand-800);
    margin-bottom: 0.2rem;
}

.login-card .login-header p {
    color: #9ca3af;
    font-size: 0.9rem;
}

.login-card .login-icon {
    width: 56px;
    height: 56px;
    background: var(--brand-100);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-md);
    font-size: 1.5rem;
}

/* ---- Form refinements ---- */
label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #374151;
}

input, select, textarea {
    border-radius: var(--radius-sm) !important;
}

fieldset {
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}

legend {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--brand-800);
    padding: 0 0.5rem;
}

details > summary {
    font-weight: 600;
    color: var(--brand-700);
    cursor: pointer;
}

small {
    color: #9ca3af;
}

/* ---- Modal / dialog ---- */
dialog article {
    max-width: 500px;
    width: 90vw;
}

/* ---- Print ---- */
@media print {
    nav.site-nav, footer, .no-print, .tabs, .actions, .breadcrumb {
        display: none !important;
    }
    main { padding: 0 !important; }
    body { background: #fff; }
    .letter-preview {
        border: none;
        padding: 0;
        box-shadow: none;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        position: static;
        display: flex;
        overflow-x: auto;
        padding: var(--space-sm);
        gap: 0;
    }
    .admin-sidebar a {
        padding: 0.5rem 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
    }
    .admin-sidebar a.active {
        border-left-color: transparent;
        border-bottom-color: var(--brand-600);
    }
    .admin-sidebar .sidebar-label {
        display: none;
    }
    .tabs {
        gap: 0;
    }
    .score-table {
        font-size: 0.82rem;
    }
    .page-header {
        flex-direction: column;
    }
    .letter-preview {
        padding: 1.5rem;
    }
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.35rem; }
}

/* ---- Utilities ---- */
.text-muted { color: #9ca3af; }
.text-sm { font-size: 0.85rem; }
.text-center { text-align: center; }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.gap-sm { gap: var(--space-sm); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.max-w-sm { max-width: 500px; }
.max-w-md { max-width: 700px; }
