/* ============================================================
   LIVE Commerce Dashboard — Premium Glassmorphism UI
   ============================================================ */

:root {
    --bg-primary: #000000;
    --bg-card: rgba(20, 20, 30, 0.35);
    --bg-card-hover: rgba(30, 30, 45, 0.55);
    --bg-input: rgba(10, 10, 15, 0.6);
    --bg-sidebar: rgba(10, 10, 15, 0.45);
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #38bdf8;
    --accent-purple: #d8b4fe;
    --accent-blue: #7dd3fc;
    --accent-green: #5eead4;
    --accent-orange: #fcd34d;
    --accent-red: #fda4af;
    --accent-pink: #f9a8d4;
    --accent-cyan: #67e8f9;
    --accent-tiktok: #06b6d4;
    --accent-live: #ef4444;
    --gradient-purple: linear-gradient(135deg, #c084fc, #ec4899);
    --gradient-blue: linear-gradient(135deg, #38bdf8, #818cf8);
    --gradient-green: linear-gradient(135deg, #2dd4bf, #0284c7);
    --gradient-orange: linear-gradient(135deg, #fbbf24, #f59e0b);
    --gradient-pink: linear-gradient(135deg, #f472b6, #fb7185);
    --gradient-tiktok: linear-gradient(135deg, #0ea5e9, #a855f7, #ec4899);
    --gradient-live: linear-gradient(135deg, #ef4444, #f97316);
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(14, 165, 233, 0.4);
    --radius-sm: 14px;
    --radius-md: 20px;
    --radius-lg: 24px;
    --transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    --sidebar-width: 250px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Glowing background orbs */
body::before {
    content: '';
    position: fixed;
    top: -10%; left: 10%;
    width: 60vw; height: 60vh;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.2), transparent 60%);
    filter: blur(120px);
    z-index: -1;
    animation: blob1 20s infinite alternate;
    pointer-events: none;
}
body::after {
    content: '';
    position: fixed;
    bottom: -20%; right: 0;
    width: 70vw; height: 70vh;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.2), transparent 60%);
    filter: blur(140px);
    z-index: -1;
    animation: blob2 25s infinite alternate;
    pointer-events: none;
}

@keyframes blob1 {
    0% { transform: translate(0,0) scale(1); }
    50% { transform: translate(10vw,5vh) scale(1.1); }
    100% { transform: translate(-5vw,15vh) scale(0.9); }
}
@keyframes blob2 {
    0% { transform: translate(0,0) scale(1); }
    50% { transform: translate(-10vw,-10vh) scale(1.05); }
    100% { transform: translate(10vw,-5vh) scale(0.95); }
}

/* ═══ Sidebar ═══ */
#sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    backdrop-filter: blur(30px);
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 18px;
    border-bottom: 1px solid var(--border-color);
}
.brand-icon {
    font-size: 26px; width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    background: var(--gradient-live);
    border-radius: var(--radius-md);
}
.sidebar-brand h1 {
    font-size: 17px; font-weight: 800;
    background: var(--gradient-live);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.brand-sub {
    font-size: 10px; color: var(--accent-red);
    font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
}
.nav-links {
    flex: 1; padding: 12px 8px;
    display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    transition: var(--transition);
    position: relative; cursor: pointer;
}
.nav-item:hover { background: rgba(239, 68, 68, 0.08); color: var(--text-primary); }
.nav-item.active { background: rgba(239, 68, 68, 0.1); color: var(--accent-red); }
.nav-item.active::before {
    content: ''; position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 22px;
    background: var(--accent-red);
    border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 17px; width: 22px; text-align: center; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border-color); }
.pipeline-mini {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius-md);
    padding: 10px;
}
.pipeline-mini-label { font-size: 10px; color: var(--accent-red); text-transform: uppercase; font-weight: 600; }
.pipeline-mini-text { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ═══ Main ═══ */
#main-content {
    margin-left: var(--sidebar-width);
    flex: 1; padding: 22px 28px; min-height: 100vh;
}

.top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 0; margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(16px);
    z-index: 90;
}
.update-info { font-size: 11px; color: var(--text-muted); }

/* ═══ Stats ═══ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 22px;
}
.stat-card {
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex; align-items: center; gap: 14px;
    position: relative; overflow: hidden;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card::after {
    content: ''; position: absolute; top: 0; right: 0;
    width: 80px; height: 80px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
    transform: translate(25%,-25%);
}
.gradient-pink { background: var(--gradient-pink); }
.gradient-purple { background: var(--gradient-purple); }
.gradient-blue { background: var(--gradient-blue); }
.gradient-green { background: var(--gradient-green); }
.stat-icon {
    font-size: 28px; width: 46px; height: 46px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-md);
}
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; opacity: 0.8; margin-top: 3px; }

/* ═══ Cards ═══ */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 22px; margin-bottom: 18px;
    transition: var(--transition);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
}
.card-header h3 { font-size: 15px; font-weight: 700; }

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border: none;
    border-radius: var(--radius-md);
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--gradient-tiktok); color: white; box-shadow: 0 4px 14px rgba(14,165,233,0.3); }
.btn-secondary { background: rgba(139,92,246,0.12); color: var(--accent-purple); border: 1px solid rgba(139,92,246,0.2); }
.btn-success { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-sm { padding: 6px 11px; font-size: 11.5px; }
.btn-lg { padding: 14px 28px; font-size: 15px; }
.btn-live {
    background: var(--gradient-live); color: white;
    box-shadow: 0 4px 20px rgba(239,68,68,0.4);
    animation: pulse-live 2s infinite;
}
@keyframes pulse-live {
    0%, 100% { box-shadow: 0 4px 20px rgba(239,68,68,0.4); }
    50% { box-shadow: 0 4px 30px rgba(239,68,68,0.7); }
}

/* ═══ Forms ═══ */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; font-size: 12px; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
textarea, select, input[type="text"] {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit; font-size: 13px;
    transition: var(--transition); outline: none;
}
textarea:focus, select:focus, input:focus {
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.12);
}
select {
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%238585a0' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}
.checkbox-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; cursor: pointer; padding: 4px 0;
}
.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent-red); }

/* ═══ Step Cards ═══ */
.create-flow { display: flex; flex-direction: column; gap: 16px; }
.step-card {
    background: rgba(15, 15, 25, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
}
.step-card.active { border-color: rgba(239, 68, 68, 0.3); }
.step-header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px;
    background: rgba(239, 68, 68, 0.05);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}
.step-number {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: var(--gradient-live);
    border-radius: 50%;
    font-size: 13px; font-weight: 800; color: white;
}
.step-title { font-size: 14px; font-weight: 700; }
.step-body { padding: 18px; }

/* ═══ Product Picker ═══ */
.product-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-height: 350px;
    overflow-y: auto;
}
.product-pick-item {
    background: rgba(20, 20, 35, 0.5);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}
.product-pick-item:hover { border-color: rgba(239,68,68,0.3); transform: translateY(-2px); }
.product-pick-item.selected {
    border-color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
    box-shadow: 0 0 15px rgba(239,68,68,0.2);
}
.product-pick-item.selected::after {
    content: '✅'; position: absolute; top: 4px; right: 4px; font-size: 14px;
}
.product-pick-item { position: relative; }
.pick-img {
    width: 100%; aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 6px;
    background: rgba(20,20,40,0.5);
}
.pick-name {
    font-size: 11px; font-weight: 600;
    color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis;
    white-space: nowrap;
}
.pick-price {
    font-size: 12px; font-weight: 700;
    color: var(--accent-orange);
    margin-top: 2px;
}
.selected-count {
    margin-top: 12px; padding: 10px 16px;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    color: var(--accent-red);
}

/* ═══ Phone Preview ═══ */
.preview-container {
    display: flex; gap: 24px; align-items: flex-start;
}
.preview-phone {
    width: 280px; min-width: 280px;
    background: #111;
    border-radius: 32px;
    padding: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 30px rgba(239,68,68,0.15);
    border: 2px solid rgba(255,255,255,0.08);
}
.phone-notch {
    width: 100px; height: 28px; margin: 0 auto 8px;
    background: #000;
    border-radius: 0 0 16px 16px;
}
.phone-screen {
    width: 100%; aspect-ratio: 9/16;
    background: linear-gradient(180deg, #1a0a2e 0%, #0d1b2a 50%, #1a0a2e 100%);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}
.preview-overlay {
    position: absolute; top: 12px; left: 12px; right: 12px;
    display: flex; justify-content: space-between;
    z-index: 10;
}
.preview-live-badge {
    background: var(--accent-live);
    color: white; padding: 4px 12px;
    border-radius: 20px; font-size: 11px; font-weight: 800;
    animation: pulse-live 2s infinite;
}
.preview-viewers {
    background: rgba(0,0,0,0.5);
    color: white; padding: 4px 10px;
    border-radius: 20px; font-size: 11px;
    backdrop-filter: blur(8px);
}
.preview-avatar-area {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -60%);
    text-align: center;
}
.avatar-placeholder {
    font-size: 80px;
    filter: drop-shadow(0 0 20px rgba(239,68,68,0.3));
    animation: avatar-float 3s ease-in-out infinite;
}
@keyframes avatar-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.avatar-speech-bubble {
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(12px);
    color: white; padding: 10px 14px;
    border-radius: 14px;
    font-size: 11px; line-height: 1.5;
    max-width: 200px; margin-top: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    animation: fadeInUp 0.5s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.preview-product-bar {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    padding: 24px 14px 14px;
    display: flex; align-items: center; gap: 10px;
}
.preview-product-img {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; overflow: hidden;
}
.preview-product-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.preview-product-info { flex: 1; }
.preview-prod-name { font-size: 11px; color: rgba(255,255,255,0.8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-prod-price { font-size: 14px; font-weight: 800; color: var(--accent-orange); }
.preview-cart-btn {
    background: var(--accent-orange); color: #000;
    border: none; padding: 8px 14px;
    border-radius: 20px; font-size: 11px; font-weight: 800;
    cursor: pointer; white-space: nowrap;
    animation: cart-pulse 2s infinite;
}
@keyframes cart-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 12px rgba(252,211,77,0.4); }
}

.preview-scripts { flex: 1; }
.preview-scripts h4 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.script-preview-item {
    background: rgba(15, 15, 25, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px; margin-bottom: 10px;
}
.script-preview-item .script-product { font-size: 12px; color: var(--accent-orange); font-weight: 600; margin-bottom: 6px; }
.script-preview-item .script-text { font-size: 12px; color: var(--text-secondary); line-height: 1.6; white-space: pre-line; }

/* ═══ Session Cards ═══ */
.session-card {
    background: rgba(15, 15, 25, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 16px;
    transition: var(--transition);
}
.session-card:hover { border-color: rgba(239,68,68,0.2); transform: translateX(4px); }
.session-icon {
    width: 50px; height: 50px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.session-icon.draft { background: rgba(100,100,120,0.2); }
.session-icon.ready { background: rgba(16,185,129,0.15); }
.session-icon.live { background: var(--gradient-live); animation: pulse-live 2s infinite; }
.session-icon.ended { background: rgba(100,100,120,0.1); }
.session-info { flex: 1; min-width: 0; }
.session-name { font-size: 15px; font-weight: 700; }
.session-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; display: flex; gap: 16px; }
.session-status {
    padding: 4px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 600;
}
.status-draft { background: rgba(100,100,120,0.15); color: var(--text-muted); }
.status-preparing { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.status-ready { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.status-live { background: rgba(239,68,68,0.2); color: var(--accent-red); animation: pulse-live 2s infinite; }
.status-ended { background: rgba(100,100,120,0.1); color: var(--text-secondary); }
.session-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ═══ Empty State ═══ */
.empty-state {
    text-align: center; padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { margin-bottom: 16px; }

/* ═══ Toast ═══ */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: rgba(10,10,20,0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    color: var(--text-primary);
    font-size: 13px;
    z-index: 9999;
    animation: slideInRight 0.3s ease;
    max-width: 350px;
}
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ═══ Scrollbar ═══ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ═══ Loading Spinner ═══ */
.loading-spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-menu-btn {
    display: none;
}
.sidebar-backdrop {
    display: none;
}

@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -250px;
        top: 0;
        bottom: 0;
        width: 250px;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.25, 1, 0.5, 1);
        display: flex !important;
        background: rgba(10, 10, 15, 0.9);
        backdrop-filter: blur(40px);
        -webkit-backdrop-filter: blur(40px);
    }
    #sidebar.mobile-show {
        left: 0;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(239, 68, 68, 0.15);
    }
    #main-content {
        margin-left: 0;
        padding: 16px 14px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .preview-container {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    .preview-phone {
        width: 100%;
        max-width: 320px;
    }
    .preview-scripts {
        width: 100%;
    }
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: 10px;
        color: var(--text-primary);
        font-size: 20px;
        width: 40px;
        height: 40px;
        cursor: pointer;
        padding: 0;
        line-height: 1;
        transition: var(--transition);
    }
    .mobile-menu-btn:hover {
        background: rgba(239, 68, 68, 0.1);
        color: var(--accent-red);
        border-color: rgba(239, 68, 68, 0.2);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: auto;
    }
    
    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px 0;
    }
    .top-bar > div:first-child {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .top-bar-title {
        font-size: 16px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }
    .update-info {
        display: none; /* Hide update label on narrow mobile to save space */
    }
    .header-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
    }
    .header-actions > div {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* Make tables and list cards responsive */
    .session-card {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px;
    }
    .session-icon {
        align-self: center;
    }
    .session-meta {
        flex-wrap: wrap;
        gap: 8px 16px;
    }
    .session-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
        gap: 8px;
    }
    .session-actions .btn {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .header-actions {
        grid-template-columns: 1fr;
    }
}
