/* ===== CSS VARIABLES & DESIGN TOKENS ===== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a1f35;
    --bg-card-hover: #1f2544;
    --bg-glass: rgba(26, 31, 53, 0.8);
    --bg-input: #0f1324;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-active: rgba(99, 102, 241, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --facebook: #1877F2;
    --instagram: #E4405F;
    --twitter: #1DA1F2;
    --tiktok: #00f2ea;
    --linkedin: #0A66C2;
    --youtube: #FF0000;
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --transition: all 0.2s ease;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

@media (min-width: 768px) {
    html {
        font-size: 15px;
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== APP LAYOUT ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    font-size: 1.5rem;
    color: var(--accent-primary);
}

.brand-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.brand-accent {
    color: var(--accent-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    display: block;
    padding: 0 12px;
    margin-bottom: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-link-item:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.08);
}

.nav-link-item.active {
    color: #fff;
    background: var(--accent-gradient);
    box-shadow: var(--shadow-glow);
}

.nav-link-item i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    transition: var(--transition);
}

/* ===== TOP BAR ===== */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
}

.top-bar-title h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box i {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    width: 200px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

.badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid var(--bg-card);
}

/* ===== CONTENT AREA ===== */
.content-area {
    padding: 24px;
}

/* ===== METRIC CARDS ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition);
}

.metric-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.metric-card:hover::before {
    opacity: 1;
}

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.metric-icon.blue { background: var(--info-bg); color: var(--info); }
.metric-icon.green { background: var(--success-bg); color: var(--success); }
.metric-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.metric-icon.orange { background: var(--warning-bg); color: var(--warning); }
.metric-icon.pink { background: rgba(236, 72, 153, 0.1); color: #ec4899; }
.metric-icon.cyan { background: rgba(6, 182, 212, 0.1); color: #06b6d4; }

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
}

.metric-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
}

.metric-change.positive {
    color: var(--success);
    background: var(--success-bg);
}

.metric-change.negative {
    color: var(--danger);
    background: var(--danger-bg);
}

.metric-change.neutral {
    color: var(--text-muted);
    background: rgba(100, 116, 139, 0.1);
}

/* ===== GLASS CARD ===== */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== CHARTS GRID ===== */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.charts-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.chart-full {
    grid-column: 1 / -1;
}

/* ===== TABLE ===== */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead th {
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    position: sticky;
    top: 0;
    background: var(--bg-card);
}

.data-table tbody td {
    padding: 12px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table tbody tr:hover td {
    background: rgba(99, 102, 241, 0.04);
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== BADGES & TAGS ===== */
.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.platform-badge.facebook { background: rgba(24, 119, 242, 0.15); color: var(--facebook); }
.platform-badge.instagram { background: rgba(228, 64, 95, 0.15); color: var(--instagram); }
.platform-badge.twitter { background: rgba(29, 161, 242, 0.15); color: var(--twitter); }
.platform-badge.tiktok { background: rgba(0, 242, 234, 0.15); color: var(--tiktok); }
.platform-badge.linkedin { background: rgba(10, 102, 194, 0.15); color: var(--linkedin); }
.platform-badge.youtube { background: rgba(255, 0, 0, 0.15); color: var(--youtube); }
.platform-badge.manual { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

.sentiment-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.sentiment-badge.positive { background: var(--success-bg); color: var(--success); }
.sentiment-badge.neutral { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.sentiment-badge.negative { background: var(--danger-bg); color: var(--danger); }

.post-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.connected { background: var(--success-bg); color: var(--success); }
.status-badge.disconnected { background: var(--danger-bg); color: var(--danger); }

/* ===== BUTTONS ===== */
.btn-primary-custom {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary-custom:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
    color: white;
}

.btn-secondary-custom {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-secondary-custom:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-select, .filter-input {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 14px;
    font-size: 0.85rem;
    transition: var(--transition);
    outline: none;
}

.filter-select:focus, .filter-input:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.filter-select option {
    background: var(--bg-secondary);
}

/* ===== SENTIMENT GAUGE ===== */
.sentiment-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.gauge-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--success) 0%, var(--accent-primary) 50%, var(--danger) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gauge-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== PROGRESS BAR ===== */
.sentiment-bar {
    display: flex;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-input);
}

.sentiment-bar-segment {
    height: 100%;
    transition: width 0.5s ease;
}

.sentiment-bar-segment.positive { background: var(--success); }
.sentiment-bar-segment.neutral { background: var(--text-muted); }
.sentiment-bar-segment.negative { background: var(--danger); }

/* ===== ACTIVITY FEED ===== */
.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-dot.facebook { background: var(--facebook); }
.activity-dot.instagram { background: var(--instagram); }
.activity-dot.twitter { background: var(--twitter); }

.activity-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.activity-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== HEATMAP ===== */
.heatmap-grid {
    display: grid;
    grid-template-columns: auto repeat(24, 1fr);
    gap: 2px;
    font-size: 0.65rem;
}

.heatmap-cell {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 3px;
    transition: var(--transition);
}

.heatmap-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* ===== FORM CONTROLS ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label-custom {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control-custom {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.85rem;
    transition: var(--transition);
    outline: none;
}

.form-control-custom:focus {
    border-color: var(--border-active);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-control-custom::placeholder {
    color: var(--text-muted);
}

/* ===== FILE UPLOAD ===== */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.04);
}

.upload-zone i {
    font-size: 2.5rem;
    color: var(--accent-primary);
    margin-bottom: 12px;
}

.upload-zone p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.upload-zone .upload-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 8px;
}

/* ===== PAGINATION ===== */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-buttons {
    display: flex;
    gap: 4px;
}

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.page-btn:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

.page-btn.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes countUp {
    from { opacity: 0; }
    to { opacity: 1; }
}

.animate-in {
    animation: fadeInUp 0.4s ease forwards;
}

.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.1s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.2s; }
.delay-5 { animation-delay: 0.25s; }
.delay-6 { animation-delay: 0.3s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .charts-grid-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .search-box {
        display: none;
    }
    .content-area {
        padding: 16px;
    }
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== APEX CHARTS OVERRIDES ===== */
.apexcharts-tooltip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg) !important;
}

.apexcharts-tooltip-title {
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

.apexcharts-tooltip-text {
    color: var(--text-secondary) !important;
}

.apexcharts-legend-text {
    color: var(--text-secondary) !important;
}

.apexcharts-xaxis-label, .apexcharts-yaxis-label {
    fill: var(--text-muted) !important;
}

.apexcharts-gridline {
    stroke: var(--border-color) !important;
}

/* ===== UTILITY ===== */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-muted-custom { color: var(--text-muted) !important; }
.text-accent { color: var(--accent-primary) !important; }

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.gap-16 { gap: 16px; }
.mb-24 { margin-bottom: 24px; }