/* ==============================================
   WebTools - Design System
   Cyberpunk Terminal Aesthetic
   ============================================== */

:root {
    --bg: #07080c;
    --surface: #0e1018;
    --surface-2: #151821;
    --surface-3: #1a1e2a;
    --border: #1e2233;
    --border-glow: #2a3a5c;
    --text: #c8cdd8;
    --text-muted: #555c72;
    --text-bright: #eef0f6;
    --cyan: #22d3ee;
    --cyan-dim: rgba(34, 211, 238, 0.08);
    --cyan-glow: rgba(34, 211, 238, 0.25);
    --green: #4ade80;
    --green-dim: rgba(74, 222, 128, 0.08);
    --amber: #fbbf24;
    --amber-dim: rgba(251, 191, 36, 0.08);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.08);
    --pink: #f472b6;
    --radius: 10px;
    --radius-lg: 14px;
    --sidebar-width: 240px;
    --header-height: 56px;
    --font-mono: 'JetBrains Mono', monospace;
    --font-body: 'Noto Sans JP', sans-serif;
    --transition: 0.2s ease;
}

/* --- Theme: Midnight --- */
[data-theme="midnight"] {
    --bg: #0a0e1a;
    --surface: #101424;
    --surface-2: #171c30;
    --surface-3: #1e243c;
    --border: #242b48;
    --border-glow: #3b4578;
    --cyan: #818cf8;
    --cyan-dim: rgba(129, 140, 248, 0.08);
    --cyan-glow: rgba(129, 140, 248, 0.25);
    --green: #a78bfa;
    --green-dim: rgba(167, 139, 250, 0.08);
}

/* --- Theme: Forest --- */
[data-theme="forest"] {
    --bg: #0a120c;
    --surface: #0e1a12;
    --surface-2: #14241a;
    --surface-3: #1a2e22;
    --border: #1e3828;
    --border-glow: #2a5c3a;
    --cyan: #34d399;
    --cyan-dim: rgba(52, 211, 153, 0.08);
    --cyan-glow: rgba(52, 211, 153, 0.25);
    --green: #a3e635;
    --green-dim: rgba(163, 230, 53, 0.08);
}

/* --- Theme: Sunset --- */
[data-theme="sunset"] {
    --bg: #120a08;
    --surface: #1a0e0a;
    --surface-2: #241412;
    --surface-3: #2e1a18;
    --border: #3d221e;
    --border-glow: #5c332a;
    --cyan: #fb923c;
    --cyan-dim: rgba(251, 146, 60, 0.08);
    --cyan-glow: rgba(251, 146, 60, 0.25);
    --green: #f472b6;
    --green-dim: rgba(244, 114, 182, 0.08);
}

/* --- Theme: Ocean --- */
[data-theme="ocean"] {
    --bg: #070d12;
    --surface: #0c1520;
    --surface-2: #121d2c;
    --surface-3: #182636;
    --border: #1e3044;
    --border-glow: #2a4a6c;
    --cyan: #38bdf8;
    --cyan-dim: rgba(56, 189, 248, 0.08);
    --cyan-glow: rgba(56, 189, 248, 0.25);
    --green: #22d3ee;
    --green-dim: rgba(34, 211, 238, 0.08);
}

/* --- Theme: Monochrome --- */
[data-theme="monochrome"] {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1e1e1e;
    --surface-3: #282828;
    --border: #333;
    --border-glow: #444;
    --cyan: #a1a1aa;
    --cyan-dim: rgba(161, 161, 170, 0.08);
    --cyan-glow: rgba(161, 161, 170, 0.25);
    --green: #e4e4e7;
    --green-dim: rgba(228, 228, 231, 0.08);
}

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

/* --- Custom Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scanline */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.02) 2px, rgba(0,0,0,0.02) 4px);
    pointer-events: none;
    z-index: 9999;
}

/* --- Layout --- */
.layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon { font-size: 1.3rem; filter: drop-shadow(0 0 8px var(--cyan-glow)); }

.logo-text {
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1rem;
    color: var(--cyan);
    letter-spacing: -0.5px;
    text-shadow: 0 0 20px var(--cyan-glow);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

/* --- Nav Group Accordion --- */
.nav-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 10px;
    border: none;
    background: none;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition);
    margin-bottom: 2px;
    margin-top: 8px;
}

.nav-group-toggle:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-group-toggle.open {
    color: var(--cyan);
}

.nav-group-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.nav-group-toggle.open .nav-group-arrow {
    transform: rotate(90deg);
}

.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.nav-group-items.open {
    max-height: 500px;
}

.nav-group-items .nav-item {
    padding-left: 20px;
    font-size: 0.8rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.nav-item.active {
    background: var(--cyan-dim);
    color: var(--cyan);
    border: 1px solid rgba(34, 211, 238, 0.15);
}

.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-ads { padding: 12px; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.nav-admin { color: var(--amber); }
.nav-admin:hover { background: var(--amber-dim); }

/* --- Main Content --- */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header --- */
.header {
    height: var(--header-height);
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 50;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-muted);
    border-radius: 1px;
    transition: all 0.2s;
}

.page-title {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-bright);
    flex: 1;
}

.header-actions { display: flex; gap: 8px; }

.header-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-decoration: none;
    transition: all var(--transition);
}

.header-btn:hover { border-color: var(--cyan); color: var(--cyan); }

/* --- Content --- */
.content {
    flex: 1;
    padding: 24px;
    max-width: 960px;
    width: 100%;
}

/* --- Footer --- */
.footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.copyright {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- Ad Slots --- */
.ad-slot {
    padding: 8px;
    text-align: center;
}

.ad-slot:empty { display: none; }

/* --- Shared UI Components --- */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.panel-title {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.btn {
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--surface-2);
    color: var(--text-muted);
}

.btn:hover { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-dim); }

.btn-primary {
    background: var(--cyan-dim);
    border-color: rgba(34, 211, 238, 0.3);
    color: var(--cyan);
}

.btn-primary:hover { background: rgba(34, 211, 238, 0.15); box-shadow: 0 0 20px rgba(34, 211, 238, 0.15); }

.btn-danger { color: var(--red); border-color: rgba(248, 113, 113, 0.3); }
.btn-danger:hover { background: var(--red-dim); }

.input, .textarea, .select {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition);
}

.input:focus, .textarea:focus, .select:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px var(--cyan-dim);
}

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

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.2); }
.alert-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.2); }
.alert-warning { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(251, 191, 36, 0.2); }

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--cyan);
    color: var(--bg);
    padding: 10px 24px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 0 24px var(--cyan-glow);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Overlay (mobile sidebar backdrop) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    }

    .sidebar-close { display: block; }
    .hamburger { display: flex; }

    .main {
        margin-left: 0;
    }

    .header {
        padding: 0 12px;
        gap: 10px;
    }

    .page-title {
        font-size: 0.85rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .header-actions {
        flex-shrink: 0;
    }

    .header-btn {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .content {
        padding: 12px;
        max-width: 100%;
    }

    .panel {
        padding: 16px;
        border-radius: var(--radius);
    }

    .panel-title {
        font-size: 0.65rem;
    }

    .btn {
        padding: 10px 14px;
        font-size: 0.75rem;
        width: 100%;
        text-align: center;
    }

    .input, .textarea, .select {
        font-size: 16px; /* prevent iOS zoom on focus */
    }

    .form-group .btn {
        width: auto;
    }

    .footer {
        padding: 16px 12px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .content {
        padding: 8px;
    }

    .panel {
        padding: 12px;
        border-radius: 8px;
    }

    .header-btn span.label {
        display: none;
    }
}
