/* ============================================================
   GP Digital Maturity Dashboard — Main Stylesheet
   Aesthetic: Clinical precision meets modern data design
   ============================================================ */

:root {
    --nhs-blue: #003087;
    --nhs-mid: #0072CE;
    --nhs-light: #41B6E6;
    --nhs-green: #009639;
    --nhs-warm: #FFB81C;
    --nhs-red: #DA291C;

    --bg-base: #F0F4F8;
    --bg-card: #FFFFFF;
    --bg-dark: #0A1628;
    --bg-panel: #EBF3FA;

    --text-primary: #0D1B2A;
    --text-secondary: #4A5568;
    --text-muted: #8896A5;
    --text-on-dark: #E8F0F8;

    --border: #D1DCE8;
    --border-focus: var(--nhs-mid);
    --shadow-sm: 0 1px 3px rgba(0,48,135,0.08);
    --shadow-md: 0 4px 16px rgba(0,48,135,0.12);
    --shadow-lg: 0 12px 40px rgba(0,48,135,0.15);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --font-body: 'Sora', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Maturity level colors */
    --level-exemplar:  #10B981;
    --level-advanced:  #3B82F6;
    --level-developing:#F59E0B;
    --level-foundation:#EF4444;
    --level-early:     #9CA3AF;

    /* Place colors */
    --place-nel: #0072CE;
    --place-nl:  #00A499;
    --place-ery: #7B2D8B;
    --place-yny: #DA291C;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* ── HEADER ── */
.site-header {
    background: var(--bg-dark);
    border-bottom: 2px solid var(--nhs-blue);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(0,0,0,0.3);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-text {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.site-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-on-dark);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    opacity: 0.75;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.1);
    opacity: 1;
    color: white;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 100px;
    padding: 4px 14px 4px 4px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
a.user-pill:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.25);
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: var(--nhs-mid);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

.user-name {
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.btn-logout:hover {
    background: rgba(218,41,28,0.2);
    color: #FF6B6B;
}

/* ── MAIN LAYOUT ── */
.site-main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ── FOOTER ── */
.site-footer {
    background: var(--bg-dark);
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 16px 24px;
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-copy, .footer-version {
    color: rgba(255,255,255,0.35);
    font-size: 0.8rem;
}

/* ── PAGE HEADER ── */
.page-header {
    margin-bottom: 32px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.8rem;
}

.breadcrumb a {
    color: var(--nhs-mid);
    text-decoration: none;
    font-weight: 500;
}

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

.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-current { color: var(--text-secondary); }

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 6px;
}

/* ── ALERTS ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 3px solid;
}

.alert-error {
    background: #FEF2F2;
    color: #991B1B;
    border-color: var(--nhs-red);
}

.alert-success {
    background: #F0FDF4;
    color: #166534;
    border-color: var(--nhs-green);
}

.alert-info {
    background: #EFF6FF;
    color: #1E40AF;
    border-color: var(--nhs-mid);
}

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(0,114,206,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0,150,57,0.08) 0%, transparent 70%);
    pointer-events: none;
}

.login-brand {
    padding: 32px 48px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand-text {
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    font-size: 0.95rem;
}

.login-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}

.login-heading {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.03em;
    margin-bottom: 6px;
}

.login-subheading {
    color: rgba(255,255,255,0.5);
    font-size: 0.875rem;
    margin-bottom: 36px;
}

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

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: white;
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.form-input::placeholder { color: rgba(255,255,255,0.25); }

.form-input:focus {
    border-color: var(--nhs-mid);
    background: rgba(0,114,206,0.08);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--nhs-mid);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    letter-spacing: -0.01em;
    margin-top: 8px;
}

.btn-primary:hover { background: #005fa3; }
.btn-primary:active { transform: scale(0.98); }

.login-note {
    text-align: center;
    margin-top: 20px;
    font-size: 0.78rem;
    color: rgba(255,255,255,0.3);
}

/* ── REGION CARDS (DASHBOARD) ── */
.place-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.place-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.place-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.place-card-accent {
    height: 5px;
    width: 100%;
}

.place-card-body {
    padding: 24px;
    flex: 1;
}

.place-name {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.place-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.place-meta {
    display: flex;
    gap: 16px;
}

.place-stat {
    display: flex;
    flex-direction: column;
}

.place-stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-family: var(--font-mono);
}

.place-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.place-card-footer {
    padding: 14px 24px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.place-avg-score {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── PRACTICE LIST ── */
.practices-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    min-width: 280px;
}

.search-box input {
    border: none;
    outline: none;
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text-primary);
    width: 100%;
}

.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.practice-table-wrap {
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.practice-table {
    width: 100%;
    border-collapse: collapse;
}

.practice-table th {
    background: var(--bg-panel);
    padding: 12px 20px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.practice-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}

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

.practice-table tbody tr {
    transition: background 0.1s;
    cursor: pointer;
}

.practice-table tbody tr:hover { background: var(--bg-panel); }

.practice-name-link {
    font-weight: 600;
    color: var(--nhs-blue);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.practice-name-link:hover { color: var(--nhs-mid); text-decoration: underline; }

.ods-badge {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: var(--bg-panel);
    color: var(--text-secondary);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.score-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
}

.score-bar-bg {
    flex: 1;
    height: 6px;
    background: var(--bg-base);
    border-radius: 3px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.score-val {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 500;
    min-width: 36px;
    text-align: right;
}

.maturity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.level-exemplar  { background: #D1FAE5; color: #065F46; }
.level-advanced  { background: #DBEAFE; color: #1E40AF; }
.level-developing{ background: #FEF3C7; color: #92400E; }
.level-foundation{ background: #FEE2E2; color: #991B1B; }
.level-early     { background: #F3F4F6; color: #374151; }

/* ── DASHBOARD PAGE ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue  { background: #EFF6FF; color: var(--nhs-mid); }
.stat-icon-green { background: #F0FDF4; color: var(--nhs-green); }
.stat-icon-amber { background: #FFFBEB; color: #D97706; }
.stat-icon-purple{ background: #F5F3FF; color: #7C3AED; }

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* ── PRACTICE DASHBOARD ── */
.practice-overview {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 900px) {
    .practice-overview { grid-template-columns: 1fr; }
}

.practice-info-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.practice-overall-score {
    background: var(--bg-dark);
    border-radius: var(--radius-md);
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
    box-shadow: var(--shadow-md);
}

.big-score {
    font-size: 4rem;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.05em;
    line-height: 1;
    margin: 12px 0;
}

.big-score-label { font-size: 0.8rem; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 0.08em; }
.big-score-sublabel { font-size: 0.875rem; color: rgba(255,255,255,0.7); margin-top: 4px; }

.practice-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 24px;
    margin-top: 16px;
}

.detail-item-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.detail-item-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-top: 2px;
}

.domains-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.domain-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.domain-card:hover { box-shadow: var(--shadow-md); }

.domain-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.domain-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-panel);
    color: var(--nhs-blue);
}

.domain-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.domain-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}

.domain-score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.domain-score-num {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.domain-progress {
    height: 8px;
    background: var(--bg-base);
    border-radius: 4px;
    overflow: hidden;
}

.domain-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ── RADAR CHART CANVAS ── */
.radar-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
}

/* ── Radar grid responsive ── */
.radar-wrap { flex-direction: column; align-items: center; }
@media (max-width: 900px) { .radar-two-col { grid-template-columns: 1fr !important; } }
/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .header-inner { padding: 0 16px; gap: 12px; }
    .site-main { padding: 20px 16px; }
    .page-title { font-size: 1.5rem; }
    .login-card { padding: 32px 24px; }
    .place-grid { grid-template-columns: 1fr; }
    .domains-grid { grid-template-columns: 1fr; }
    .practice-detail-grid { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: 1fr 1fr; }
}

/* ── ANIMATIONS ── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeInUp 0.4s ease both;
}

.animate-in:nth-child(1) { animation-delay: 0.05s; }
.animate-in:nth-child(2) { animation-delay: 0.10s; }
.animate-in:nth-child(3) { animation-delay: 0.15s; }
.animate-in:nth-child(4) { animation-delay: 0.20s; }
.animate-in:nth-child(5) { animation-delay: 0.25s; }
.animate-in:nth-child(6) { animation-delay: 0.30s; }
.animate-in:nth-child(7) { animation-delay: 0.35s; }
.animate-in:nth-child(8) { animation-delay: 0.40s; }

/* ── TABLE PAGINATION ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.page-links { display: flex; gap: 4px; }

.page-link {
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: background 0.1s;
}

.page-link:hover, .page-link.active { background: var(--nhs-mid); color: white; border-color: var(--nhs-mid); }

/* ── REGION BANNER ── */
.place-banner {
    height: 6px;
    border-radius: 3px;
    margin-bottom: 24px;
}

/* ── SPINNER ── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }