:root {
    /* Color Palette - Premium Dark Theme */
    --bg-main: #0a0c10;
    --bg-sidebar: #11141b;
    --accent-primary: #3b82f6; /* Modern Blue */
    --accent-glow: rgba(59, 130, 246, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Platform Colors */
    --color-meta: #0668E1;
    --color-google: #4285F4;
    --color-tiktok: #EE1D52;
    --color-instagram: #E1306C;
    
    /* Animation Speeds */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', 'Noto Kufi Arabic', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 3rem;
    color: var(--accent-primary);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.nav-item.active {
    border-right: 3px solid var(--accent-primary);
}

.nav-item i {
    width: 20px;
}

.user-selector-wrapper {
    margin-top: auto;
    padding-top: 2rem;
    border-top: 1px solid var(--glass-border);
}

.premium-select {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 8px;
    margin-top: 8px;
    outline: none;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 2.5rem 3.5rem;
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.2rem;
    font-weight: 700;
}

/* Glass Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.glass-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

/* Stats Logic */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 2rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 1.8rem;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);
    text-align: right;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, var(--accent-glow) 0%, transparent 70%);
    opacity: 0.1;
    pointer-events: none;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-trend.positive { color: var(--success); }
.stat-trend.negative { color: var(--danger); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary { background: var(--accent-primary); color: white; }
.btn-primary:hover { background: #2563eb; transform: scale(1.02); }

.btn-sparkle { 
    background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899); 
    color: white; 
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4);
}

/* Form Styling */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

input, textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px;
    outline: none;
    transition: var(--transition);
}

input:focus, textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Table Styling */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

th {
    padding: 12px 16px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--glass-border);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
}

/* Helpers */
.hidden { display: none !important; }

/* Micro-animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-content {
    animation: fadeIn 0.4s ease-out forwards;
}

/* Filter Controls */
.header-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filters {
    display: flex;
    gap: 1.5rem;
    padding: 0.8rem 1.5rem;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.mini {
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
    margin-top: 0 !important;
}

.premium-input {
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 8px;
    outline: none;
}

/* Demo Mode Styling */
.sidebar-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 1.5rem 0;
}

.btn-demo-sidebar {
    width: 100%;
    justify-content: center;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 12px;
}

.btn-demo-sidebar:hover {
    background: rgba(16, 185, 129, 0.2);
    transform: translateY(-2px);
}

.error-placeholder {
    padding: 3rem;
    text-align: center;
}

.loader.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.badge.active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
}

/* AI Labels */
.ai-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.ai-status.excellent { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.ai-status.warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.ai-status.danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }

/* UI Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}
.status-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.status-paused {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Platform Icons Wrapper */
.platform-icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-left: 8px;
}

/* Platform Filter Bar */
.platform-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.platform-btn {
    padding: 8px 16px;
    border-radius: 100px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.platform-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-analyze-row {
    padding: 4px 8px;
    font-size: 0.75rem;
    background: rgba(168, 85, 247, 0.1);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.btn-analyze-row:hover {
    background: #a855f7;
    color: white;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.1) 0%, transparent 50%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 3rem !important;
    animation: fadeIn 0.6s ease-out;
}

.error-text {
    font-size: 0.85rem;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Automation Rules UI */
.automation-grid {
    margin-top: 1rem;
}

.premium-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.premium-select:focus {
    border-color: var(--accent-primary);
}

.rules-list-section table {
    width: 100%;
    border-collapse: collapse;
}

.rules-list-section th {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 12px;
    border-bottom: 2px solid var(--border);
}

.rules-list-section td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.btn-delete-rule {
    color: var(--danger);
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-delete-rule:hover {
    opacity: 1;
}
