/* ==========================================
   SocialHub — Custom Design System
   Premium dark theme for social media management
   ========================================== */

/* CSS Custom Properties */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d26;
    --bg-card: #1e2230;
    --bg-card-hover: #252a3a;
    --bg-input: rgba(255, 255, 255, 0.04);
    
    --accent-violet: #6C5CE7;
    --accent-violet-light: #a29bfe;
    --accent-blue: #0984E3;
    --accent-green: #00b894;
    --accent-red: #e17055;
    --accent-orange: #fdcb6e;
    
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-muted: rgba(255, 255, 255, 0.35);
    --text-accent: #a29bfe;
    
    --border-color: rgba(255, 255, 255, 0.06);
    --border-active: rgba(108, 92, 231, 0.5);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.35);
    --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.2);
    
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --nav-height: 72px;
    --header-height: 60px;
}

/* Global */
* { -webkit-tap-highlight-color: transparent; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ==========================================
   BOTTOM NAVIGATION (Mobile)
   ========================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    padding-bottom: var(--safe-bottom);
    background: linear-gradient(to top, rgba(15, 17, 23, 0.98) 60%, rgba(15, 17, 23, 0.9));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
    border-radius: 12px;
}

.bottom-nav-item.active {
    color: var(--accent-violet);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--accent-violet);
    border-radius: 0 0 4px 4px;
}

.bottom-nav-item:active {
    transform: scale(0.9);
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
}

.bottom-nav .badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    background: var(--accent-red);
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ==========================================
   HEADER
   ========================================== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    padding: 0 16px;
    background: rgba(15, 17, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 900;
}

.app-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
}

.app-header .logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-violet), var(--accent-blue));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   MAIN CONTENT
   ========================================== */
.main-content {
    padding-top: calc(var(--header-height) + 8px);
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    min-height: 100vh;
}

/* ==========================================
   CARDS
   ========================================== */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    margin: 8px 0 4px;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-change {
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px;
    border-radius: 6px;
}

.stat-change.up { color: var(--accent-green); background: rgba(0, 184, 148, 0.1); }
.stat-change.down { color: var(--accent-red); background: rgba(225, 112, 85, 0.1); }

/* ==========================================
   SIDEBAR / DRAWER
   ========================================== */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: var(--bg-secondary);
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.drawer-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.drawer-nav-item:hover,
.drawer-nav-item.active {
    background: rgba(108, 92, 231, 0.08);
    color: var(--text-primary);
    border-left-color: var(--accent-violet);
}

.drawer-nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ==========================================
   FAB (Floating Action Button)
   ========================================== */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--accent-violet), #8B5CF6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.4);
    z-index: 500;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.fab:active {
    transform: scale(0.9);
}

.fab svg {
    width: 24px;
    height: 24px;
}

/* ==========================================
   POST COMPOSER MODAL
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    margin: 12px auto;
}

/* ==========================================
   PLATFORM BADGES
   ========================================== */
.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.platform-badge.facebook { background: rgba(24, 119, 242, 0.15); color: #1877F2; }
.platform-badge.instagram { background: rgba(228, 64, 95, 0.15); color: #E4405F; }
.platform-badge.twitter { background: rgba(255, 255, 255, 0.1); color: #fff; }
.platform-badge.linkedin { background: rgba(10, 102, 194, 0.15); color: #0A66C2; }
.platform-badge.tiktok { background: rgba(255, 255, 255, 0.1); color: #fff; }
.platform-badge.youtube { background: rgba(255, 0, 0, 0.15); color: #FF0000; }

/* ==========================================
   STATUS BADGES
   ========================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.draft { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
.status-badge.scheduled { background: rgba(9, 132, 227, 0.15); color: var(--accent-blue); }
.status-badge.published { background: rgba(0, 184, 148, 0.15); color: var(--accent-green); }
.status-badge.failed { background: rgba(225, 112, 85, 0.15); color: var(--accent-red); }
.status-badge.active { background: rgba(0, 184, 148, 0.15); color: var(--accent-green); }
.status-badge.paused { background: rgba(253, 203, 110, 0.15); color: var(--accent-orange); }

/* ==========================================
   CALENDAR
   ========================================== */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 4px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.calendar-day:hover { background: rgba(255, 255, 255, 0.05); }
.calendar-day.today { background: rgba(108, 92, 231, 0.15); color: var(--accent-violet); font-weight: 700; }
.calendar-day.has-events::after {
    content: '';
    width: 5px;
    height: 5px;
    background: var(--accent-violet);
    border-radius: 50%;
    margin-top: 2px;
}

/* ==========================================
   STREAMS (Horizontal Columns)
   ========================================== */
.streams-container {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 0 16px 16px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.stream-column {
    flex: 0 0 300px;
    max-width: 85vw;
    scroll-snap-align: start;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.stream-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stream-body {
    max-height: calc(100vh - 240px);
    overflow-y: auto;
}

.stream-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.stream-item:hover { background: rgba(255,255,255,0.02); }

/* ==========================================
   INBOX
   ========================================== */
.inbox-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
    cursor: pointer;
}

.inbox-item:hover { background: rgba(255, 255, 255, 0.02); }
.inbox-item.unread { background: rgba(108, 92, 231, 0.04); }
.inbox-item.unread .inbox-sender { font-weight: 700; }

.inbox-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-violet), var(--accent-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 14px;
}

/* ==========================================
   CHARTS
   ========================================== */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.chart-container canvas {
    max-height: 220px;
}

/* ==========================================
   TABS
   ========================================== */
.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex: 1;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    border: none;
    background: none;
}

.tab.active {
    background: var(--accent-violet);
    color: white;
    font-weight: 600;
}

/* ==========================================
   SKELETON LOADER
   ========================================== */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, rgba(255,255,255,0.05) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.animate-fade-in { animation: fadeIn 0.3s ease-out; }
.animate-fade-in-up { animation: fadeInUp 0.4s ease-out; }

/* Staggered children animation */
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (min-width: 768px) {
    .bottom-nav { display: none; }
    .main-content {
        padding-bottom: 24px;
        margin-left: 260px;
    }
    .drawer {
        transform: translateX(0) !important;
        position: fixed;
        border-right: 1px solid var(--border-color);
    }
    .drawer-overlay { display: none !important; }
    .fab { bottom: 24px; }
    .app-header { left: 260px; }
}

@media (min-width: 1024px) {
    .stream-column {
        flex: 0 0 340px;
    }
}

/* ==========================================
   UTILITY CLASSES
   ========================================== */
.text-gradient {
    background: linear-gradient(135deg, #6C5CE7, #a29bfe, #74b9ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bg-glass {
    background: rgba(30, 34, 48, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Toggle Switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle.active { background: var(--accent-violet); }

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle.active::after { transform: translateX(20px); }

/* Account selector checkboxes */
.account-check {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.account-check.checked {
    background: var(--accent-violet);
    border-color: var(--accent-violet);
}
