/* Shared styles for teacher salary dashboard & subpages */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
    --color-bg: #eef2f7;
    --color-bg-end: #e8f0f8;
    --color-surface: #ffffff;
    --color-text: #2c3e50;
    --color-text-muted: #7f8c8d;
    --color-text-light: #95a5a6;
    --color-primary: #3498db;
    --color-primary-dark: #2980b9;
    --color-header: #1a5276;
    --color-header-end: #2471a3;
    --color-accent: #8e44ad;
    --color-accent-bg: #f4ecf7;
    --color-role-bg: #ebf5fb;
    --color-error: #c0392b;
    --color-error-bg: #fdedec;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(26, 82, 118, 0.06);
    --shadow-md: 0 4px 20px rgba(26, 82, 118, 0.1);
    --shadow-lg: 0 12px 40px rgba(26, 82, 118, 0.12);
    --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    margin: 0;
    padding: 0;
    background: linear-gradient(165deg, var(--color-bg) 0%, #f5f7fa 40%, var(--color-bg-end) 100%);
    background-attachment: fixed;
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

/* —— Site header —— */
.site-header {
    background: linear-gradient(135deg, var(--color-header) 0%, var(--color-header-end) 100%);
    color: white;
    box-shadow: 0 4px 24px rgba(26, 82, 118, 0.25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: white;
}

.site-brand-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.site-brand-text strong {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.site-brand-text span {
    font-size: 0.75rem;
    opacity: 0.85;
    font-weight: 500;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-link {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.12);
    transition: background 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateX(-2px);
}

/* —— Page layout —— */
.page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.page-hero {
    margin-bottom: 28px;
}

.page-hero h1 {
    margin: 0 0 10px;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.03em;
}

.page-hero p {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 1.05rem;
    max-width: 640px;
    line-height: 1.55;
}

.page-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-subnav .text-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 14px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(52, 152, 219, 0.12);
    transition: transform 0.2s, box-shadow 0.2s, color 0.2s;
}

.page-subnav .text-link:hover {
    color: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 14px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(52, 152, 219, 0.12);
    transition: transform 0.2s, box-shadow 0.2s;
}

.back-link:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}

.breadcrumb-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

/* —— Entity headers —— */
.entity-header,
.school-header,
.kommun-header,
.role-header {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px 32px;
    margin-bottom: 28px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-left: 4px solid var(--color-primary);
}

.school-name,
.kommun-name,
.role-name {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.school-info,
.role-info,
.role-code {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.role-code {
    font-weight: 500;
}

/* —— Stats —— */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(52, 152, 219, 0.08);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 8px 0 4px;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stats-summary {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    text-align: center;
    border: 1px solid rgba(52, 152, 219, 0.08);
}

.stats-summary .stat-value {
    font-size: 2rem;
    margin: 10px 0;
}

/* —— Panels & controls —— */
.panel,
.controls,
.search-box {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px 28px;
    margin-bottom: 28px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.panel-title,
.controls h2,
.data-table-container h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 20px;
    letter-spacing: -0.02em;
}

.controls-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label,
.controls label {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.9rem;
}

select,
button,
input[type="text"] {
    padding: 12px 16px;
    font-size: 0.95rem;
    font-family: inherit;
    border: 2px solid #e8ecef;
    border-radius: var(--radius-sm);
    background: #fafbfc;
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

select:hover,
input[type="text"]:hover {
    border-color: var(--color-primary);
    background: white;
}

select:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
    background: white;
}

input[type="text"] {
    width: 100%;
}

button {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(52, 152, 219, 0.3);
    margin-top: 4px;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

button:disabled {
    background: var(--color-text-light);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.search-box input {
    width: 100%;
}

/* —— Cards grid (kommun / roll lists) —— */
.kommun-grid,
.roll-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.kommun-card,
.roll-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    border: 1px solid rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

.kommun-card::before,
.roll-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--color-primary), #5dade2);
    transition: height 0.2s;
}

.kommun-card:hover,
.roll-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    background: var(--color-surface);
}

.kommun-card:hover::before,
.roll-card:hover::before {
    height: 5px;
}

.kommun-card .kommun-name,
.roll-card .roll-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.kommun-stats,
.roll-count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.roll-code {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

/* —— Tables —— */
.data-table-container,
.data-section {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px 32px;
    margin-bottom: 28px;
    border: 1px solid rgba(0, 0, 0, 0.04);
    overflow-x: auto;
}

.data-section .section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f0f3f5;
    letter-spacing: -0.02em;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

th {
    background: linear-gradient(135deg, var(--color-header) 0%, var(--color-header-end) 100%);
    color: white;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    position: sticky;
    top: 0;
    z-index: 1;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: filter 0.2s;
}

th.sortable:hover {
    filter: brightness(1.08);
}

th.sortable::after {
    content: ' ↕';
    opacity: 0.5;
    font-size: 0.75rem;
}

th.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

th.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

td {
    padding: 11px 14px;
    border-bottom: 1px solid #f0f3f5;
    font-size: 0.925rem;
}

tr:hover {
    background-color: #fafbfc;
}

.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.clickable-row:hover {
    background-color: var(--color-role-bg) !important;
}

.number {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
}

.school-name-cell {
    font-weight: 600;
    color: var(--color-text);
}

.school-details {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* —— Roll view accordion —— */
.kommun-item {
    margin-bottom: 14px;
    border: 1px solid #e8ecef;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface);
}

.kommun-item > .kommun-header {
    background: linear-gradient(180deg, #fafbfc 0%, #f4f6f8 100%);
    padding: 16px 20px;
    margin-bottom: 0;
    border-radius: 0;
    border-left: none;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.kommun-item > .kommun-header:hover {
    background: var(--color-role-bg);
}

.kommun-item > .kommun-header.expanded {
    background: var(--color-role-bg);
    border-bottom: 1px solid #e8ecef;
}

.kommun-item .kommun-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0;
}

.kommun-item .kommun-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    font-size: 0.85rem;
}

.kommun-item .kommun-stats span {
    font-weight: 700;
    color: var(--color-primary);
}

.expand-icon {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.kommun-item > .kommun-header.expanded .expand-icon {
    transform: rotate(180deg);
}

.kommun-content {
    display: none;
    padding: 20px;
}

.kommun-content.expanded {
    display: block;
}

/* —— Chart —— */
.chart-container {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px 32px;
    margin-bottom: 28px;
    height: 400px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

/* —— States —— */
.loading {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-muted);
    font-size: 1.05rem;
}

.error {
    background: var(--color-error-bg);
    color: var(--color-error);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin: 20px 0;
    border: 1px solid rgba(192, 57, 43, 0.2);
    font-weight: 500;
}

.error a {
    color: var(--color-primary-dark);
    font-weight: 600;
}

.no-data {
    text-align: center;
    padding: 24px;
    color: var(--color-text-muted);
    font-style: italic;
}

@media (max-width: 640px) {
    .page {
        padding: 20px 16px 36px;
    }

    .panel,
    .controls,
    .search-box,
    .data-table-container,
    .data-section,
    .chart-container {
        padding: 18px 20px;
    }

    .entity-header,
    .school-header,
    .kommun-header,
    .role-header {
        padding: 20px;
    }

    .kommun-grid,
    .roll-grid {
        grid-template-columns: 1fr;
    }
}
