/* ============================================================
   Auto Electronics Academy
   Professional bench-lab theme — wiring, modules, diagnostics
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --primary: #f59e0b;
    --primary-dark: #d97706;
    --secondary: #38bdf8;
    --accent: #22d3ee;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;

    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-bright: #f8fafc;

    --bg: #0b1220;
    --bg-elevated: #111827;
    --card-bg: #151c2c;
    --card-bg-hover: #1a2336;
    --border: #243044;
    --border-strong: #334155;

    --header-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 45%, #0c4a6e 100%);
    --header-glow: rgba(56, 189, 248, 0.15);
    --footer-bg: #070b14;
    --sidebar-bg: #0f1523;

    --sidebar-width: 300px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(0,0,0,0.35);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.35);

    --font: 'DM Sans', system-ui, -apple-system, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--header-glow), transparent),
        linear-gradient(180deg, var(--bg) 0%, #080d18 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

header {
    background: var(--header-bg);
    color: var(--text-bright);
    text-align: center;
    padding: 1.85rem 1.5rem;
    position: relative;
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(56, 189, 248, 0.2);
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, transparent 0%, rgba(56,189,248,0.06) 50%, transparent 100%),
        repeating-linear-gradient(90deg, transparent, transparent 48px, rgba(245,158,11,0.04) 48px, rgba(245,158,11,0.04) 49px);
    pointer-events: none;
}

header h1 {
    position: relative;
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.3rem;
    background: linear-gradient(90deg, #ffffff 0%, #e2e8f0 55%, var(--primary, #2dd4bf) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

header p {
    position: relative;
    font-size: 0.95rem;
    color: #94a3b8;
    font-weight: 500;
}

.header-links {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    z-index: 2;
}

.header-links a {
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.25);
    transition: all 0.2s;
}

.header-links a:hover {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.45);
    color: #fff;
}

.container {
    display: flex;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    min-height: calc(100vh - 180px);
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 1.35rem 1.1rem;
    overflow-y: auto;
    flex-shrink: 0;
}

.content {
    flex: 1;
    padding: 1.75rem 2rem;
    background: transparent;
}

.tree h3, .sidebar > h3 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--secondary);
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tree h3 i, .sidebar > h3 i { color: var(--primary); }

.category {
    margin-bottom: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    overflow: hidden;
}

.category-header {
    padding: 0.7rem 0.85rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-bright);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(56,189,248,0.06), transparent);
}

.guides-list { list-style: none; }

.guide {
    padding: 0.55rem 0.85rem 0.55rem 1.15rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: all 0.15s;
}

.guide:hover {
    color: var(--text-bright);
    background: rgba(56, 189, 248, 0.06);
    border-left-color: var(--secondary);
}

.guide.active {
    color: var(--primary);
    background: rgba(245, 158, 11, 0.08);
    border-left-color: var(--primary);
    font-weight: 600;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem 1.5rem;
    margin-bottom: 1.15rem;
    box-shadow: var(--shadow);
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 1rem; right: 1rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(56,189,248,0.35), transparent);
}

.card h3, .card h2 { color: var(--text-bright); }

label, form label {
    display: block;
    margin: 1rem 0 0.35rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
}

form label:first-child { margin-top: 0; }

form input, form select, form textarea,
input[type=text], input[type=email], input[type=password],
input[type=number], input[type=datetime-local], input[type=color],
select, textarea {
    width: 100%;
    padding: 0.7rem 0.95rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: var(--font);
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--bg-elevated);
    color: var(--text-bright);
}

form input:focus, form select:focus, form textarea:focus,
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

input::placeholder, textarea::placeholder { color: #64748b; }

.submit-btn, button[type="submit"], button.submit-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #0f172a;
    padding: 0.75rem 1.4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
    margin-top: 1rem;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--primary, #2dd4bf) 28%, transparent);
}

.submit-btn:hover, button[type="submit"]:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--primary, #2dd4bf) 35%, transparent);
}

.admin-menu { list-style: none; }
.admin-menu li { margin-bottom: 0.2rem; }

.admin-menu a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.9rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.admin-menu a:hover {
    background: rgba(56, 189, 248, 0.08);
    color: var(--text-bright);
    border-color: var(--border);
}

.admin-menu a i {
    width: 18px;
    text-align: center;
    color: var(--primary);
    opacity: 0.9;
}

.table-wrap, .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}
table, .data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    font-size: 0.9rem;
}

th, td, .data-table th, .data-table td {
    padding: 0.75rem 0.9rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th, .data-table th {
    background: rgba(15, 23, 42, 0.9);
    color: var(--secondary);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(56, 189, 248, 0.04); }

.delete-btn { color: var(--danger); text-decoration: none; font-weight: 600; font-size: 0.88rem; }
.edit-btn { color: var(--secondary); text-decoration: none; font-weight: 600; font-size: 0.88rem; }

.content h2 {
    font-size: 1.45rem;
    color: var(--text-bright);
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.content h3 {
    font-size: 1.1rem;
    color: var(--text-bright);
    margin: 1.35rem 0 0.75rem;
    font-weight: 650;
}

.steps, .tips {
    background: var(--card-bg);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

footer {
    background: var(--footer-bg);
    color: #64748b;
    text-align: center;
    padding: 1.35rem;
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

a { color: var(--secondary); }
a:hover { color: var(--accent); }

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    color: var(--primary);
}

@media (max-width: 768px) {
    table, .data-table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    .content { overflow-x: hidden; }
    .table-wrap, .table-responsive { max-width: 100%; }
    .container { flex-direction: column; }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 320px;
    }
    .header-links {
        position: static;
        justify-content: center;
        margin-top: 0.85rem;
        flex-wrap: wrap;
    }
    header { padding-bottom: 1.25rem; }
    header h1 { font-size: 1.45rem; }
    .content { padding: 1.25rem; }
}

/* Admin sidebar groups */
.admin-group { margin-bottom: 0.85rem; }
.admin-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0.35rem 0.9rem 0.25rem;
    opacity: 0.85;
}
.admin-menu li.active a {
    background: rgba(56, 189, 248, 0.12);
    color: var(--text-bright);
    border-color: var(--border);
}

/* Build number in footers */
footer .build-num {
    font-family: var(--mono, ui-monospace, monospace);
    font-size: 0.78em;
    opacity: 0.85;
    letter-spacing: 0.02em;
}

.menu-emoji, .cat-icon-label { font-style: normal; }
.admin-menu a .menu-emoji { margin-right: 0.15rem; }


/* Site page links under Knowledge sidebar (not top header) */
.nav-pages {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.nav-pages-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.nav-pages-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav-pages-list li a {
    display: block;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}
.nav-pages-list li a:hover,
.nav-pages-list li.active a {
    background: rgba(245, 158, 11, 0.12);
    color: var(--primary);
}
.nav-pages-list li a i {
    width: 1.2rem;
    color: var(--primary);
}
.header-links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Prevent admin tables from hanging off mobile viewport */
@media (max-width: 900px) {
  .content table, .content .data-table, main table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .content, main.content { overflow-x: hidden; max-width: 100%; }
}
