/* ==============================================
   Mobile Web Tutorial - Main Stylesheet
   ============================================== */

/* ========== CSS Variables ========== */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #93c5fd;
    --bg: #f0f4ff;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --code-bg: #1e1e2e;
    --code-text: #cdd6f4;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --radius: 10px;
    --transition: 0.3s ease;
}

/* ========== Reset & Base ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 70px;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
}

/* ========== Navbar ========== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #1e293b;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.navbar .logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 1001;
}

.navbar .logo span { font-size: 1.6rem; }

.navbar .nav-links {
    display: flex;
    gap: 0.3rem;
    list-style: none;
    align-items: center;
}

.navbar .nav-links > li {
    position: relative;
}

.navbar .nav-links > li > a {
    text-decoration: none;
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    transition: var(--transition);
    white-space: nowrap;
    display: block;
}

.navbar .nav-links > li > a:hover {
    background: #1e293b;
    color: var(--primary);
}

/* Dropdown Button */
.nav-dropdown-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.nav-dropdown-btn:hover,
.nav-dropdown-btn.active {
    background: #1e293b;
    color: var(--primary);
}

/* Dropdown Menu */
.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    min-width: 160px;
    padding: 6px 0;
    list-style: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 1002;
}

.nav-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.nav-dropdown-menu li a {
    display: block;
    padding: 8px 18px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-dropdown-menu li a:hover {
    background: #1e293b;
    color: var(--primary);
}

/* Hamburger */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
}

.hamburger:hover { background: #1e293b; }

.hamburger .hamburger-line {
    display: block;
    width: 22px;
    height: 2.5px;
    background: #94a3b8;
    border-radius: 2px;
    transition: var(--transition);
    transform-origin: center;
}

.hamburger.active .hamburger-line:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
    background: var(--primary);
}
.hamburger.active .hamburger-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.active .hamburger-line:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
    background: var(--primary);
}

.nav-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.nav-overlay.active { display: block; opacity: 1; }

@media (max-width: 768px) {
    .hamburger { display: flex; }
    .navbar .nav-links {
        position: fixed;
        top: 0; right: -100%;
        width: 260px; height: 100vh;
        flex-direction: column; align-items: stretch; gap: 0;
        background: #0f172a;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
        padding: 80px 1.5rem 2rem;
        z-index: 1000;
        transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }
    .navbar .nav-links.active { right: 0; }
    .navbar .nav-links > li { border-bottom: 1px solid #1e293b; }
    .navbar .nav-links > li > a { display: block; padding: 14px 12px; font-size: 1rem; border-radius: 8px; }

    /* Mobile dropdown */
    .nav-dropdown {
        display: flex;
        flex-direction: column;
    }
    .nav-dropdown-btn {
        display: flex; align-items: center; justify-content: space-between;
        width: 100%; text-align: left;
        padding: 14px 12px; font-size: 1rem; border-radius: 8px;
    }
    .nav-dropdown-btn::after {
        content: '▾';
        font-size: 0.7rem;
        transition: transform 0.25s ease;
    }
    .nav-dropdown-btn.active::after {
        transform: rotate(180deg);
    }
    .nav-dropdown-menu {
        position: static !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        background: rgba(30, 41, 59, 0.4);
        border: none !important;
        border-radius: 0 0 8px 8px !important;
        box-shadow: none !important;
        margin: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        min-width: unset;
    }
    .nav-dropdown-menu.show {
        max-height: 500px;
        padding: 4px 0;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
    .nav-dropdown-menu li { border-bottom: none; }
    .nav-dropdown-menu li a {
        padding: 10px 12px 10px 28px;
        font-size: 0.92rem;
        border-radius: 6px;
        color: #94a3b8;
        white-space: normal;
    }
    .nav-dropdown-menu li a:hover {
        background: #1e293b;
        color: var(--primary);
    }
    body.menu-open { overflow: hidden; }
}

/* ========== Hero ========== */
.hero {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    color: #fff;
    text-align: center;
    padding: 80px 2rem 70px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 30% 70%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
    animation: heroPulse 8s ease-in-out infinite;
}

@keyframes heroPulse {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(20px, -20px); }
}

.hero h1 {
    font-size: 2.8rem;
    font-weight: 800;
    position: relative;
    margin-bottom: 1rem;
    letter-spacing: -1px;
    color: var(--primary);
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
    position: relative;
    max-width: 650px;
    margin: 0 auto;
    color: #94a3b8;
}

.hero .badge-row {
    display: flex; gap: 12px;
    justify-content: center; margin-top: 1.5rem;
    position: relative; flex-wrap: wrap;
}

.hero .badge {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--primary);
    padding: 6px 16px; border-radius: 20px;
    font-size: 0.85rem; font-weight: 500;
}

/* ========== Main Layout ========== */
.main-container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 2rem;
    padding: 2rem;
}

/* ========== Sidebar ========== */
.sidebar {
    position: sticky;
    top: 80px;
    width: 250px;
    min-width: 250px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.sidebar h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary);
}

.sidebar ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }

.sidebar ul a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.88rem;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar ul a:hover,
.sidebar ul a.active {
    background: #eff6ff;
    color: var(--primary-dark);
    font-weight: 600;
}

/* ========== Content Area ========== */
.content {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 2rem;
}

.section {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    transition: var(--transition);
}

.section:hover { box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1); }

.section h2 {
    font-size: 1.8rem;
    color: #0f172a;
    margin-bottom: 0.5rem;
    padding-bottom: 0.6rem;
    border-bottom: 3px solid #dbeafe;
    display: flex; align-items: center; gap: 10px;
}

.section h2 .icon { font-size: 1.6rem; }

.section h3 {
    font-size: 1.25rem;
    margin: 1.8rem 0 0.8rem;
    color: #1e293b;
}

.section p { margin-bottom: 1rem; color: #475569; }

/* ========== Tables ========== */
.table-wrapper { overflow-x: auto; margin: 1.2rem 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

table thead { background: #eff6ff; }

table th, table td {
    padding: 10px 14px;
    text-align: left;
    border: 1px solid var(--border);
}

table th {
    font-weight: 700;
    color: var(--primary-dark);
    white-space: nowrap;
}

table tbody tr:hover { background: #f8fafc; }

table code {
    background: #eff6ff;
    color: var(--primary-dark);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.85em;
    white-space: nowrap;
}

/* ========== Code Blocks ========== */
.code-block {
    position: relative;
    margin: 1.2rem 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    background: var(--code-bg);
}

.code-block pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.2rem 1.5rem;
    overflow-x: auto;
    margin: 0;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.75;
    tab-size: 2;
}

.code-block pre code {
    background: none; color: inherit; padding: 0;
    border-radius: 0; font-size: inherit; font-family: inherit;
}

/* Run Button */
.run-btn {
    display: inline-flex;
    align-items: center; gap: 6px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    letter-spacing: 0.5px;
}

.run-btn:hover {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

.run-btn:active { transform: translateY(0); }

.run-btn.running {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    pointer-events: none;
}

.run-btn.running::after {
    content: '';
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Code Output Area */
.code-output {
    background: #111;
    border-top: 2px solid #333;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.35s ease;
}

.code-output.active { max-height: 400px; padding: 14px 18px; overflow-y: auto; }

.code-output .output-header {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.75rem; color: #94a3b8;
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: 8px;
    display: flex; align-items: center; gap: 6px;
}

.code-output .output-header::before {
    content: '▶'; color: #4ec9b0; font-size: 0.7rem;
}

.code-output .output-line {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem; padding: 3px 0;
    border-bottom: 1px solid #1a1a1a;
    word-break: break-all; white-space: pre-wrap;
}

.code-output .output-line.log    { color: #cdd6f4; }
.code-output .output-line.warn   { color: #f59e0b; }
.code-output .output-line.error  { color: #ef4444; }
.code-output .output-line.result { color: #4ec9b0; }

.code-output .output-line::before {
    content: '>'; margin-right: 10px; color: #555; font-weight: 700;
}

/* ========== Tip Boxes ========== */
.tip-box {
    padding: 1rem 1.2rem;
    border-radius: 8px;
    margin: 1.2rem 0;
    border-left: 4px solid;
    font-size: 0.92rem;
}

.tip-box.info {
    background: #eff6ff;
    border-color: var(--info);
    color: #0c4a6e;
}

.tip-box.warning {
    background: #fffbeb;
    border-color: var(--warning);
    color: #92400e;
}

.tip-box.success {
    background: #f0fdf4;
    border-color: var(--success);
    color: #166534;
}

.tip-box strong { display: block; margin-bottom: 4px; }

.tip-box ul { margin: 6px 0 0 18px; }
.tip-box li { margin-bottom: 4px; }

/* ========== Inline Code ========== */
code {
    background: #eff6ff;
    color: var(--primary-dark);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
}

/* ========== Nav Buttons ========== */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 0.5rem;
}

.nav-btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.nav-btn:hover {
    border-color: var(--primary);
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.nav-btn.disabled {
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ========== Footer ========== */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.88rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ========== Back to Top ========== */
.back-to-top {
    position: fixed;
    bottom: 2rem; right: 2rem;
    width: 44px; height: 44px;
    background: #0f172a;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: var(--transition);
    opacity: 0; visibility: hidden;
    display: flex;
    align-items: center; justify-content: center;
    z-index: 999;
}

.back-to-top.visible { opacity: 1; visibility: visible; }

.back-to-top:hover {
    background: var(--primary);
    color: #0f172a;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.4);
}

/* ========== Checklist ========== */
.checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checklist li {
    padding: 10px 16px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    font-size: 0.92rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.checklist li::before {
    content: '☐';
    font-size: 1.1rem;
    color: var(--primary);
    flex-shrink: 0;
}

.checklist li.done::before { content: '✅'; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .main-container { padding: 1rem; }
    .hero h1 { font-size: 2.2rem; }
    .section { padding: 1.5rem; }
}

@media (max-width: 600px) {
    .navbar { padding: 0 1rem; }
    .navbar .logo { font-size: 1.1rem; }
    .hero { padding: 50px 1rem 40px; }
    .hero h1 { font-size: 1.8rem; }
    .hero p { font-size: 1rem; }
    .section h2 { font-size: 1.4rem; }
    table { font-size: 0.78rem; }
}
