/* ============================================================
   common.css - Shared Design System
   YouTube Channel API Dashboard
   ============================================================ */

/* ==========================================================
   1. CSS Variables (Design Tokens)
   ========================================================== */
:root {
    /* Primary Colors */
    --color-primary: #3ea6ff;
    --color-primary-hover: #2196f3;
    --color-primary-glow: rgba(62, 166, 255, 0.3);
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;

    /* Backgrounds */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-input: rgba(0, 0, 0, 0.4);

    /* Text */
    --text-primary: #f0f0f0;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Effects */
    --border-color: rgba(255, 255, 255, 0.06);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
    --gradient-primary: linear-gradient(135deg, #3ea6ff 0%, #a855f7 100%);
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(0, 0, 0, 0.02);
    --bg-glass: rgba(255, 255, 255, 0.9);
    --bg-input: rgba(0, 0, 0, 0.05);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: rgba(0, 0, 0, 0.06);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    font-size: var(--font-size-base, 14px);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Selection */
::selection {
    background: var(--color-primary);
    color: #fff;
}

/* ==========================================================
   3. Custom Scrollbar
   ========================================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

/* ==========================================================
   4. Enhanced Typography
   ========================================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
}

h1 { font-size: 1.8em; }
h2 { font-size: 1.5em; }
h3 { font-size: 1.2em; }
h4 { font-size: 1em; }

p {
    color: var(--text-secondary);
    line-height: 1.6;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.9em;
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--color-primary);
}

/* ==========================================================
   5. Navbar
   ========================================================== */
.navbar {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
}

.navbar-brand:hover {
    text-decoration: none;
}

.navbar-logo {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9em;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-card);
    text-decoration: none;
}

.nav-link.active {
    color: #fff;
    background: var(--color-primary);
}

.nav-link.settings-link {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    animation: settingsGlow 2s ease-in-out infinite;
}

.nav-link.settings-link:hover {
    animation: none;
    box-shadow: 0 0 20px var(--color-primary-glow);
}

/* Refresh Indicator */
.refresh-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.8em;
    color: var(--text-muted);
}

.refresh-indicator.active {
    color: var(--color-success);
}

.refresh-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.2s;
}

.refresh-indicator.active .refresh-dot {
    background: var(--color-success);
    animation: pulse 1s ease infinite;
}

/* ==========================================================
   6. Layout
   ========================================================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 6px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.95em;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* ==========================================================
   7. Cards
   ========================================================== */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .card:hover {
    border-color: rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.card-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
}

.card-title {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==========================================================
   8. Buttons
   ========================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s, filter 0.2s;
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--color-primary-glow);
}

.btn-primary:disabled:hover {
    transform: none;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-success:hover {
    filter: brightness(1.1);
}

.btn-lg {
    padding: 16px 36px;
    font-size: 1.05em;
    border-radius: 12px;
}

/* ==========================================================
   9. Form Controls
   ========================================================== */
input[type="text"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="password"],
select {
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

input::placeholder {
    color: var(--text-muted);
}

/* Focus-visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

input:focus-visible,
select:focus-visible {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* Range Input */
input[type="range"] {
    accent-color: var(--color-primary);
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.toggle-slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
    background: #fff;
}

/* ==========================================================
   10. Settings Panel
   ========================================================== */
.settings-panel {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
}

.section-title {
    font-size: 1em;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-weight: 500;
    font-size: 0.9em;
}

.setting-desc {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 2px;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-value {
    min-width: 45px;
    text-align: right;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.85em;
    color: var(--color-primary);
}

/* ==========================================================
   11. Spinner
   ========================================================== */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================
   11. Toast Notification
   ========================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-success);
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 0.9em;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ==========================================================
   12. Footer
   ========================================================== */
footer {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 0.85em;
    border-top: 1px solid var(--border-color);
}

footer a {
    color: var(--color-primary);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ==========================================================
   13. Animation System
   ========================================================== */

/* Interactive element transitions */
a, button, input, select, .btn, .card, .nav-link {
    transition: color 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes settingsGlow {
    0%, 100% {
        box-shadow: 0 0 5px var(--color-primary-glow), 0 0 10px var(--color-primary-glow);
    }
    50% {
        box-shadow: 0 0 15px var(--color-primary-glow), 0 0 25px var(--color-primary-glow), 0 0 35px var(--color-primary-glow);
    }
}

.fade-in {
    animation: fadeIn 0.4s ease;
}

/* ==========================================================
   14. Utility Classes
   ========================================================== */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

.hidden { display: none !important; }
.visible { display: block; }

.glass {
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* ==========================================================
   15. Responsive
   ========================================================== */
@media (max-width: 768px) {
    .navbar-content {
        padding: 0 16px;
    }

    .container {
        padding: 20px 16px;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .navbar-nav {
        gap: 4px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 0.85em;
    }
}
