/**
 * YouTube Premium Manager — Main Stylesheet
 * Dark Mode OLED Theme
 */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

/* =============================================
   Design Tokens
   ============================================= */
:root {
    /* Background layers (dark → darker) */
    --bg-primary: #0A0A0F;
    --bg-secondary: #111118;
    --bg-card: #16161F;
    --bg-card-hover: #1C1C28;
    --bg-elevated: #1F1F2C;

    /* Brand colors — YouTube-inspired red + trust blue */
    --accent: #E53935;
    --accent-hover: #EF5350;
    --accent-muted: rgba(229, 57, 53, 0.12);
    --accent-text: #FF6B6B;

    --blue: #3B82F6;
    --blue-hover: #60A5FA;
    --blue-muted: rgba(59, 130, 246, 0.12);

    /* Semantic colors */
    --success: #22C55E;
    --success-muted: rgba(34, 197, 94, 0.12);
    --warning: #F59E0B;
    --warning-muted: rgba(245, 158, 11, 0.12);
    --danger: #EF4444;
    --danger-muted: rgba(239, 68, 68, 0.12);

    /* Text */
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --border-focus: var(--blue);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(229, 57, 53, 0.15);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Typography */
    --font-display: 'Fira Code', monospace;
    --font-body: 'Fira Sans', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 100px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

a {
    color: var(--blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--blue-hover);
}

/* =============================================
   Login Page
   ============================================= */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}

/* Animated background gradient */
.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(229, 57, 53, 0.08) 0%, transparent 50%),
                radial-gradient(ellipse at 70% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-5%, -3%) rotate(3deg); }
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl) var(--space-xl);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(20px);
    animation: cardEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardEnter {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-logo {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: var(--accent-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-md);
    border: 1px solid rgba(229, 57, 53, 0.2);
}

.login-logo-icon svg {
    width: 32px;
    height: 32px;
    color: var(--accent);
}

.login-logo h1 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
}

/* Form */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-input-wrap {
    position: relative;
}

.form-input-wrap svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.form-input {
    width: 100%;
    padding: 13px 16px 13px 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    transition: all var(--transition-base);
    outline: none;
}

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

.form-input:focus {
    border-color: var(--border-focus);
    background: var(--bg-elevated);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-input:focus + svg,
.form-input:focus ~ svg {
    color: var(--blue);
}

/* Password toggle */
.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-muted);
    transition: color var(--transition-fast);
}

.password-toggle:hover {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 13px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
    text-decoration: none;
    line-height: 1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    width: 100%;
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.3);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px rgba(229, 57, 53, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Login error */
.login-error {
    display: none;
    padding: 12px 16px;
    background: var(--danger-muted);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    color: var(--danger);
    font-size: 0.875rem;
    margin-bottom: var(--space-lg);
    animation: shake 0.4s ease;
}

.login-error.visible {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* Language switcher */
.lang-switch {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 10;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lang-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* =============================================
   Utilities
   ============================================= */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 480px) {
    .login-card {
        padding: var(--space-xl) var(--space-lg);
        border-radius: var(--radius-lg);
    }

    .login-logo-icon {
        width: 56px;
        height: 56px;
    }
}

/* =============================================
   Reduced Motion
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =============================================
   Toast Notification (persistent)
   ============================================= */
.app-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    max-width: 420px;
    min-width: 280px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

.app-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.app-toast-error {
    background: #1a0a0a;
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.app-toast-success {
    background: #0a1a0a;
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #86efac;
}

.app-toast-info {
    background: #0a0a1a;
    border: 1px solid rgba(59, 130, 246, 0.35);
    color: #93c5fd;
}

.toast-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.5;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: opacity 0.2s, background 0.2s;
}

.toast-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 480px) {
    .app-toast {
        right: 12px;
        left: 12px;
        max-width: none;
    }
}

/* =============================================
   Site Footer — Branding
   ============================================= */
.site-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding: 14px 24px;
    background: var(--bg-primary);
}

.site-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
}

.site-footer-brand {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.5;
    letter-spacing: 0.02em;
}

.site-footer-author {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.site-footer-sep {
    opacity: 0.4;
}

.site-footer-zalo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.site-footer-zalo:hover {
    opacity: 1;
}

/* Login page footer variant */
.login-footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.login-footer-name {
    font-weight: 500;
    opacity: 0.7;
}

.login-footer-sep {
    opacity: 0.3;
}

.login-footer-zalo {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent);
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.login-footer-zalo:hover {
    opacity: 1;
}

/* =============================================
   Scroll to Top Button (shared across all pages)
   ============================================= */
.scroll-top-btn {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 500;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(229, 57, 53, 0.35);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
}

.scroll-top-btn.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.scroll-top-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 6px 24px rgba(229, 57, 53, 0.45);
}

.scroll-top-btn:active {
    transform: translateY(0) scale(0.95);
}

.scroll-top-btn svg {
    width: 22px;
    height: 22px;
}
