/* Root Variables for Color System */
:root {
    --bg-primary: #070a13;
    --bg-secondary: #0d1222;
    --bg-card: rgba(18, 25, 47, 0.65);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(6, 182, 212, 0.4);
    
    /* Brand Colors */
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.15);
    --secondary: #06b6d4;
    --accent: #8b5cf6;
    
    /* Text Colors */
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    /* Status Colors */
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --danger: #ef4444;
    
    /* Gradients */
    --blue-grad: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    --cyan-grad: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    --purple-grad: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    --pink-grad: linear-gradient(135deg, #db2777 0%, #ec4899 100%);
    --x-grad: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    --threads-grad: linear-gradient(135deg, #000000 0%, #262626 100%);
}

/* Reset and Core Settings */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-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);
}

/* Premium Layout Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 260px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 24px;
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 1.5px;
    color: var(--text-main);
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
    color: var(--text-main);
    background: var(--primary-glow);
    border-color: rgba(59, 130, 246, 0.25);
    font-weight: 600;
}

.nav-item i {
    font-size: 16px;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
}

.pulse-green {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

.status-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.db-version {
    font-size: 10px;
    color: var(--text-dim);
}

/* Main Content Wrapper */
.main-content {
    margin-left: 260px;
    flex-grow: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: calc(100% - 260px);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Toggle & Header Layout Adjustments */
.header-left-flex {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-toggle-sidebar {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 18px;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-toggle-sidebar:hover {
    border-color: var(--border-hover);
    color: var(--secondary);
    background: rgba(255, 255, 255, 0.04);
}

/* Collapsed Sidebar State Rules */
.app-container.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.app-container.sidebar-collapsed .main-content {
    margin-left: 0;
    width: 100%;
}

/* Header Area */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
}

.header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, var(--text-main), var(--text-muted));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}

.time-badge {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

/* Glassmorphism Card Style */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 30px -15px rgba(0, 0, 0, 0.5);
}

/* Metrics Dashboard Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.card-icon-wrapper {
    width: 54px;
    height: 54px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.blue-grad { background: var(--blue-grad); }
.twitter-grad { background: var(--x-grad); border: 1px solid rgba(255, 255, 255, 0.1); }
.threads-grad { background: var(--threads-grad); border: 1px solid rgba(255, 255, 255, 0.1); }
.purple-grad { background: var(--purple-grad); }

.metric-info {
    display: flex;
    flex-direction: column;
}

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

.metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
    margin: 2px 0;
}

.metric-sub {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 500;
}

/* Filters Panel Styling */
.filters-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header h3 i {
    color: var(--secondary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.btn-text:hover {
    color: var(--secondary);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1100px) {
    .filters-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 650px) {
    .filters-grid {
        grid-template-columns: 1fr;
    }
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-dim);
    font-size: 14px;
}

#search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 13px;
    transition: all 0.3s;
}

#search-input:focus {
    border-color: var(--secondary);
    outline: none;
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.15);
}

select {
    padding: 10px 14px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position-x: calc(100% - 10px);
    background-position-y: 50%;
}

select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.15);
}

.filters-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    height: 18px;
    width: 18px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s;
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--secondary);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--secondary);
    border-color: var(--secondary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid var(--bg-primary);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Charts Grid */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 900px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

.chart-container {
    display: flex;
    flex-direction: column;
    min-height: 350px;
}

.chart-body {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Data Table Styling */
.data-table-card {
    padding: 0;
    overflow: hidden;
}

.table-header-flex {
    padding: 20px 24px 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.table-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-search {
    width: 280px;
}

.table-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
    margin-top: 4px;
}

.btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-secondary {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    border-color: var(--secondary);
    background-color: rgba(255, 255, 255, 0.02);
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.data-table th {
    padding: 8px 16px;
    background-color: rgba(255, 255, 255, 0.015);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
    font-size: 12.5px;
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.015);
}

/* Badges for platforms & categories */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    display: inline-block;
}

.x-badge {
    background-color: rgba(31, 41, 55, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
}

.threads-badge {
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
}

.match-badge {
    background-color: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 30px;
    padding: 3px 10px;
}

.category-badge {
    background-color: rgba(6, 182, 212, 0.1);
    color: #22d3ee;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.warning-badge {
    background-color: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Post text container styling */
.post-text-cell {
    max-width: 500px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.5;
}

.user-cell {
    font-weight: 600;
    color: var(--secondary);
}

.engagement-cell {
    display: flex;
    gap: 12px;
    color: var(--text-muted);
}

.eng-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.eng-item i {
    font-size: 11px;
    color: var(--text-dim);
}

.btn-link {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.btn-link:hover {
    color: var(--text-main);
    border-color: var(--secondary);
    background-color: var(--secondary);
}

/* Pagination Styling */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.005);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover:not(:disabled) {
    border-color: var(--secondary);
    color: var(--text-main);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-numbers-container {
    display: flex;
    gap: 4px;
}

.page-num {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.2s;
}

.page-num:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.page-num.active {
    background-color: var(--primary-glow);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--primary);
}

/* Empty State Styling */
.empty-row-cell {
    text-align: center !important;
    padding: 48px !important;
    color: var(--text-dim) !important;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-icon {
    font-size: 36px;
    color: var(--text-dim);
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 20px;
    }
    
    .logo-area {
        margin-bottom: 20px;
    }
    
    .nav-menu {
        flex-direction: row;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }
    
    .sidebar-footer {
        display: none;
    }
}
