/* ============================================================
   style.css - News Twins Dashboard V2 (كامل)
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #0B1121;
    --sidebar-active: #1E293B;
    --sidebar-hover: #1E293B;
    --primary: #2563EB;
    --primary-light: #60A5FA;
    --text-light: #E2E8F0;
    --text-muted: #94A3B8;
    --card-bg: #FFFFFF;
    --body-bg: #F1F5F9;
    --border-radius: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --transition: 0.25s ease;
    --text-dark: #0F172A;
    --border-color: #E2E8F0;
}

[data-theme="dark"] {
    --body-bg: #0A0E1A;
    --card-bg: #1A1F33;
    --text-dark: #F1F5F9;
    --border-color: #2D3A5A;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --sidebar-bg: #050A14;
    --sidebar-active: #121C2E;
    --sidebar-hover: #121C2E;
}

[data-theme="dark"] .report-rate-card,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .comparison-card,
[data-theme="dark"] .widget-card {
    background: #1A1F33;
    border-color: #2D3A5A;
}

[data-theme="dark"] .page-header .header-date {
    background: #1A1F33;
    color: #E2E8F0;
}

[data-theme="dark"] .header-search input {
    background: #1A1F33;
    color: #fff;
    border-color: #2D3A5A;
}

[data-theme="dark"] .table {
    color: #E2E8F0;
}

[data-theme="dark"] .table-striped>tbody>tr:nth-of-type(odd)>* {
    --bs-table-accent-bg: #1A1F33;
}

[data-theme="dark"] .form-control {
    background: #1A1F33;
    color: #fff;
    border-color: #2D3A5A;
}

[data-theme="dark"] .form-control:focus {
    background: #1A1F33;
    color: #fff;
}

[data-theme="dark"] .settings-form label {
    color: #E2E8F0;
}

[data-theme="dark"] .icon-btn {
    background: #1A1F33;
    color: #E2E8F0;
}

[data-theme="dark"] .user-profile {
    background: #1A1F33;
}

[data-theme="dark"] .user-profile span {
    color: #E2E8F0;
}

[data-theme="dark"] .filter-btn {
    background: #1A1F33;
    border-color: #2D3A5A;
    color: #94A3B8;
}

[data-theme="dark"] .filter-btn:hover,
[data-theme="dark"] .filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

[data-theme="dark"] .stat-card .stat-value {
    color: #F1F5F9;
}

[data-theme="dark"] .stat-card .stat-label {
    color: #94A3B8;
}

[data-theme="dark"] .stat-card .stat-sub .sub-highlight {
    color: #F1F5F9;
}

[data-theme="dark"] .comp-item .comp-value {
    color: #F1F5F9;
}

[data-theme="dark"] .widget-card h6 {
    color: #F1F5F9;
}

[data-theme="dark"] .widget-card ul li {
    color: #E2E8F0;
    border-color: #2D3A5A;
}

[data-theme="dark"] .report-rate-card .report-label {
    color: #F1F5F9;
}

[data-theme="dark"] .report-rate-card .report-main span {
    color: #F1F5F9;
}

[data-theme="dark"] .chart-card .chart-header h5 {
    color: #F1F5F9;
}

[data-theme="dark"] .welcome-section h1 {
    color: #F1F5F9;
}

[data-theme="dark"] .page-title {
    color: #F1F5F9;
}

[data-theme="dark"] .settings-form label {
    color: #E2E8F0;
}

/* ============================================================
   ✅ Dark Mode - ApexCharts Tooltip Fix
   ============================================================ */
html[data-theme="dark"] .apexcharts-tooltip {
    background: #1E293B !important;
    color: #E2E8F0 !important;
    border: 1px solid #334155 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

html[data-theme="dark"] .apexcharts-tooltip-title {
    background: #0F172A !important;
    color: #E2E8F0 !important;
    border-bottom: 1px solid #334155 !important;
    padding: 8px 12px !important;
    font-weight: 600 !important;
}

html[data-theme="dark"] .apexcharts-tooltip-text-y-label {
    color: #94A3B8 !important;
}

html[data-theme="dark"] .apexcharts-tooltip-text-y-value {
    color: #FFFFFF !important;
}

html[data-theme="dark"] .apexcharts-tooltip-text-goals-value {
    color: #E2E8F0 !important;
}

html[data-theme="dark"] .apexcharts-tooltip-series-group {
    background: transparent !important;
}

html[data-theme="dark"] .apexcharts-tooltip-marker {
    border-radius: 50% !important;
}

html[data-theme="dark"] .apexcharts-xaxistooltip {
    background: #1E293B !important;
    color: #E2E8F0 !important;
    border: 1px solid #334155 !important;
}

html[data-theme="dark"] .apexcharts-yaxistooltip {
    background: #1E293B !important;
    color: #E2E8F0 !important;
    border: 1px solid #334155 !important;
}

html[data-theme="dark"] .apexcharts-xaxistooltip-text {
    color: #E2E8F0 !important;
}

html[data-theme="dark"] .apexcharts-yaxistooltip-text {
    color: #E2E8F0 !important;
}

html[data-theme="dark"] .apexcharts-gridline {
    stroke: #334155 !important;
}

html[data-theme="dark"] .apexcharts-grid-borders line {
    stroke: #334155 !important;
}

html[data-theme="dark"] .apexcharts-menu {
    background: #1E293B !important;
    border: 1px solid #334155 !important;
}

html[data-theme="dark"] .apexcharts-menu-item {
    color: #E2E8F0 !important;
}

html[data-theme="dark"] .apexcharts-menu-item:hover {
    background: #334155 !important;
}

html[data-theme="dark"] .apexcharts-legend-text {
    color: #E2E8F0 !important;
}

/* ============================================================
   BODY
   ============================================================ */
body {
    font-family: 'Segoe UI', Tahoma, system-ui, sans-serif;
    background: var(--body-bg);
    color: var(--text-dark);
    overflow-x: hidden;
}

a {
    text-decoration: none;
}

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--text-light);
    padding: 0 0 2rem 0;
    overflow-y: auto;
    z-index: 1050;
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 10px;
}

.sidebar-brand {
    padding: 1.5rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.sidebar-brand .logo-placeholder {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
}

.sidebar-brand .logo-placeholder .logo-icon {
    width: 42px;
    height: 42px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .logo-placeholder .logo-text small {
    display: block;
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 1.25rem 0.75rem 1rem 0.75rem;
    list-style: none;
    margin: 0;
}

.sidebar-nav .nav-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 0.75rem 1rem 0.5rem 1rem;
    opacity: 0.5;
}

.sidebar-nav .nav-item {
    margin-bottom: 2px;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 1rem;
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}

.sidebar-nav .nav-link i {
    width: 22px;
    font-size: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-nav .nav-link .badge-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    margin-right: auto;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    padding: 1.5rem 2rem 1rem 2rem;
    transition: margin var(--transition);
}

/* ===== HEADER ===== */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sidebar-toggle {
    display: none;
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    padding: 0.5rem 0.9rem;
    font-size: 1.3rem;
    color: var(--text-dark);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.header-search {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: 40px;
    padding: 0.3rem 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.header-search i {
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.header-search input {
    border: none;
    background: transparent;
    padding: 0.4rem 0;
    outline: none;
    width: 180px;
    color: var(--text-dark);
}

.header-search input::placeholder {
    color: var(--text-muted);
}

.icon-btn {
    background: var(--card-bg);
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    color: var(--text-dark);
    box-shadow: var(--shadow);
    position: relative;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--primary);
    color: #fff;
}

.icon-btn .badge-dot {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 8px;
    height: 8px;
    background: #EF4444;
    border-radius: 50%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.2rem 0.8rem 0.2rem 0.5rem;
    border-radius: 40px;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.user-profile img {
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.user-profile span {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-dark);
}

.header-date {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--card-bg);
    padding: 0.3rem 1.2rem;
    border-radius: 40px;
    box-shadow: var(--shadow);
    white-space: nowrap;
}

/* ===== NOTIFICATIONS ===== */
.notif-dropdown {
    display: none;
    position: absolute;
    top: 70px;
    left: 120px;
    width: 320px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    padding: 1rem;
    z-index: 1060;
    border: 1px solid var(--border-color);
}

.notif-dropdown.open {
    display: block;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.notif-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.notif-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

/* ===== PAGES (SPA) ===== */
.page-section {
    display: none;
    animation: fadeUp 0.3s ease;
}

.page-section.active {
    display: block;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== WELCOME ===== */
.welcome-section {
    margin-bottom: 1.5rem;
}

.welcome-section h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-dark);
}

.welcome-section h1 small {
    display: block;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* ===== REPORT RATE ===== */
.report-rate-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.2rem 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-color);
}

.report-rate-card .report-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.report-rate-card .report-label i {
    color: var(--primary);
}

.report-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2rem;
}

.report-main {
    font-size: 1.1rem;
}

.report-main strong {
    color: var(--text-muted);
    font-weight: 600;
    margin-left: 0.5rem;
}

.report-main span {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 1.4rem;
}

.report-change {
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.3rem 1rem;
    border-radius: 40px;
}

.report-change.up {
    color: #16A34A;
    background: #DCFCE7;
}

.report-change.down {
    color: #DC2626;
    background: #FEE2E2;
}

/* ===== STATS CARDS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-card .stat-label i {
    color: var(--primary);
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.stat-card .stat-change {
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1rem 0.6rem;
    border-radius: 40px;
    margin-top: 0.3rem;
}

.stat-card .stat-change.up {
    color: #16A34A;
    background: #DCFCE7;
}

.stat-card .stat-change.down {
    color: #DC2626;
    background: #FEE2E2;
}

.stat-card .stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.stat-card .stat-sub .sub-highlight {
    font-weight: 600;
    color: var(--text-dark);
}

.today-earnings .stat-sub i {
    color: var(--primary);
}

/* ===== CHART FILTERS ===== */
.chart-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 0.3rem 1.2rem;
    border-radius: 40px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ===== CHART ===== */
.chart-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem 1.75rem 1rem 1.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 1.75rem;
}

.chart-card .chart-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.chart-card .chart-header h5 {
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    color: var(--text-dark);
}

.chart-card .chart-header .chart-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--body-bg);
    padding: 0.2rem 0.8rem;
    border-radius: 40px;
}

#performanceChart {
    width: 100%;
    height: 300px;
}

/* ===== COMPARISON ===== */
.comparison-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 1.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.comp-left {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 1.5rem;
}

.comp-item .comp-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.comp-item .comp-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-dark);
}

.comp-item .comp-value .currency {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
}

.comp-growth {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 1.2rem;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.95rem;
}

.comp-growth.up {
    color: #16A34A;
    background: #DCFCE7;
}

.comp-growth.down {
    color: #DC2626;
    background: #FEE2E2;
}

/* ===== WIDGETS ===== */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.widget-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.widget-card h6 {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-card h6 i {
    color: var(--primary);
}

.widget-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.widget-card ul li {
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ===== EARNINGS, ARTICLES, VISITORS, DOMAINS, TRANSACTIONS ===== */
.earnings-summary,
.articles-stats,
.visitors-stats,
.trans-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.table {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    color: var(--text-dark);
}

.table th {
    background: var(--body-bg);
    color: var(--text-muted);
    font-weight: 600;
    border-color: var(--border-color);
}

.table td {
    border-color: var(--border-color);
}

/* ===== SETTINGS & PROFILE ===== */
.settings-form {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    max-width: 600px;
}

.settings-form label {
    font-weight: 600;
    color: var(--text-dark);
}

.settings-form .form-control {
    background: var(--body-bg);
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    border-radius: 12px;
    padding: 0.6rem 1rem;
}

.settings-form .form-control:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
    border-color: var(--primary);
}

/* ===== FOOTER ===== */
.dashboard-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== OVERLAY ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1040;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .sidebar-toggle {
        display: inline-flex;
    }
    .main-content {
        margin-right: 0;
        padding: 1rem;
    }
    .header-search input {
        width: 120px;
    }
    .user-profile span {
        display: none;
    }
    .header-date {
        font-size: 0.7rem;
        padding: 0.2rem 0.8rem;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .widgets-grid {
        grid-template-columns: 1fr 1fr;
    }
    .notif-dropdown {
        left: 10px;
        width: 90%;
    }
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }
    .stat-card {
        padding: 0.75rem;
    }
    .stat-card .stat-value {
        font-size: 1.1rem;
    }
    .widgets-grid {
        grid-template-columns: 1fr;
    }
    .report-rate-card {
        flex-direction: column;
        align-items: stretch;
    }
    .report-stats {
        gap: 0.5rem;
    }
    .header-search input {
        width: 80px;
    }
    .page-header {
        gap: 0.5rem;
    }
    .dashboard-footer {
        flex-direction: column;
        align-items: center;
        gap: 0.3rem;
    }
}