/* =============================================================================
   3K FreeFire Studio — Design System
   Gaming dark theme with fire accents, glassmorphism, micro-animations
   ============================================================================= */

/* ─── Google Font ──────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design Tokens ────────────────────────────────────────────────────────── */
:root {
    /* Color Palette — Gaming Dark / FreeFire */
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #18181f;
    --bg-elevated: #1e1e28;
    --bg-hover: #252530;
    --bg-active: #2d2d3a;

    /* Glass effects */
    --glass-bg: rgba(18, 18, 28, 0.82);
    --glass-border: rgba(255, 120, 30, 0.12);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --glass-blur: blur(20px);

    /* Accent Colors — FreeFire Fire */
    --accent-primary: #ff7814;
    --accent-primary-hover: #ff9a44;
    --accent-secondary: #ff4500;
    --accent-glow: rgba(255, 120, 20, 0.25);
    --accent-glow-strong: rgba(255, 120, 20, 0.5);

    /* Semantic Colors */
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.1);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.1);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.1);
    --info: #60a5fa;
    --info-bg: rgba(96, 165, 250, 0.1);

    /* Text Colors */
    --text-primary: #f0f0f5;
    --text-secondary: #a0a3b8;
    --text-tertiary: #6b6e84;
    --text-muted: #4a4d62;

    /* Borders */
    --border-subtle: rgba(255, 120, 30, 0.06);
    --border-default: rgba(255, 120, 30, 0.15);
    --border-strong: rgba(255, 120, 30, 0.3);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Cascadia Code', monospace;
    --font-display: 'Orbitron', 'Inter', sans-serif;

    /* Sizing */
    --sidebar-width: 300px;
    --panel-width: 320px;
    --header-height: 56px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-default: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-fire: 0 0 30px rgba(255, 69, 0, 0.3);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ─── Utility Classes ──────────────────────────────────────────────────────── */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* ─── Button System ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
    white-space: nowrap;
    user-select: none;
}
.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px var(--accent-glow);
}
.btn-primary:hover {
    background: var(--accent-primary-hover);
    box-shadow: 0 0 20px var(--accent-glow-strong);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

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

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border-color: rgba(248, 113, 113, 0.2);
}
.btn-danger:hover {
    background: rgba(248, 113, 113, 0.2);
}

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon {
    padding: 8px;
    width: 36px;
    height: 36px;
}
.btn-icon-sm {
    padding: 4px;
    width: 28px;
    height: 28px;
}

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

/* ─── Input System ─────────────────────────────────────────────────────────── */
.input, .textarea, .select {
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    outline: none;
    transition: all var(--transition-fast);
    width: 100%;
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder, .textarea::placeholder {
    color: var(--text-tertiary);
}

.textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.select {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6e94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* ─── Range Slider ─────────────────────────────────────────────────────────── */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-glow);
    cursor: pointer;
    transition: transform var(--transition-fast);
}
.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-glow);
    cursor: pointer;
    border: none;
}

/* ─── Toggle Switch ────────────────────────────────────────────────────────── */
.toggle {
    position: relative;
    width: 40px;
    height: 22px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}
.toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all var(--transition-fast);
}
.toggle.active {
    background: var(--accent-primary);
}
.toggle.active::after {
    left: 21px;
    background: white;
}

/* ─── Badge ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
}
.badge-primary {
    background: var(--accent-glow);
    color: var(--accent-primary);
}
.badge-success {
    background: var(--success-bg);
    color: var(--success);
}
.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}
.badge-error {
    background: var(--error-bg);
    color: var(--error);
}
.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* ─── Animations ───────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes glow-pulse {
    0%, 100% { box-shadow: 0 0 8px var(--accent-glow); }
    50% { box-shadow: 0 0 24px var(--accent-glow-strong); }
}

.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-fade-in-up { animation: fadeInUp 0.4s ease-out; }
.animate-slide-in-right { animation: slideInRight 0.3s ease-out; }
.animate-pulse { animation: pulse 2s infinite; }
.animate-spin { animation: spin 1s linear infinite; }

/* Loading shimmer */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, var(--bg-elevated) 50%, var(--bg-tertiary) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ─── Tooltip ──────────────────────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: all var(--transition-fast);
    z-index: 1000;
}
[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Progress Bar ─────────────────────────────────────────────────────────── */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    transition: width var(--transition-slow);
}

/* ─── Toast / Notification ─────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    animation: slideInRight 0.3s ease-out;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.toast-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(74, 222, 128, 0.2); }
.toast-error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(248, 113, 113, 0.2); }
.toast-info { background: var(--info-bg); color: var(--info); border: 1px solid rgba(96, 165, 250, 0.2); }
.toast-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid rgba(251, 191, 36, 0.2); }
