/* =============================================
   Shared Author Stats — matched to web design
   ============================================= */

/* ?? Loading / Spinner ?? */
.astats-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; gap: 1rem; color: var(--text-secondary, #666); }
.astats-spinner { width: 48px; height: 48px; border: 4px solid var(--border-color, #e5e7eb); border-top-color: #6366f1; border-radius: 50%; animation: astats-spin 0.8s linear infinite; }
@keyframes astats-spin { to { transform: rotate(360deg); } }

/* ?? Hero (purple gradient — matches web) ?? */
.astats-hero {
    position: relative;
    margin-bottom: 2rem;
    overflow: hidden;
}

.astats-hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
}

.astats-hero-overlay {
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    z-index: 1;
}

.astats-hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: white;
    padding: calc(80px + 3rem) 1.5rem 2.5rem; /* accounts for fixed navbar */
}

.astats-hero-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.astats-hero-icon i { font-size: 2.5rem; color: white; }
.astats-hero-content h1 { margin: 0 0 0.5rem; font-size: 2.5rem; font-weight: 800; letter-spacing: -0.5px; }
.astats-hero-content p { margin: 0; font-size: 1.1rem; color: rgba(255,255,255,0.9); }

/* ?? Page / Container ?? */
.astats-page { min-height: 100vh; min-height: 100dvh; background: var(--bg-color, #f5f5f5); padding: 0 1.5rem 3rem; }
.astats-container { max-width: 1200px; margin: 0 auto; }

/* ?? Access Denied ?? */
.astats-access-denied { text-align: center; padding: 80px 24px; }
.astats-access-denied i { font-size: 64px; color: #ef4444; margin-bottom: 16px; display: block; }
.astats-access-denied h3 { margin: 0 0 8px; color: var(--text-primary, #212529); }
.astats-access-denied p { color: var(--text-secondary, #666); margin-bottom: 24px; }

/* ?? Buttons ?? */
.astats-btn-primary { padding: 12px 24px; background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; border: none; border-radius: 10px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all 0.2s; }
.astats-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.astats-btn-light { padding: 8px 16px; background: transparent; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; color: var(--text-secondary, #666); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; transition: all 0.2s; width: 100%; justify-content: center; }
.astats-btn-light:hover { border-color: #6366f1; color: #6366f1; }

/* ?? Tabs (purple gradient active — matches web) ?? */
.astats-tabs { display: flex; background: var(--card-background, #fff); border-radius: 1rem; padding: 0.5rem; gap: 0.5rem; box-shadow: 0 2px 12px rgba(0,0,0,0.08); margin-bottom: 2rem; overflow-x: auto; }
.astats-tab { flex: 1; min-width: fit-content; padding: 1rem 1.5rem; border: none; background: transparent; border-radius: 0.75rem; cursor: pointer; transition: all 0.3s ease; font-weight: 600; font-size: 0.95rem; color: var(--text-secondary, #666); display: flex; align-items: center; justify-content: center; gap: 0.5rem; white-space: nowrap; }
.astats-tab:hover { background: var(--bg-secondary, #f3f4f6); color: var(--text-primary, #333); transform: translateY(-1px); }
.astats-tab.active { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.astats-tab.active:hover { background: linear-gradient(135deg, #5558e8, #7c4fe0); }
.astats-tab i { font-size: 1.1rem; }

/* ?? Filters (purple label accent — matches web) ?? */
.astats-filters { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem; padding: 1rem; background: var(--bg-secondary, #f9fafb); border-radius: 0.75rem; overflow: hidden; }
.astats-filter { display: flex; flex-direction: column; gap: 0.375rem; min-width: 130px; flex: 1; box-sizing: border-box; }
.astats-filter label { font-size: 0.7rem; font-weight: 600; color: #6366f1; text-transform: uppercase; letter-spacing: 0.5px; }
.astats-filter select,
.astats-filter input[type="date"] { padding: 0.45rem 0.65rem; border: 1px solid var(--border-color, #e5e7eb); border-radius: 0.5rem; background: var(--card-background, #fff); color: var(--text-primary, #212529); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: border-color 0.2s; width: 100%; max-width: 100%; box-sizing: border-box; }
.astats-btn-light { box-sizing: border-box; max-width: 100%; }
.astats-filter select:focus,
.astats-filter input[type="date"]:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }

/* ?? Earnings Banner (green accent — matches web) ?? */
.astats-earnings-banner { display: flex; align-items: center; gap: 1rem; padding: 1.25rem 1.5rem; background: linear-gradient(135deg, #f0f8f0, #fff); border-radius: 1rem; border-left: 4px solid #28a745; box-shadow: 0 4px 16px rgba(40,167,69,0.1); margin-bottom: 1.5rem; }
.astats-earnings-banner-icon { width: 56px; height: 56px; background: linear-gradient(135deg, #28a745, #20c997); border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: white; font-size: 1.5rem; }
.astats-earnings-banner-body { flex: 1; }
.astats-earnings-banner-label { font-size: 1.1rem; font-weight: 700; color: var(--text-primary, #212529); }
.astats-earnings-banner-sub { font-size: 0.85rem; color: var(--text-secondary, #666); }
.astats-earnings-banner-value { font-size: 2rem; font-weight: 900; color: #28a745; }

/* ?? Stats Cards (left border + gradient bg — matches web) ?? */
.astats-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.astats-card { background: var(--card-background, #fff); border-radius: 1rem; padding: 1.5rem; box-shadow: 0 2px 12px rgba(0,0,0,0.08); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.75rem; transition: all 0.2s; border-left: 4px solid var(--primary-color, #00b4ff); }
.astats-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.astats-card-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.04); }
.astats-card-icon i { font-size: 1.5rem; }
.astats-card-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.astats-card-label { font-size: 0.875rem; font-weight: 600; color: var(--text-secondary, #666); }
.astats-card-sub { font-size: 0.75rem; color: var(--text-secondary, #999); }

/* ?? Rate Guide (amber accent — matches web) ?? */
.astats-rate-guide { background: linear-gradient(135deg, rgba(255,248,220,0.4), rgba(255,255,255,0.8)); border-radius: 1rem; border: 1px solid rgba(255,193,7,0.2); margin-bottom: 1.5rem; overflow: hidden; }
.astats-rate-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; cursor: pointer; font-weight: 700; color: #444; transition: background 0.2s; }
.astats-rate-header:hover { background: rgba(255,193,7,0.05); }
.astats-rate-header span i { color: #f57c00; margin-right: 0.5rem; }
.astats-rate-body { padding: 1.5rem; border-top: 1px solid rgba(255,193,7,0.15); }
.astats-rate-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.5rem; }
.astats-rate-cols h5 { margin: 0 0 1rem; font-weight: 600; font-size: 1rem; text-align: center; }
.astats-rate-row { display: flex; justify-content: space-between; align-items: center; padding: 0.25rem 0; font-size: 0.9rem; color: #666; }
.astats-rate-note { text-align: center; margin: 1rem 0 0; padding-top: 1rem; border-top: 1px solid rgba(255,193,7,0.15); font-size: 0.85rem; color: #999; font-style: italic; }

/* ?? Badges (traditional muted — matches web) ?? */
.astats-badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.astats-badge.light { background: var(--bg-secondary, #f3f4f6); color: var(--text-secondary, #666); }
.astats-badge.success { background: #d4edda; color: #155724; }
.astats-badge.primary { background: #cce5ff; color: #004085; }
.astats-badge.info { background: #d1ecf1; color: #0c5460; }
.astats-badge.warning { background: #fff3cd; color: #856404; }

/* ?? Chart ?? */
.astats-chart-section { background: var(--card-background, #fff); border-radius: 1rem; padding: 1.5rem; box-shadow: 0 2px 12px rgba(0,0,0,0.08); margin-bottom: 1.5rem; }
.astats-chart-section h4 { margin: 0 0 1rem; font-weight: 700; font-size: 1rem; color: var(--text-primary, #212529); }
.astats-chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem; }
.astats-chart-header h4 { margin: 0; }
.astats-chart-toggle { display: flex; gap: 0.25rem; background: var(--bg-secondary, #f1f5f9); padding: 0.25rem; border-radius: 0.5rem; }
.astats-toggle-btn { display: flex; align-items: center; gap: 0.375rem; padding: 0.5rem 0.875rem; border: none; background: transparent; color: var(--text-secondary, #64748b); font-size: 0.85rem; font-weight: 500; border-radius: 0.375rem; cursor: pointer; transition: all 0.2s; }
.astats-toggle-btn:hover { color: var(--text-primary, #333); }
.astats-toggle-btn.active { background: var(--card-background, #fff); color: #6366f1; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 600; }

/* Chart layout: Y-axis | Plot area */
.astats-chart { position: relative; display: flex; gap: 0; }

/* Y-axis */
.astats-yaxis { width: 48px; flex-shrink: 0; position: relative; }
.astats-yaxis-tick { position: absolute; right: 8px; transform: translateY(50%); font-size: 0.7rem; color: var(--text-secondary, #999); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Plot area */
.astats-plot { flex: 1; position: relative; min-width: 0; }
.astats-gridline { position: absolute; left: 0; right: 0; height: 1px; background: var(--border-color, #eee); pointer-events: none; }

/* Bars */
.astats-chart-bars { display: flex; align-items: flex-end; gap: 2px; height: 100%; position: relative; z-index: 1; }
.astats-chart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; cursor: pointer; }
.astats-chart-bar { width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; transition: height 0.4s ease, opacity 0.2s, transform 0.15s; opacity: 0.8; background: var(--bar-color); }
.astats-chart-col:hover .astats-chart-bar { opacity: 1; transform: scaleX(1.15); }

/* X-axis */
.astats-xaxis { position: relative; height: 28px; margin-left: 48px; margin-top: 4px; }
.astats-xaxis-tick { position: absolute; transform: translateX(-50%); font-size: 0.7rem; color: var(--text-secondary, #999); white-space: nowrap; }

/* Floating tooltip */
.astats-chart-tip { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 8px; background: var(--card-background, #fff); border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; padding: 6px 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 10; animation: astats-tip-in 0.15s ease-out; }
.astats-chart-tip-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.astats-chart-tip-label { font-size: 0.8rem; color: var(--text-secondary, #666); font-weight: 500; }
.astats-chart-tip-value { font-size: 1rem; font-weight: 700; }
@keyframes astats-tip-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.astats-chart-empty { text-align: center; padding: 2rem; color: var(--text-secondary, #999); font-size: 0.9rem; }

/* ?? Revenue Sub-tabs ?? */
.astats-subtabs { display: flex; gap: 0.25rem; background: var(--bg-secondary, #f1f5f9); padding: 0.25rem; border-radius: 0.5rem; margin-bottom: 1.5rem; }
.astats-subtab { flex: 1; padding: 0.5rem 0.875rem; border: none; background: transparent; border-radius: 0.375rem; font-weight: 500; font-size: 0.85rem; color: var(--text-secondary, #64748b); cursor: pointer; transition: all 0.2s; text-align: center; }
.astats-subtab:hover { color: var(--text-primary, #333); }
.astats-subtab.active { background: var(--card-background, #fff); color: #6366f1; box-shadow: 0 1px 3px rgba(0,0,0,0.1); font-weight: 600; }

/* ?? Revenue Summary ?? */
.astats-revenue-summary { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; background: linear-gradient(135deg, color-mix(in srgb, var(--accent, #8b5cf6) 10%, transparent), color-mix(in srgb, var(--accent, #8b5cf6) 5%, transparent)); border-radius: 0.5rem; margin-bottom: 1rem; font-size: 0.9rem; }

/* ?? Empty State ?? */
.astats-empty { text-align: center; padding: 60px 24px; }
.astats-empty i { font-size: 48px; color: var(--text-secondary, #9ca3af); margin-bottom: 16px; display: block; }
.astats-empty h3 { margin: 0 0 8px; color: var(--text-primary, #212529); }
.astats-empty p { margin: 0; color: var(--text-secondary, #666); }

/* ?? DataTable ?? */
.astats-table-wrap { overflow-x: auto; background: var(--card-background, #fff); border-radius: 1rem; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.astats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.astats-table thead { background: var(--bg-secondary, #f9fafb); }
.astats-table th { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--text-secondary, #666); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; border-bottom: 1px solid var(--border-color, #e5e7eb); }
.astats-table td { padding: 12px 16px; border-top: 1px solid var(--border-color, #f0f0f0); color: var(--text-primary, #212529); }
.astats-table tbody tr:hover { background: var(--bg-secondary, #f9fafb); }
.astats-table code { font-size: 0.8rem; color: #666; }

.astats-table-empty { text-align: center; padding: 48px 24px; color: var(--text-secondary, #9ca3af); }
.astats-table-empty i { font-size: 2rem; display: block; margin-bottom: 0.5rem; }

.astats-table-paging { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 12px; font-size: 0.85rem; color: var(--text-secondary, #666); }
.astats-table-paging button { width: 32px; height: 32px; border: 1px solid var(--border-color, #e5e7eb); border-radius: 8px; background: transparent; color: var(--text-primary, #212529); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.astats-table-paging button:hover:not(:disabled) { border-color: #6366f1; color: #6366f1; }
.astats-table-paging button:disabled { opacity: 0.3; cursor: not-allowed; }

/* ?? Responsive ?? */
@media (max-width: 768px) {
    .astats-hero-content { padding: calc(60px + 2rem) 1rem 2rem; }
    .astats-hero-content h1 { font-size: 1.75rem; }
    .astats-hero-content p { font-size: 0.9rem; }
    .astats-hero-icon { width: 60px; height: 60px; }
    .astats-hero-icon i { font-size: 1.75rem; }

    .astats-page { padding: 0 0.75rem 2rem; }

    .astats-tabs { flex-wrap: wrap; }
    .astats-tab { padding: 0.75rem; font-size: 0.85rem; gap: 0.35rem; }
    .astats-tab span { display: none; }

    .astats-filters { flex-direction: column; }
    .astats-filter { min-width: 0; width: 100%; flex: none; }

    .astats-earnings-banner { flex-direction: column; text-align: center; gap: 0.75rem; }
    .astats-earnings-banner-value { font-size: 1.5rem; }

    .astats-cards { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .astats-card { padding: 1rem; gap: 0.5rem; }
    .astats-card-value { font-size: 1.25rem; }
    .astats-card-icon { width: 36px; height: 36px; }
    .astats-card-icon i { font-size: 1.1rem; }

    .astats-rate-cols { grid-template-columns: 1fr; }

    .astats-subtabs { flex-wrap: wrap; }
    .astats-subtab { font-size: 0.8rem; padding: 0.5rem; }

    .astats-yaxis { width: 36px; }
    .astats-yaxis-tick { font-size: 0.6rem; }
    .astats-xaxis { margin-left: 36px; }
    .astats-xaxis-tick { font-size: 0.6rem; }

    .astats-table th, .astats-table td { padding: 8px 10px; font-size: 0.8rem; }
}

@media (max-width: 400px) {
    .astats-cards { grid-template-columns: 1fr; }
    .astats-tab { flex: auto; min-width: 0; }
}

/* ?? Dark Mode ?? */
body.dark-mode .astats-page { background: var(--bg-color, #121212); }

body.dark-mode .astats-tabs,
body.dark-mode .astats-card,
body.dark-mode .astats-table-wrap { background: var(--card-background, #1e293b); box-shadow: 0 2px 12px rgba(0,0,0,0.3); }

body.dark-mode .astats-tab { color: var(--text-secondary, #9ca3af); }
body.dark-mode .astats-tab:hover { background: rgba(255,255,255,0.05); color: var(--text-primary, #e0e0e0); }
body.dark-mode .astats-tab.active { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; }

body.dark-mode .astats-filters { background: var(--card-background, #1e293b); }
body.dark-mode .astats-filter label { color: #818cf8; }
body.dark-mode .astats-filter select,
body.dark-mode .astats-filter input[type="date"] { background: var(--input-bg, #2d2d2d); color: var(--text-primary, #e0e0e0); border-color: var(--border-color, #444); }
body.dark-mode .astats-filter select:focus,
body.dark-mode .astats-filter input[type="date"]:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(129,140,248,0.15); }

body.dark-mode .astats-earnings-banner { background: linear-gradient(135deg, rgba(40,167,69,0.15), rgba(40,167,69,0.05)); border-color: rgba(40,167,69,0.3); }
body.dark-mode .astats-earnings-banner-label { color: var(--text-primary, #e0e0e0); }
body.dark-mode .astats-earnings-banner-sub { color: var(--text-secondary, #aaa); }

body.dark-mode .astats-card { border-color: rgba(255,255,255,0.1); }

body.dark-mode .astats-rate-guide { background: var(--card-background, #1e293b); border-color: rgba(255,193,7,0.15); }
body.dark-mode .astats-rate-header { color: var(--text-primary, #e0e0e0); }
body.dark-mode .astats-rate-header:hover { background: rgba(255,255,255,0.04); }
body.dark-mode .astats-rate-row { color: var(--text-secondary, #aaa); }

body.dark-mode .astats-badge.light { background: rgba(255,255,255,0.08); color: var(--text-secondary, #9ca3af); }
body.dark-mode .astats-badge.success { background: rgba(21,87,36,0.3); color: #6ee7b7; }
body.dark-mode .astats-badge.primary { background: rgba(0,64,133,0.3); color: #93c5fd; }
body.dark-mode .astats-badge.info { background: rgba(12,84,96,0.3); color: #67e8f9; }
body.dark-mode .astats-badge.warning { background: rgba(133,100,4,0.3); color: #fcd34d; }

body.dark-mode .astats-chart-section { background: var(--card-background, #1e293b); box-shadow: 0 2px 12px rgba(0,0,0,0.3); }
body.dark-mode .astats-chart-section h4 { color: var(--text-primary, #e0e0e0); }
body.dark-mode .astats-chart-tip { background: var(--card-background, #1e293b); border-color: var(--border-color, #444); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
body.dark-mode .astats-chart-tip-label { color: var(--text-secondary, #9ca3af); }
body.dark-mode .astats-gridline { background: rgba(255,255,255,0.06); }
body.dark-mode .astats-yaxis-tick, body.dark-mode .astats-xaxis-tick { color: var(--text-secondary, #666); }
body.dark-mode .astats-chart-toggle { background: rgba(255,255,255,0.06); }
body.dark-mode .astats-toggle-btn { color: var(--text-secondary, #9ca3af); }
body.dark-mode .astats-toggle-btn.active { background: rgba(99,102,241,0.15); color: #818cf8; box-shadow: none; }

body.dark-mode .astats-subtabs { background: var(--card-background, #1e293b); }
body.dark-mode .astats-subtab { color: var(--text-secondary, #9ca3af); }
body.dark-mode .astats-subtab.active { background: rgba(99,102,241,0.15); color: #818cf8; box-shadow: none; }

body.dark-mode .astats-table thead { background: rgba(255,255,255,0.04); }
body.dark-mode .astats-table th { color: var(--text-secondary, #9ca3af); border-color: rgba(255,255,255,0.06); }
body.dark-mode .astats-table td { border-color: rgba(255,255,255,0.06); color: var(--text-primary, #e0e0e0); }
body.dark-mode .astats-table tbody tr:hover { background: rgba(255,255,255,0.04); }
body.dark-mode .astats-table code { color: #94a3b8; }

body.dark-mode .astats-table-paging button { border-color: var(--border-color, #444); color: var(--text-primary, #e0e0e0); }
body.dark-mode .astats-table-paging button:hover:not(:disabled) { border-color: #818cf8; color: #818cf8; }

body.dark-mode .astats-empty h3,
body.dark-mode .astats-access-denied h3 { color: var(--text-primary, #e0e0e0); }
body.dark-mode .astats-empty p,
body.dark-mode .astats-access-denied p { color: var(--text-secondary, #aaa); }

body.dark-mode .astats-btn-light { color: var(--text-secondary, #9ca3af); border-color: var(--border-color, #444); }
body.dark-mode .astats-btn-light:hover { border-color: #818cf8; color: #818cf8; }
