/**
 * AIOX Website Analytics - Dark Theme Styles
 * All class names match the HTML + JS exactly.
 * Uses CSS variables defined in the unified dashboard.
 */

/* ============================================================
   NOTICES
   ============================================================ */
#wa-notices {
    position: fixed; top: 1.25rem; right: 1.25rem; z-index: 9999;
    display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
.wa-notice {
    padding: .7rem 1.1rem; border-radius: 8px; font-size: .875rem;
    font-weight: 500; box-shadow: 0 4px 20px rgba(0,0,0,.5);
    pointer-events: auto; animation: waSlideIn .2s ease;
}
.wa-notice-success { background: #064e3b; color: #6ee7b7; border-left: 4px solid #10b981; }
.wa-notice-error   { background: #7f1d1d; color: #fca5a5; border-left: 4px solid #ef4444; }
@keyframes waSlideIn { from { opacity:0; transform: translateX(12px); } to { opacity:1; transform: none; } }

/* ============================================================
   HEADER BAR
   ============================================================ */
.wa-header-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.wa-period-wrap {
    display: flex; align-items: center; gap: .5rem;
    font-size: .875rem; color: var(--aiox-text-secondary, #94a3b8);
}
.wa-period-wrap select,
.wa-select {
    background: var(--aiox-bg-input, #12141f);
    color: var(--aiox-text-primary, #fff);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: 8px; padding: .4rem .8rem;
    font-size: .875rem; cursor: pointer; font-family: inherit;
}
.wa-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ============================================================
   BUTTONS
   ============================================================ */
.wa-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .45rem .9rem; border-radius: 8px;
    font-size: .84rem; font-weight: 500; border: 1px solid transparent;
    cursor: pointer; transition: all .2s; font-family: inherit;
    text-decoration: none; white-space: nowrap; line-height: 1;
}
.wa-btn-primary {
    background: linear-gradient(135deg, var(--aiox-accent-primary, #667eea), #764ba2);
    color: #fff;
}
.wa-btn-primary:hover { opacity: .85; }
.wa-btn-secondary {
    background: var(--aiox-bg-card, #181b28);
    color: var(--aiox-text-secondary, #94a3b8);
    border-color: var(--aiox-border-color, #1e2235);
}
.wa-btn-secondary:hover {
    border-color: rgba(102,126,234,.5); color: var(--aiox-text-primary, #fff);
}
.wa-btn-danger {
    background: rgba(239,68,68,.1); color: #f87171;
    border-color: rgba(239,68,68,.3);
}
.wa-btn-danger:hover { background: rgba(239,68,68,.2); }

/* ============================================================
   SUB-TAB NAVIGATION  (wa-sub-tabs / wa-sub-tab)
   ============================================================ */
.wa-sub-tabs {
    display: flex; flex-wrap: wrap;
    border-bottom: 1px solid var(--aiox-border-color, #1e2235);
    margin-bottom: 1.5rem;
    overflow-x: auto; scrollbar-width: none; gap: 0;
}
.wa-sub-tabs::-webkit-scrollbar { display: none; }
.wa-sub-tab {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .6rem 1rem; font-size: .83rem; font-weight: 500;
    color: var(--aiox-text-muted, #64748b);
    border: 1px solid transparent; border-bottom: none;
    margin-bottom: -1px; background: transparent;
    cursor: pointer; white-space: nowrap; font-family: inherit;
    transition: color .2s;
}
.wa-sub-tab:hover { color: var(--aiox-text-secondary, #94a3b8); }
.wa-sub-tab.active {
    background: var(--aiox-bg-card, #181b28);
    border-color: var(--aiox-border-color, #1e2235);
    border-bottom-color: var(--aiox-bg-card, #181b28);
    color: var(--aiox-text-primary, #fff); font-weight: 600;
}

/* ============================================================
   TAB PANES  (wa-tab-pane)
   ============================================================ */
.wa-tab-pane { display: none; }
.wa-tab-pane.active { display: block; }

/* ============================================================
   METRIC CARDS
   ============================================================ */
.wa-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 1rem; margin-bottom: 1.25rem;
}
.wa-metric-card {
    background: var(--aiox-bg-card, #181b28);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: var(--aiox-card-radius, 12px);
    padding: 1.1rem 1.2rem;
    display: flex; align-items: center; gap: .875rem;
}
/* Colour variants */
.wa-metric-blue   { border-left: 3px solid var(--aiox-accent-primary, #667eea) !important; }
.wa-metric-purple { border-left: 3px solid #a855f7 !important; }
.wa-metric-green  { border-left: 3px solid var(--aiox-accent-success, #10b981) !important; }
.wa-metric-amber  { border-left: 3px solid var(--aiox-accent-warning, #f59e0b) !important; }
.wa-metric-red    { border-left: 3px solid var(--aiox-accent-danger, #ef4444) !important; }
.wa-metric-teal   { border-left: 3px solid #22d3ee !important; }
.wa-metric-slate  { border-left: 3px solid var(--aiox-text-muted, #64748b) !important; }

.wa-metric-icon {
    font-size: 1.4rem; line-height: 1; flex-shrink: 0;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.04); border-radius: 8px;
}
.wa-metric-value {
    font-size: 1.6rem; font-weight: 700;
    color: var(--aiox-text-primary, #fff); line-height: 1.1;
}
.wa-metric-label {
    font-size: .7rem; color: var(--aiox-text-muted, #64748b);
    text-transform: uppercase; letter-spacing: .04em; margin-top: .2rem;
}

/* ============================================================
   CHART CARDS  (wa-chart-card / wa-chart-wrap)
   ============================================================ */
.wa-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.25rem; margin-bottom: 1.25rem;
}
.wa-chart-card {
    background: var(--aiox-bg-card, #181b28);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: var(--aiox-card-radius, 12px);
    padding: 1.25rem;
}
.wa-chart-card h3 {
    display: flex; align-items: center; gap: .5rem;
    margin: 0 0 .875rem 0; font-size: .9375rem; font-weight: 600;
    color: var(--aiox-text-primary, #fff);
}
.wa-chart-wrap { position: relative; height: 240px; }

/* ============================================================
   TABLE CARDS  (wa-table-card / wa-table-wrap / wa-table)
   ============================================================ */
.wa-table-card {
    background: var(--aiox-bg-card, #181b28);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: var(--aiox-card-radius, 12px);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.wa-table-card h3 {
    display: flex; align-items: center; gap: .5rem;
    margin: 0 0 1rem 0; font-size: .9375rem; font-weight: 600;
    color: var(--aiox-text-primary, #fff);
}
.wa-table-wrap { overflow-x: auto; max-height: 420px; overflow-y: auto; }
.wa-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.wa-table th {
    padding: .5rem .75rem; text-align: left; font-size: .7rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--aiox-text-muted, #64748b);
    background: rgba(255,255,255,.025);
    border-bottom: 1px solid var(--aiox-border-color, #1e2235);
    position: sticky; top: 0; z-index: 1;
}
.wa-table td {
    padding: .55rem .75rem;
    color: var(--aiox-text-secondary, #94a3b8);
    border-bottom: 1px solid rgba(255,255,255,.03);
    vertical-align: middle;
}
.wa-table tbody tr:hover { background: rgba(255,255,255,.025); }
.wa-empty, .wa-loading {
    text-align: center !important; padding: 2.5rem !important;
    color: var(--aiox-text-muted, #64748b);
}

/* ============================================================
   INFO BANNER  (wa-info-banner)
   ============================================================ */
.wa-info-banner {
    display: flex; gap: 1rem; align-items: center;
    padding: 1rem 1.25rem;
    background: var(--aiox-bg-card, #181b28);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-left: 4px solid var(--aiox-accent-primary, #667eea);
    border-radius: var(--aiox-card-radius, 12px);
    margin-bottom: 1.25rem;
}
.wa-info-banner strong { color: var(--aiox-text-primary, #fff); font-size: .9375rem; display: block; margin-bottom: .2rem; }
.wa-info-banner p { margin: 0; color: var(--aiox-text-secondary, #94a3b8); font-size: .875rem; }

/* ============================================================
   VISITOR TYPE BADGES  (wa-type-badge)
   ============================================================ */
.wa-type-badge {
    display: inline-block; padding: .2em .55em; border-radius: 4px;
    font-size: .72rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.wa-analytics-container { position: relative; min-height: 200px; }
#wa-loading-overlay {
    position: absolute; inset: 0;
    background: rgba(15,17,26,.75);
    display: flex; align-items: center; justify-content: center;
    z-index: 50; border-radius: var(--aiox-card-radius, 12px);
    backdrop-filter: blur(2px);
}
.wa-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,.07);
    border-top-color: var(--aiox-accent-primary, #667eea);
    border-radius: 50%; animation: waSpin .8s linear infinite;
}
.wa-spinner-small {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.07);
    border-top-color: var(--aiox-accent-primary, #667eea);
    border-radius: 50%; animation: waSpin .8s linear infinite;
    vertical-align: middle; margin-right: 5px;
}
@keyframes waSpin { to { transform: rotate(360deg); } }

/* ============================================================
   SNIPPET BOX
   ============================================================ */
.wa-snippet-box {
    background: #0d1117;
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: 10px; overflow: hidden; margin-bottom: 1.25rem;
}
.wa-snippet-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: .5rem 1rem;
    background: rgba(255,255,255,.025);
    border-bottom: 1px solid var(--aiox-border-color, #1e2235);
    font-size: .8rem; color: var(--aiox-text-muted, #64748b);
}
#wa-snippet-code {
    display: block; padding: 1.1rem;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: .78rem; line-height: 1.65; color: #e6edf3;
    white-space: pre; overflow-x: auto;
    max-height: 480px; overflow-y: auto;
}
.wa-snippet-steps {
    list-style: decimal; padding-left: 1.25rem;
    color: var(--aiox-text-secondary, #94a3b8);
    font-size: .875rem; line-height: 2; margin: 0 0 1.25rem 0;
}
.wa-snippet-steps li strong { color: var(--aiox-text-primary, #fff); }

/* ============================================================
   SETTINGS
   ============================================================ */
.wa-settings-section {
    background: rgba(255,255,255,.02);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: 10px; padding: 1.25rem; margin-bottom: 1.25rem;
}
.wa-settings-section h4 {
    margin: 0 0 1rem 0; font-size: .9rem; font-weight: 600;
    color: var(--aiox-text-primary, #fff);
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--aiox-border-color, #1e2235);
    display: flex; align-items: center; gap: .5rem;
}
.wa-tip-box {
    background: rgba(245,158,11,.07);
    border-left: 4px solid var(--aiox-accent-warning, #f59e0b);
    border-radius: 8px; padding: .875rem 1rem; margin-bottom: 1rem;
    font-size: .875rem; color: var(--aiox-text-secondary, #94a3b8);
}
.wa-tip-box strong { color: var(--aiox-text-primary, #fff); }
.wa-info-box {
    background: rgba(102,126,234,.07);
    border-left: 4px solid var(--aiox-accent-primary, #667eea);
    border-radius: 8px; padding: .875rem 1rem; margin-bottom: 1rem;
    font-size: .875rem;
}
.wa-info-box h4 { color: var(--aiox-accent-primary, #667eea); font-size: .9rem; font-weight: 600; margin: 0 0 .4rem 0; }
.wa-info-box p  { margin: 0; color: var(--aiox-text-secondary, #94a3b8); }

/* DB stats grid */
.wa-db-stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem; margin-bottom: 1rem;
}
.wa-db-stat {
    background: var(--aiox-bg-primary, #0f111a);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-left: 3px solid var(--aiox-accent-primary, #667eea);
    border-radius: 8px; padding: .75rem 1rem;
}
.wa-db-stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--aiox-text-muted, #64748b); margin-bottom: .25rem; }
.wa-db-stat-value { font-size: 1.25rem; font-weight: 700; color: var(--aiox-text-primary, #fff); }

/* Logging type checkboxes */
.wa-logging-types {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem;
}
.wa-logging-label {
    display: block;
    background: var(--aiox-bg-card, #181b28);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: 8px; padding: .875rem 1rem; cursor: pointer;
    transition: border-color .2s;
}
.wa-logging-label:hover { border-color: rgba(102,126,234,.5); }
.wa-logging-label input[type=checkbox] { accent-color: var(--aiox-accent-primary, #667eea); margin-right: .5rem; }
.wa-logging-label strong { color: var(--aiox-text-primary, #fff); }
.wa-logging-label .wa-log-desc { font-size: .75rem; color: var(--aiox-text-muted, #64748b); margin-top: .25rem; }
.wa-logging-label .wa-log-impact { font-size: .7rem; margin-top: .2rem; }
.wa-impact-low  { color: #34d399; }
.wa-impact-med  { color: #fbbf24; }
.wa-impact-high { color: #f87171; }
.wa-impact-crit { color: #ef4444; font-weight: 700; }

/* ============================================================
   BROWSER ANALYSIS
   ============================================================ */
.wa-scan-controls {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    padding: 1rem; background: var(--aiox-bg-card, #181b28);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: var(--aiox-card-radius, 12px); margin-bottom: 1.25rem;
}
.wa-progress-wrap { flex: 1; min-width: 180px; }
.wa-progress-track {
    background: rgba(255,255,255,.06); border-radius: 8px; height: 14px;
    overflow: hidden; border: 1px solid var(--aiox-border-color, #1e2235);
}
.wa-progress-bar {
    background: linear-gradient(90deg, var(--aiox-accent-primary, #667eea), #764ba2);
    height: 100%; width: 0%; transition: width .3s ease; border-radius: 8px;
}
.wa-progress-labels {
    display: flex; justify-content: space-between;
    font-size: .72rem; color: var(--aiox-text-muted, #64748b); margin-top: .3rem;
}
.wa-risk-high   { background: rgba(239,68,68,.15); color: #f87171; padding: .2em .5em; border-radius: 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.wa-risk-medium { background: rgba(245,158,11,.15); color: #fbbf24; padding: .2em .5em; border-radius: 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.wa-risk-low    { background: rgba(16,185,129,.15); color: #34d399; padding: .2em .5em; border-radius: 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; }

/* ============================================================
   EXPORT MODAL
   ============================================================ */
.wa-modal {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}
.wa-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.wa-modal-content {
    position: relative; z-index: 1;
    background: var(--aiox-bg-card, #181b28);
    border: 1px solid var(--aiox-border-color, #1e2235);
    border-radius: 14px; width: 100%; max-width: 420px;
    padding: 1.5rem; box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.wa-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.wa-modal-header h3 { margin: 0; font-size: 1.05rem; font-weight: 600; color: var(--aiox-text-primary, #fff); }
.wa-modal-close { background: none; border: none; cursor: pointer; color: var(--aiox-text-muted, #64748b); font-size: 1.25rem; padding: .2rem; font-family: inherit; }
.wa-modal-close:hover { color: var(--aiox-text-primary, #fff); }
.wa-modal-footer { display: flex; justify-content: flex-end; margin-top: 1.25rem; }

/* ============================================================
   PAGINATION
   ============================================================ */
.wa-pagination { display: flex; justify-content: center; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.wa-page-btn {
    padding: .3rem .7rem; border-radius: 6px;
    border: 1px solid var(--aiox-border-color, #1e2235);
    background: var(--aiox-bg-card, #181b28);
    color: var(--aiox-text-muted, #64748b); cursor: pointer;
    font-size: .82rem; font-family: inherit; transition: all .2s;
}
.wa-page-btn:hover, .wa-page-btn.active {
    border-color: var(--aiox-accent-primary, #667eea);
    color: var(--aiox-accent-primary, #667eea);
}

/* ============================================================
   MISC
   ============================================================ */
.wa-ua-cell   { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-page-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-time-cell { white-space: nowrap; }
.wa-page-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: .5rem .75rem; border-bottom: 1px solid rgba(255,255,255,.04);
    font-size: .84rem;
}
.wa-page-url   { color: var(--aiox-text-secondary, #94a3b8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.wa-page-visits { color: var(--aiox-text-primary, #fff); font-weight: 600; flex-shrink: 0; margin-left: .75rem; }
.wa-tag {
    display: inline-block; padding: .2em .6em; border-radius: 4px;
    font-size: .75rem; font-weight: 600;
    background: rgba(16,185,129,.15); color: #34d399; margin: .15rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 680px) {
    .wa-metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .wa-charts-grid  { grid-template-columns: 1fr; }
    .wa-sub-tab span { display: none; }
    .wa-sub-tab      { padding: .6rem .7rem; }
}
