/* ============================================
   Solar4Good SEO Dashboard - CSS
   ============================================ */

:root {
    --bg-primary: #020617;
    --bg-secondary: #0f172a;
    --bg-card: #0f172a;
    --bg-hover: #1e293b;
    --border: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --radius: 12px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --accent: #ea580c;
    --accent-hover: #c2410c;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --purple: #7c3aed;
}
[data-theme="light"] .sidebar { box-shadow: 2px 0 8px rgba(0,0,0,0.06); }
[data-theme="light"] .top-bar { background: rgba(255,255,255,0.9); }
[data-theme="light"] .stat-card { box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
[data-theme="light"] .card { box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
[data-theme="light"] .date-filter-dropdown { box-shadow: 0 12px 32px rgba(0,0,0,0.12); }
[data-theme="light"] .modal-overlay { background: rgba(0,0,0,0.3); }
[data-theme="light"] .nav-item:hover { background: #f1f5f9; }
[data-theme="light"] .nav-item.active { background: rgba(234, 88, 12, 0.08); }
[data-theme="light"] table tr:hover { background: #f8fafc; }
[data-theme="light"] .logo-icon { background: linear-gradient(135deg, #ea580c, #f97316); }
[data-theme="light"] .filter-btn { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
[data-theme="light"] .filter-btn.active { background: rgba(234, 88, 12, 0.1); color: #ea580c; border-color: #ea580c; }
[data-theme="light"] .date-active-bar { background: rgba(234, 88, 12, 0.04); border-color: rgba(234, 88, 12, 0.1); }
[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator { filter: none; }

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-secondary); min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.content { flex: 1; overflow-y: auto; padding: 32px; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width); background: var(--bg-secondary);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); flex-shrink: 0; overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text, .sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-info, .sidebar.collapsed .logout-btn span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .user-avatar { margin: 0; }

.sidebar-logo {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
}
.logo-icon {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #fb923c);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 900; flex-shrink: 0;
}
.logo-title { color: var(--text-primary); font-weight: 800; font-size: 15px; }
.logo-sub { color: var(--text-dim); font-size: 11px; }

.sidebar-nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 16px;
    margin-bottom: 3px; border-radius: 10px; color: var(--text-muted);
    font-size: 14px; font-weight: 500; transition: all 0.15s; cursor: pointer;
    border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(30, 41, 59, 0.5); color: var(--text-secondary); }
.nav-item.active {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.12), rgba(234, 88, 12, 0.06));
    color: var(--accent); font-weight: 600;
}
.nav-item i { font-size: 18px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-user {
    padding: 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-name { color: var(--text-primary); font-size: 13px; font-weight: 600; }
.user-role { color: var(--text-dim); font-size: 11px; text-transform: capitalize; }

.logout-btn { margin: 0 12px 12px; border: 1px solid var(--border) !important; border-radius: 8px !important; }
.logout-btn:hover { color: var(--danger) !important; border-color: rgba(239, 68, 68, 0.3) !important; }

/* Top Bar */
.top-bar {
    padding: 16px 32px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(15, 23, 42, 0.95); backdrop-filter: blur(12px);
    position: relative; z-index: 100;
}
.top-bar-left { display: flex; align-items: center; gap: 16px; }
.top-bar-right { display: flex; align-items: center; gap: 16px; }
.page-title { color: var(--text-primary); font-size: 22px; font-weight: 800; }
.page-date { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.menu-toggle {
    display: none; background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; padding: 4px;
}
.alert-bell {
    position: relative; padding: 8px; border-radius: 10px;
    background: var(--bg-hover); cursor: pointer; display: flex;
}
.alert-bell i { font-size: 18px; color: var(--text-muted); }
.alert-badge {
    position: absolute; top: 2px; right: 2px; width: 16px; height: 16px;
    border-radius: 50%; background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; display: flex; align-items: center;
    justify-content: center;
}

/* Flash Messages */
.flash-message {
    margin: 16px 32px 0; padding: 14px 20px; border-radius: var(--radius);
    display: flex; justify-content: space-between; align-items: center;
    font-size: 14px; font-weight: 500;
}
.flash-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); color: var(--success); }
.flash-error { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }
.flash-info { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); color: var(--info); }
.flash-close { background: none; border: none; color: inherit; font-size: 18px; cursor: pointer; }

/* Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* Stat Card */
.stat-card {
    background: linear-gradient(135deg, var(--bg-hover), var(--bg-secondary));
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px 28px; position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; top: -20px; right: -20px;
    width: 100px; height: 100px; border-radius: 50%; opacity: 0.08;
}
.stat-card[data-color="blue"]::after { background: var(--info); }
.stat-card[data-color="green"]::after { background: var(--success); }
.stat-card[data-color="orange"]::after { background: var(--accent); }
.stat-card[data-color="purple"]::after { background: var(--purple); }
.stat-card[data-color="red"]::after { background: var(--danger); }

.stat-label { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { color: var(--text-primary); font-size: 32px; font-weight: 800; margin-top: 8px; line-height: 1; }
.stat-sub { color: var(--text-dim); font-size: 13px; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.stat-sub .trend-up { color: var(--success); }
.stat-sub .trend-down { color: var(--danger); }

/* Card */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
}
.card-header {
    padding: 18px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.card-title { color: var(--text-primary); font-size: 16px; font-weight: 700; }
.card-body { padding: 24px; }
.card-body.no-pad { padding: 0; }
.card + .card { margin-top: 24px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 12px 16px; color: var(--text-muted);
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
td {
    padding: 14px 16px; border-bottom: 1px solid rgba(30, 41, 59, 0.3);
    color: var(--text-secondary); font-size: 14px; vertical-align: middle;
}
tr:hover td { background: rgba(30, 41, 59, 0.25); }
.cell-name { font-weight: 600; }
.cell-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.cell-amount { color: var(--success); font-weight: 700; }
.cell-muted { color: var(--text-dim); font-size: 12px; }
.empty-state { padding: 48px; text-align: center; color: var(--text-dim); }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px;
    border: none; border-radius: 10px; font-size: 14px; font-weight: 600;
    font-family: var(--font); cursor: pointer; transition: all 0.15s;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3); }
.btn-secondary { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-muted); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 8px; }
.btn-danger { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }
.btn-success { background: rgba(16, 185, 129, 0.1); border: 1px solid rgba(16, 185, 129, 0.3); color: var(--success); }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-btn {
    padding: 6px 14px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-hover); color: var(--text-muted); font-size: 12px;
    font-family: var(--font); cursor: pointer; transition: all 0.15s;
    text-transform: capitalize;
}
.filter-btn:hover, .filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; color: var(--text-muted); font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.form-input, .form-select {
    width: 100%; padding: 12px 16px; background: var(--bg-hover); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary); font-size: 14px;
    font-family: var(--font); transition: border-color 0.2s; outline: none;
}
.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-dim); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-inline { display: flex; gap: 12px; align-items: end; }
.form-inline .form-group { margin-bottom: 0; flex: 1; }

/* Bar Chart (CSS) */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding: 0 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-value { font-size: 10px; color: var(--text-muted); font-weight: 600; }
.bar-fill {
    width: 100%; max-width: 48px; border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--accent), rgba(249, 115, 22, 0.6));
    transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); min-height: 4px;
}
.bar-fill.green { background: linear-gradient(180deg, var(--success), rgba(16, 185, 129, 0.6)); }
.bar-label { font-size: 10px; color: var(--text-dim); }

/* Alert Items */
.alert-item {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    background: rgba(30, 41, 59, 0.25); border-radius: 10px;
    border-left: 3px solid var(--info); margin-bottom: 10px;
}
.alert-item.warning { border-left-color: var(--warning); }
.alert-item.critical { border-left-color: var(--danger); }
.alert-item .alert-title { color: var(--text-primary); font-size: 14px; font-weight: 600; }
.alert-item .alert-msg { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.alert-item .alert-time { color: var(--text-dim); font-size: 11px; white-space: nowrap; margin-left: auto; }

/* Integration Cards */
.integration-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.integration-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px; transition: all 0.2s;
}
.integration-card:hover { border-color: rgba(249, 115, 22, 0.3); }
.integration-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.integration-icon { font-size: 28px; }
.integration-name { color: var(--text-primary); font-weight: 700; font-size: 16px; }
.integration-synced { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.status-dot {
    width: 10px; height: 10px; border-radius: 50%;
}
.status-dot.active { background: var(--success); box-shadow: 0 0 8px rgba(16, 185, 129, 0.5); }
.status-dot.inactive { background: var(--text-dim); }

/* Agent Performance */
.agent-card { padding: 16px 20px; background: rgba(30, 41, 59, 0.25); border-radius: 12px; margin-bottom: 12px; }
.agent-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.agent-name { color: var(--text-primary); font-weight: 600; }
.agent-revenue { color: var(--success); font-weight: 700; }
.agent-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }
.progress-bar { margin-top: 8px; height: 4px; background: var(--bg-hover); border-radius: 2px; }
.progress-fill { height: 100%; background: var(--success); border-radius: 2px; transition: width 0.5s; }

/* Role Permissions */
.role-card {
    background: rgba(30, 41, 59, 0.25); border-radius: 12px; padding: 20px;
    border-top: 3px solid var(--info);
}
.role-card.sales { border-top-color: var(--success); }
.role-card.dev { border-top-color: var(--purple); }
.role-card h4 { color: var(--text-primary); font-weight: 700; margin-bottom: 12px; }
.role-item {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
    color: var(--text-muted); font-size: 13px;
}
.role-item i { font-size: 14px; }

/* Pagination */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 24px; }
.pagination a, .pagination span {
    padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
    transition: all 0.15s;
}
.pagination a { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active { background: var(--accent); color: #fff; }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* Login Page */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #020617 0%, #0f172a 40%, #1e1b4b 100%);
}
.login-card {
    width: 420px; background: var(--bg-secondary); border-radius: 24px;
    padding: 48px; border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.login-header { text-align: center; margin-bottom: 40px; }
.login-header h1 { color: var(--text-primary); font-size: 24px; font-weight: 800; margin-top: 16px; }
.login-header p { color: var(--text-dim); font-size: 14px; margin-top: 8px; }
.login-error {
    background: #fef2f2; border: 1px solid #fecaca; color: #dc2626;
    padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-size: 13px;
}
.login-btn {
    width: 100%; padding: 14px; background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border: none; border-radius: 12px; color: #fff; font-size: 15px; font-weight: 700;
    font-family: var(--font); cursor: pointer; transition: transform 0.15s;
}
.login-btn:hover { transform: translateY(-1px); }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    z-index: 1000; display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 32px; width: 500px; max-width: 90%;
}
.modal-title { color: var(--text-primary); font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Global Date Filter */
.theme-toggle {
    display: flex; align-items: center; justify-content: center; width: 38px; height: 38px;
    background: var(--bg-hover); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text-muted); cursor: pointer; transition: all 0.15s; font-size: 16px;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
[data-theme="light"] .theme-toggle .icon-sun { display: inline-block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }
.date-filter-wrap { position: relative; z-index: 999; }
.date-filter-toggle {
    display: flex; align-items: center; gap: 8px; padding: 8px 16px;
    background: var(--bg-hover); border: 1px solid var(--border); border-radius: 10px;
    color: var(--text-secondary); font-size: 13px; font-weight: 600;
    font-family: var(--font); cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.date-filter-toggle:hover { border-color: var(--accent); color: var(--accent); }
.date-filter-dropdown {
    display: none; position: absolute; top: calc(100% + 8px); right: 0; z-index: 9999;
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0,0,0,0.6); width: 280px; overflow: hidden;
}
.date-filter-dropdown.show { display: block; }
.date-presets { padding: 8px; }
.date-preset {
    display: block; padding: 9px 14px; border-radius: 8px; font-size: 13px;
    color: var(--text-muted); font-weight: 500; transition: all 0.12s; cursor: pointer;
}
.date-preset:hover { background: var(--bg-hover); color: var(--text-secondary); }
.date-preset.active { background: rgba(249, 115, 22, 0.12); color: var(--accent); font-weight: 600; }
.date-custom-divider { height: 1px; background: var(--border); margin: 0 12px; }
.date-custom-form { padding: 14px; overflow: hidden; }
.date-custom-label { color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.date-custom-sub { display: block; color: var(--text-dim); font-size: 11px; margin-bottom: 4px; }
.date-custom-row { display: flex; gap: 8px; }
.date-custom-row > div { flex: 1; min-width: 0; }
.date-custom-row input[type="date"] { width: 100%; padding: 8px 6px; font-size: 12px; }
.date-active-bar {
    padding: 10px 32px; background: rgba(249, 115, 22, 0.06); border-bottom: 1px solid rgba(249, 115, 22, 0.15);
    display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary);
}
.date-active-bar strong { color: var(--accent); }
.date-clear-btn {
    margin-left: auto; color: var(--text-dim); font-size: 12px; padding: 4px 10px;
    border-radius: 6px; transition: all 0.15s;
}
.date-clear-btn:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* Responsive */
@media (max-width: 1024px) {
    .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .date-filter-toggle span { display: none; }
    .date-filter-toggle { padding: 8px 12px; }
}
@media (max-width: 768px) {
    .sidebar { position: fixed; z-index: 100; transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .menu-toggle { display: block; }
    .content { padding: 20px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 24px; }
    .form-row { grid-template-columns: 1fr; }
    .date-active-bar { padding: 8px 16px; font-size: 12px; flex-wrap: wrap; }
}
