/* =====================================================
   StudentToolBank – Main Stylesheet
   ===================================================== */

/* CSS Custom Properties */
:root {
    --color-sidebar-bg:   #1e3a5f;
    --color-sidebar-dark: #162d4a;
    --color-sidebar-text: #b8cce8;
    --color-sidebar-active: #3498db;
    --color-accent:       #3498db;
    --color-accent-dark:  #2980b9;
    --color-bg:           #f5f6fa;
    --color-card:         #ffffff;
    --color-text:         #333333;
    --color-text-light:   #666666;
    --color-border:       #e0e0e0;
    --color-success:      #27ae60;
    --color-danger:       #e74c3c;
    --color-warning:      #f39c12;
    --sidebar-width:      280px;
    --header-height:      56px;
    --border-radius:      6px;
    --shadow:             0 2px 8px rgba(0,0,0,0.10);
    --shadow-lg:          0 4px 20px rgba(0,0,0,0.15);
    --transition:         0.2s ease;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--color-accent-dark); }

img { max-width: 100%; height: auto; }

h1, h2, h3, h4 { line-height: 1.3; color: #1e3a5f; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1rem; }

/* ===== LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 20px 16px;
    background: var(--color-sidebar-dark);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 10px;
}

.sidebar-logo img {
    width: 36px;
    height: 36px;
    border-radius: 4px;
}

.sidebar-user {
    font-size: 0.8rem;
    color: var(--color-sidebar-text);
    opacity: 0.8;
}

/* Sidebar search */
.sidebar-search {
    padding: 12px 16px;
    background: var(--color-sidebar-dark);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-search input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px;
    color: #fff;
    font-size: 0.85rem;
    outline: none;
    transition: background var(--transition);
}

.sidebar-search input::placeholder { color: rgba(255,255,255,0.5); }
.sidebar-search input:focus { background: rgba(255,255,255,0.2); }

/* Nav tree */
.nav-tree {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.nav-section {
    margin: 4px 0;
}

.nav-section-title {
    padding: 6px 16px 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(184,204,232,0.5);
    font-weight: 600;
}

.nav-item {
    display: block;
    padding: 9px 16px;
    color: var(--color-sidebar-text);
    font-size: 0.875rem;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    border: none;
    width: 100%;
    text-align: left;
    background: none;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}

.nav-item.active {
    background: var(--color-accent);
    color: #fff;
}

.nav-item.nav-parent {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.nav-item.nav-parent::after {
    content: '▸';
    font-size: 0.7rem;
    transition: transform var(--transition);
    flex-shrink: 0;
}

.nav-item.nav-parent.expanded::after {
    transform: rotate(90deg);
}

.nav-sub {
    display: none;
    background: rgba(0,0,0,0.15);
}

.nav-sub.open { display: block; }

.nav-sub .nav-item {
    padding-left: 28px;
    font-size: 0.82rem;
}

.nav-sub-sub {
    display: none;
    background: rgba(0,0,0,0.1);
}

.nav-sub-sub.open { display: block; }

.nav-sub-sub .nav-item {
    padding-left: 40px;
    font-size: 0.8rem;
    color: rgba(184,204,232,0.85);
}

.nav-category {
    padding: 6px 28px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(184,204,232,0.4);
    font-weight: 600;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.sidebar-footer form { display: inline; }

.btn-logout {
    width: 100%;
    padding: 8px 12px;
    background: rgba(231,76,60,0.2);
    border: 1px solid rgba(231,76,60,0.4);
    border-radius: var(--border-radius);
    color: #e74c3c;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition);
    text-align: center;
}

.btn-logout:hover { background: rgba(231,76,60,0.35); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top header bar */
.topbar {
    position: sticky;
    top: 0;
    background: var(--color-card);
    border-bottom: 1px solid var(--color-border);
    padding: 0 24px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--color-text);
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: currentColor;
    margin: 5px 0;
    transition: all var(--transition);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--color-text-light);
    flex-wrap: wrap;
}

.breadcrumb a { color: var(--color-accent); }
.breadcrumb-sep { color: var(--color-border); }

.topbar-right { display: flex; align-items: center; gap: 12px; }

/* Quick search in topbar */
.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
}

.topbar-search input {
    padding: 7px 12px 7px 34px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: var(--color-bg);
    font-size: 0.85rem;
    outline: none;
    width: 200px;
    transition: width var(--transition), border-color var(--transition);
}

.topbar-search input:focus {
    width: 280px;
    border-color: var(--color-accent);
}

.topbar-search-icon {
    position: absolute;
    left: 10px;
    color: var(--color-text-light);
    font-size: 0.85rem;
    pointer-events: none;
}

/* Page content area */
.page-content {
    padding: 28px 32px;
    flex: 1;
}

/* ===== CARDS ===== */
.card {
    background: var(--color-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-header {
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 { margin: 0; }

/* ===== DASHBOARD REGION GRID ===== */
.region-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-top: 8px;
}

.region-card {
    background: var(--color-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: transform var(--transition), box-shadow var(--transition);
    border-top: 4px solid var(--color-accent);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: block;
}

.region-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    color: inherit;
}

.region-card-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    display: block;
}

.region-card h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
    color: var(--color-sidebar-bg);
}

.region-card p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-text-light);
    line-height: 1.4;
}

/* Different border colors per region */
.region-skuldra  { border-top-color: #3498db; }
.region-arm      { border-top-color: #2ecc71; }
.region-landrygg { border-top-color: #9b59b6; }
.region-hoft     { border-top-color: #e67e22; }
.region-kna      { border-top-color: #e74c3c; }
.region-fot      { border-top-color: #1abc9c; }

/* ===== STATS ROW ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-accent);
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-top: 4px;
}

/* ===== CONTENT PAGE STYLES ===== */
.content-page h2 {
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 10px;
    margin-bottom: 20px;
}

.content-page .info-box {
    background: #e8f4fd;
    border-left: 4px solid var(--color-accent);
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    padding: 16px 20px;
    margin: 16px 0;
}

.content-page .info-box p { margin: 0; }

.content-page .steps-list {
    counter-reset: steps;
    list-style: none;
    padding: 0;
}

.content-page .steps-list li {
    counter-increment: steps;
    display: flex;
    gap: 14px;
    margin-bottom: 12px;
}

.content-page .steps-list li::before {
    content: counter(steps);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    background: var(--color-accent);
    color: #fff;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-region { background: #e8f4fd; color: #1e3a5f; }
.badge-led     { background: #e8f8f5; color: #1a6b57; }
.badge-muskel  { background: #fef9e7; color: #7d6608; }
.badge-nerv    { background: #fdf2f8; color: #7b241c; }

/* Body image in content pages */
.body-image-wrap {
    text-align: center;
    margin: 20px 0;
}

.body-image-wrap img { max-width: 140px; opacity: 0.7; }

/* ===== VIDEO PLAYER ===== */
.video-wrap {
    margin: 16px 0 20px;
    text-align: center;
}
.video-wrap video {
    width: 100%;
    max-width: 720px;
    border-radius: 6px;
    background: #000;
    display: block;
    margin: 0 auto;
}

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

table.stb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.stb-table th {
    background: var(--color-sidebar-bg);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
}

.stb-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
}

.stb-table tr:hover td { background: var(--color-bg); }

.stb-table .actions { white-space: nowrap; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #444;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}

.form-control.is-invalid { border-color: var(--color-danger); }

.form-hint {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-top: 4px;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background var(--transition), transform var(--transition);
    text-decoration: none;
    min-height: 44px;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary   { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-dark); color: #fff; }

.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; color: #fff; }

.btn-success   { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #219a52; color: #fff; }

.btn-danger    { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #c0392b; color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}
.btn-outline:hover { background: var(--color-bg); }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; min-height: 32px; }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #2a5080 50%, #1e3a5f 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo img { width: 80px; height: 80px; }

.login-title {
    text-align: center;
    margin-bottom: 28px;
}

.login-title h1 {
    font-size: 1.4rem;
    margin: 8px 0 4px;
    color: #1e3a5f;
}

.login-title p {
    color: var(--color-text-light);
    font-size: 0.875rem;
    margin: 0;
}

/* ===== SEARCH RESULTS ===== */
.search-results { margin-top: 16px; }

.search-result-item {
    background: var(--color-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 18px 22px;
    margin-bottom: 12px;
    transition: box-shadow var(--transition);
}

.search-result-item:hover { box-shadow: var(--shadow-lg); }

.search-result-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-accent);
    margin: 0 0 4px;
}

.search-result-meta {
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-bottom: 6px;
}

.search-result-excerpt {
    font-size: 0.875rem;
    color: var(--color-text);
}

.search-result-excerpt mark {
    background: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
}

.search-no-results {
    text-align: center;
    padding: 40px;
    color: var(--color-text-light);
}

/* ===== ORDLISTA ===== */
.ordlista-az {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.ordlista-az a {
    display: inline-block;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    background: var(--color-sidebar-bg);
    color: #fff;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--transition);
}

.ordlista-az a:hover { background: var(--color-accent); text-decoration: none; }

.ordlista-letter-header {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-sidebar-bg);
    border-bottom: 2px solid var(--color-accent);
    margin: 24px 0 12px;
    padding-bottom: 6px;
}

.ordlista-filter {
    margin-bottom: 20px;
    position: relative;
}

.ordlista-filter input {
    width: 100%;
    max-width: 400px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
}

.ordlista-filter input:focus { border-color: var(--color-accent); }

.ordlista-table { width: 100%; }

.ordlista-table td:first-child {
    font-weight: 600;
    color: #1e3a5f;
    padding-right: 20px;
    vertical-align: top;
    white-space: nowrap;
}

.ordlista-table td { padding: 6px 0; border-bottom: 1px solid var(--color-border); }

.ordlista-hidden { display: none; }

/* ===== DERMATOMKARTA ===== */
.dermatom-page img {
    max-width: 100%;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

/* ===== ADMIN ===== */
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active   { background: #d4edda; color: #155724; }
.status-inactive { background: #f8d7da; color: #721c24; }
.status-admin    { background: #cce5ff; color: #004085; }
.status-user     { background: #e2e3e5; color: #383d41; }
.status-superadmin { background: #fdf2f8; color: #7b241c; }

/* ===== PAGINATION ===== */
.pagination { display: flex; gap: 6px; margin-top: 20px; }

.pagination a, .pagination span {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    color: var(--color-accent);
}

.pagination .current { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

/* ===== MOBILE OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

    .page-content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
    }

    .topbar-search input {
        width: 140px;
    }

    .topbar-search input:focus {
        width: 180px;
    }

    .region-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 14px;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    h1 { font-size: 1.3rem; }

    .card { padding: 16px; }
}

@media (max-width: 480px) {
    .region-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .topbar-search { display: none; }
}

/* ===== UTILITIES ===== */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--color-text-light); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.w-100 { width: 100%; }

/* Print */
@media print {
    .sidebar, .topbar, .hamburger, .btn-logout { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
}
