/* ====================================
   KINGDOM SOUND PLATFORM - BASE STYLES
   ==================================== */

:root {
    /* Colors - Streamer (Purple) */
    --color-primary: #7c3aed;
    --color-primary-dark: #5b21b6;
    --color-primary-light: #f3f0ff;
    
    /* Colors - Uploader (Orange) */
    --color-secondary: #ea580c;
    --color-secondary-dark: #c2410c;
    --color-secondary-light: #fff7ed;
    
    /* Neutral Colors */
    --color-dark: #1a1a2e;
    --color-dark-secondary: #16213e;
    --color-light: #ffffff;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    
    /* Status Colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;
    
    /* Spacing Scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    

    --font-primary: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Courier New', monospace;
    
    /* Font Sizes */
    --font-xs: 12px;
    --font-sm: 14px;
    --font-base: 16px;
    --font-lg: 18px;
    --font-xl: 20px;
    --font-2xl: 24px;
    --font-3xl: 32px;
    
    /* Font Weights */
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Z-Index */
    --z-base: 1;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 1000;
}

    /* Loader */
.ksp-loader-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(17, 24, 39, 0.72);
    backdrop-filter: blur(8px);
    z-index: 3000;
}

.ksp-loader-overlay.show {
    display: flex;
}

.ksp-loader-card {
    min-width: 240px;
    padding: 24px 28px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    gap: 16px;
}

.ksp-loader-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 12px;
    background: #111827;
    padding: 6px;
    flex: 0 0 auto;
}

.ksp-loader-spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid rgba(124, 58, 237, 0.2);
    border-top-color: #7c3aed;
    animation: kspSpin 0.8s linear infinite;
    margin-left: auto;
}

.ksp-loader-text {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 2px 0;
}

.ksp-loader-timer {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
}

@keyframes kspSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* ====================================
   RESET & BASE STYLES
   ==================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-primary);
    font-size: var(--font-base);
    line-height: 1.6;
    color: var(--color-gray-700);
    background-color: var(--color-gray-50);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--weight-bold);
    line-height: 1.2;
    color: var(--color-dark);
}

h1 { font-size: var(--font-3xl); }
h2 { font-size: var(--font-2xl); }
h3 { font-size: var(--font-xl); }
h4 { font-size: var(--font-lg); }
h5 { font-size: var(--font-base); }
h6 { font-size: var(--font-sm); }

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--color-primary-dark);
}

/* ====================================
   LAYOUT
   ==================================== */

.dashboard-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.dashboard-main {
    background: var(--color-gray-50);
    overflow-y: auto;
}

/* ====================================
   SIDEBAR
   ==================================== */

.sidebar {
    background: var(--color-dark);
    color: white;
    padding: var(--space-lg);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

/* ====================================
   MOBILE NAVIGATION (hamburger + off-canvas sidebar)
   ==================================== */

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1100;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--color-dark);
    color: #fff;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.mobile-menu-toggle svg {
    width: 22px;
    height: 22px;
}

.sidebar-close-btn {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    margin-bottom: var(--space-lg);
    margin-left: auto;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 16, 32, 0.55);
    z-index: 1090;
}

.sidebar-backdrop.active {
    display: block;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo svg {
    width: 32px;
    height: 32px;
}

.sidebar-logo-text h3 {
    color: white;
    font-size: var(--font-sm);
    font-weight: var(--weight-bold);
    margin-bottom: 4px;
}

.sidebar-logo-text p {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-xl);
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-bold);
    font-size: var(--font-lg);
    position: relative;
}

.sidebar-user-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--color-success);
    border: 2px solid var(--color-dark);
    border-radius: 50%;
}

.sidebar-user-info h4 {
    color: white;
    font-size: var(--font-sm);
    margin-bottom: 2px;
}

.sidebar-user-info p {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-user-badge {
    display: inline-block;
    padding: 3px 8px;
    background: var(--color-primary);
    border-radius: 12px;
    font-size: 10px;
    font-weight: var(--weight-semibold);
}

.sidebar-user-badge.gold {
    background: linear-gradient(135deg, #d4af37, #aa8c2c);
}

.sidebar-nav {
    margin-bottom: var(--space-2xl);
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all 0.3s ease;
    position: relative;
    font-size: var(--font-sm);
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.sidebar-nav-item.active {
    background: var(--color-primary);
    color: white;
}

.sidebar-nav-item.active.uploader {
    background: var(--color-secondary);
}

.sidebar-nav-item svg {
    width: 20px;
    height: 20px;
}

.sidebar-nav-badge {
    margin-left: auto;
    background: rgba(255, 0, 0, 0.7);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--weight-bold);
}

.sidebar-upgrade {
    padding: var(--space-lg);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(91, 33, 182, 0.1));
    border-radius: var(--radius-lg);
    border: 1px solid rgba(124, 58, 237, 0.3);
    text-align: center;
    margin-bottom: var(--space-lg);
}

.sidebar-upgrade.uploader {
    background: linear-gradient(135deg, rgba(234, 88, 12, 0.15), rgba(194, 65, 12, 0.1));
    border: 1px solid rgba(234, 88, 12, 0.3);
}

.sidebar-upgrade h4 {
    color: white;
    font-size: var(--font-lg);
    margin-bottom: var(--space-sm);
}

.sidebar-upgrade p {
    font-size: var(--font-xs);
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: var(--space-md);
}

.upgrade-btn {
    width: 100%;
    padding: var(--space-md);
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: var(--weight-bold);
    cursor: pointer;
    transition: all 0.3s ease;
}

.upgrade-btn.uploader {
    background: var(--color-secondary);
}

.upgrade-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

/* ====================================
   MAIN CONTENT
   ==================================== */

.dashboard-header {
    background: white;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--color-gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

.header-content h1 {
    font-size: var(--font-2xl);
    margin-bottom: 4px;
}

.header-content p {
    color: var(--color-gray-500);
    font-size: var(--font-sm);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.notification-icon {
    position: relative;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-gray-100);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.notification-icon:hover {
    background: var(--color-gray-200);
}

.notification-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--color-error);
    color: white;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-bold);
}

.user-profile {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: var(--weight-bold);
    cursor: pointer;
}

/* ====================================
   CARDS & SECTIONS
   ==================================== */

.dashboard-content {
    padding: var(--space-lg);
    max-width: 1600px;
}

.card {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
}

.card-header h3 {
    font-size: var(--font-lg);
    margin: 0;
}

.card-header-action {
    font-size: var(--font-sm);
    color: var(--color-primary);
    cursor: pointer;
    transition: color 0.3s ease;
}

.card-header-action:hover {
    color: var(--color-primary-dark);
}

.card-header-action.uploader {
    color: var(--color-secondary);
}

.card-header-action.uploader:hover {
    color: var(--color-secondary-dark);
}

/* ====================================
   GRID LAYOUTS
   ==================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.stat-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-lg);
    border: 1px solid var(--color-gray-200);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: var(--space-md);
}

.stat-card .stat-label {
    font-size: var(--font-sm);
    color: var(--color-gray-500);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: var(--font-2xl);
    font-weight: var(--weight-bold);
    color: var(--color-dark);
    margin-bottom: 8px;
}

.stat-card .stat-unit {
    font-size: var(--font-sm);
    color: var(--color-gray-500);
}

.content-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* ====================================
   BUTTONS
   ==================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-sm);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--color-secondary);
    color: white;
}

.btn-secondary:hover {
    background: var(--color-secondary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
}

.btn-outline:hover {
    background: var(--color-primary-light);
}

.btn-small {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-xs);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ====================================
   PROGRESS BAR
   ==================================== */

.progress-container {
    margin: var(--space-lg) 0;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--color-gray-200);
    border-radius: 100px;
    overflow: hidden;
    display: flex;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-dark));
    border-radius: 100px;
    transition: width 0.3s ease;
}

.progress-fill.secondary {
    background: linear-gradient(90deg, var(--color-secondary), var(--color-secondary-dark));
}

/* ====================================
   TABLES
   ==================================== */

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: var(--color-gray-50);
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-weight: var(--weight-semibold);
    font-size: var(--font-sm);
    color: var(--color-gray-600);
    border-bottom: 1px solid var(--color-gray-200);
}

.data-table td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-gray-200);
}

.data-table tr:hover {
    background: var(--color-gray-50);
}

.table-rank {
    font-weight: var(--weight-bold);
    color: var(--color-dark);
    width: 40px;
}

.table-song {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.table-song-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--color-gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.table-song-info h5 {
    margin: 0 0 4px 0;
    font-size: var(--font-sm);
}

.table-song-info p {
    margin: 0;
    font-size: var(--font-xs);
    color: var(--color-gray-500);
}

/* ====================================
   BADGES & LABELS
   ==================================== */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: var(--weight-semibold);
}

.badge-primary {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge-secondary {
    background: var(--color-secondary-light);
    color: var(--color-secondary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
}

.badge-gold {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(170, 140, 44, 0.1));
    color: #d4af37;
}

/* ====================================
   FORMS
   ==================================== */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-dark);
    font-size: var(--font-sm);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--color-gray-300);
    border-radius: var(--radius-md);
    font-size: var(--font-base);
    transition: all 0.3s ease;
    font-family: var(--font-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ====================================
   MODALS
   ==================================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-xl);
}

.modal-header {
    margin-bottom: var(--space-lg);
}

.modal-header h2 {
    margin: 0;
}

.modal-close {
    float: right;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-gray-500);
}

/* ====================================
   RESPONSIVE
   ==================================== */

@media (max-width: 900px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }

    .mobile-menu-toggle {
        display: flex;
    }

    .sidebar-close-btn {
        display: flex;
    }

    .sidebar {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        max-width: 84vw;
        z-index: 1095;
        overflow-y: auto;
        padding-bottom: var(--space-xl);
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .dashboard-header {
        flex-direction: column;
        gap: var(--space-md);
        align-items: flex-start;
        padding-left: 68px !important;
    }

    .md-split {
        grid-template-columns: 1fr !important;
    }

    .md-card-grid {
        grid-template-columns: 1fr !important;
    }

    #liveSessionGrid {
        grid-template-columns: 1fr !important;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* ====================================
   UTILITIES
   ==================================== */

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--color-gray-500);
}

.text-small {
    font-size: var(--font-sm);
}

.mt {
    margin-top: var(--space-lg);
}

.mb {
    margin-bottom: var(--space-lg);
}

.gap {
    gap: var(--space-lg);
}
