/* ================================================================
   DASHBOARD POLISH — Unified Design System Enhancement Layer
   Shared across SSP, DSP & SuperAdmin dashboards.
   This is an additive CSS layer — no functionality changes.
   ================================================================ */

/* === ENHANCED ROOT TOKENS === */
:root {
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
    --shadow-glow-accent: 0 0 20px rgba(0, 255, 136, 0.06);
    --shadow-glow-purple: 0 0 20px rgba(139, 92, 246, 0.06);
    --shadow-glow-blue: 0 0 20px rgba(0, 180, 216, 0.06);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --bg-elevated: #14141e;
    --bg-surface: #0f0f17;
    --border-subtle: rgba(255, 255, 255, 0.04);
}

/* === GLOBAL REFINEMENTS === */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Smooth scrolling */
html { scroll-behavior: smooth; }

/* Better scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.14); }

/* Selection color */
::selection {
    background: rgba(0, 255, 136, 0.2);
    color: #fff;
}

/* === CARD ENHANCEMENTS === */
.card,
.chart-card,
.stat-card {
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-base);
}

.card:hover,
.chart-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

.stat-card {
    position: relative;
    overflow: hidden;
}

/* Subtle top accent line on stat cards */
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-1);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md), var(--shadow-glow-accent);
    transform: translateY(-1px);
}

/* Better stat value hierarchy */
.stat-card .stat-value,
.stat-value {
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.stat-card .stat-label,
.stat-label {
    font-weight: 600;
    letter-spacing: 0.06em;
}

.stat-card .stat-sub,
.stat-sub {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Trend indicators */
.trend-up {
    color: var(--accent) !important;
}

.trend-up::before {
    content: '↑ ';
    font-size: 0.7em;
}

.trend-down {
    color: var(--danger) !important;
}

.trend-down::before {
    content: '↓ ';
    font-size: 0.7em;
}

/* === TABLE ENHANCEMENTS === */
.data-table th,
thead th {
    background: rgba(255, 255, 255, 0.02);
    position: relative;
}

/* Striped rows */
.data-table tbody tr:nth-child(even),
tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.data-table tbody tr:hover,
tbody tr:hover {
    background: rgba(255, 255, 255, 0.04) !important;
    transition: background var(--transition-fast);
}

/* Better table cell styling */
.data-table td,
tbody td {
    transition: background var(--transition-fast);
}

/* Table container enhancement */
.table-wrap,
.table-container {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-wrap .data-table,
.table-container .data-table,
.table-wrap table,
.table-container table {
    margin-bottom: 0;
}

/* === BUTTON ENHANCEMENTS === */
.btn {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:hover {
    transform: translateY(-1px);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 68, 102, 0.15);
}

/* Focus visible ring */
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* === FORM ENHANCEMENTS === */
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-input:focus {
    box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.08);
}

.form-group input,
.form-group select,
.form-group textarea,
.form-input {
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

/* === STATUS BADGES === */
.status-badge,
.badge {
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: transform var(--transition-fast);
    white-space: nowrap;
}

/* Pulsing dot for active badges */
.status-badge.active .status-dot,
.status-badge.approved .status-dot {
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* === NAVIGATION ENHANCEMENTS === */
/* Top nav glass effect */
.app-nav {
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.nav-links a {
    transition: all var(--transition-base);
    position: relative;
}

/* Nav link underline animation */
.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    opacity: 0.7;
}

/* === SIDEBAR ENHANCEMENTS (Admin) === */
.sidebar {
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.06); border-radius: 2px; }

.nav-item {
    transition: all var(--transition-fast);
    border-radius: 0 8px 8px 0;
    margin-right: 8px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
    box-shadow: inset 3px 0 0 var(--purple, var(--accent));
    background: rgba(139, 92, 246, 0.08);
}

.nav-section-label {
    margin-top: 0.75rem;
    opacity: 0.6;
    transition: opacity var(--transition-base);
}

.sidebar:hover .nav-section-label {
    opacity: 1;
}

/* === CHART ENHANCEMENTS === */
.chart-card {
    position: relative;
}

/* Subtle gridlines */
.chart-area {
    position: relative;
    background-image: linear-gradient(
        to top,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px
    );
    background-size: 100% 25%;
}

.chart-bar {
    border-radius: 4px 4px 0 0;
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.chart-bar:hover {
    opacity: 1;
    transform: scaleY(1.02);
    transform-origin: bottom;
}

/* Chart tooltip enhancement */
.chart-bar .tooltip {
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    font-weight: 500;
}

/* Admin chart bars */
.chart-bars {
    background-image: linear-gradient(
        to top,
        rgba(255, 255, 255, 0.03) 1px,
        transparent 1px
    );
    background-size: 100% 25%;
}

.chart-bars .chart-bar {
    border-radius: 3px 3px 0 0;
    transition: opacity var(--transition-base), filter var(--transition-base);
}

.chart-bars .chart-bar:hover {
    opacity: 1;
    filter: brightness(1.2);
}

/* === TAB ENHANCEMENTS === */
.tab-bar {
    position: relative;
}

.tab-btn {
    transition: all var(--transition-base);
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    text-shadow: 0 0 20px currentColor;
}

/* Mode tabs (DSP) */
.mode-tabs {
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.mode-tab {
    transition: all var(--transition-base);
    border-radius: 6px;
}

.mode-tab.active {
    box-shadow: var(--shadow-sm);
}

/* === NOTIFICATION BELL ENHANCEMENTS === */
.notif-dropdown {
    backdrop-filter: blur(20px);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: dropdown-enter 0.2s ease-out;
}

@keyframes dropdown-enter {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.notif-item {
    transition: background var(--transition-fast);
}

.notif-item.unread {
    border-left: 2px solid var(--accent);
}

/* === EMPTY STATE ENHANCEMENTS === */
.empty-state {
    opacity: 0.8;
}

.empty-state .empty-icon {
    filter: grayscale(0.3);
    transition: filter var(--transition-base);
}

.empty-state:hover .empty-icon {
    filter: grayscale(0);
}

/* === LOADING ENHANCEMENTS === */
.loading {
    animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.spinner {
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
}

/* === MODAL ENHANCEMENTS === */
.modal-overlay {
    backdrop-filter: blur(4px);
}

.modal {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: modal-enter 0.25s ease-out;
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* === CODE BLOCK ENHANCEMENTS === */
.code-block {
    border-radius: var(--radius-md);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.06);
}

/* === SETUP CARD / BANNER ENHANCEMENTS === */
.setup-card,
.setup-banner {
    position: relative;
    overflow: hidden;
}

.setup-card::after,
.setup-banner::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 255, 136, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

/* === AI INSIGHTS ENHANCEMENTS === */
.ai-insights-card {
    box-shadow: var(--shadow-md), var(--shadow-glow-purple);
    transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.ai-insights-card:hover {
    border-color: rgba(139, 92, 246, 0.35);
    box-shadow: var(--shadow-md), 0 0 30px rgba(139, 92, 246, 0.1);
}

/* === ALERT ENHANCEMENTS === */
.alert,
.error-msg,
.success-msg {
    box-shadow: var(--shadow-sm);
    animation: alert-enter 0.3s ease-out;
}

@keyframes alert-enter {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === ZONE ITEM ENHANCEMENTS === */
.zone-item {
    transition: all var(--transition-base);
}

.zone-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.zone-item.selected {
    box-shadow: var(--shadow-md), var(--shadow-glow-accent);
}

/* === LOGIN BOX ENHANCEMENTS === */
.login-box,
.auth-card {
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.04);
    animation: login-enter 0.4s ease-out;
}

@keyframes login-enter {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* === PAGE TRANSITIONS === */
.main-content {
    animation: content-enter 0.25s ease-out;
}

@keyframes content-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === PAGE HEADER ENHANCEMENTS === */
.page-header {
    position: relative;
}

/* Sticky page header glass effect (admin) */
.page-header[style*="sticky"],
.sidebar + .main-content .page-header {
    backdrop-filter: blur(16px) saturate(1.3);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
}

/* === HEALTH ITEM ENHANCEMENTS (Admin) === */
.health-item {
    transition: background var(--transition-fast);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    border-radius: 6px;
}

.health-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* === SCORE BAR ENHANCEMENTS === */
.score-track {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
}

.score-fill {
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === MOBILE ENHANCEMENTS === */
.mobile-topbar {
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03);
}

.mobile-menu {
    backdrop-filter: blur(24px);
    animation: mobile-menu-enter 0.2s ease-out;
}

@keyframes mobile-menu-enter {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === SIDEBAR OVERLAY === */
.sidebar-overlay.open {
    animation: overlay-enter 0.2s ease-out;
}

@keyframes overlay-enter {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === UTILITY CLASSES === */
.animate-in {
    animation: fade-in 0.3s ease-out;
}

.animate-slide-up {
    animation: slide-up 0.3s ease-out;
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Card with colored accent variants */
.stat-card.accent::before { background: linear-gradient(90deg, var(--accent), var(--accent-dim, var(--accent))); opacity: 1; }
.stat-card.danger::before { background: var(--danger); opacity: 1; }
.stat-card.warning::before { background: var(--warning); opacity: 1; }
.stat-card.info::before { background: var(--info, #00b4d8); opacity: 1; }
.stat-card.purple::before { background: var(--purple, #8b5cf6); opacity: 1; }

/* Better focus for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid rgba(0, 255, 136, 0.5);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .sidebar, .app-nav, .mobile-topbar, .notif-bell-wrap { display: none !important; }
    .main-content { margin-left: 0 !important; padding-top: 0 !important; }
    body { background: #fff; color: #000; }
    .card, .stat-card, .chart-card { box-shadow: none; border: 1px solid #ddd; }
}
