/* ══════════════════════════════════════════════════════
   Shared CSS — reusable styles across dashboard pages
   ══════════════════════════════════════════════════════ */

/* ── Stat Card ────────────────────────────────────── */
.stat-card {
    border: none;
    border-radius: 16px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15) !important;
}

.stat-card .card-body {
    position: relative;
    z-index: 1;
}

.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 3rem;
    opacity: 0.15;
    z-index: 0;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.85;
    font-weight: 600;
}

.stat-card .stat-sub {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ── Table Card ───────────────────────────────────── */
.table-card {
    border: none;
    border-radius: 16px;
    overflow: hidden;
    background-color: #ffffff;
}

.table-card .table {
    margin-bottom: 0;
}

.table-card .table thead th {
    border-top: none;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    opacity: 0.95;
    color: #343a40;
}

[data-bs-theme="dark"] .table-card {
    background-color: #2b3035;
}

[data-bs-theme="dark"] .table-card .table thead th {
    color: #dee2e6;
}

.table-card .table td {
    vertical-align: middle;
    font-size: 0.85rem;
}

/* ── Chart Card ───────────────────────────────────── */
.chart-card {
    border: none;
    border-radius: 16px;
    transition: transform 0.2s ease;
    background-color: #ffffff;
}

.chart-card:hover {
    transform: translateY(-2px);
}

.chart-card .card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 700;
    font-size: 0.95rem;
}

[data-bs-theme="dark"] .chart-card {
    background-color: #2b3035;
}

[data-bs-theme="dark"] .chart-card .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}



/* ── Progress Thin ────────────────────────────────── */
.progress-thin {
    height: 6px;
    border-radius: 3px;
}

[data-bs-theme="dark"] .progress-thin {
    background-color: rgba(255, 255, 255, 0.1);
}

/* ── Empty State ──────────────────────────────────── */
.empty-state {
    padding: 3rem;
    text-align: center;
    opacity: 1;
    color: #495057;
}

[data-bs-theme="dark"] .empty-state {
    color: #adb5bd;
}

/* ── Gradient Backgrounds ─────────────────────────── */
.bg-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.bg-gradient-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: #fff;
}

.bg-gradient-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: #fff;
}

.bg-gradient-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
}

.bg-gradient-danger {
    background: linear-gradient(135deg, #ff6a00 0%, #ee0979 100%);
    color: #fff;
}

.bg-gradient-dark {
    background: linear-gradient(135deg, #434343 0%, #000000 100%);
    color: #fff;
}

.bg-gradient-indigo {
    background: linear-gradient(135deg, #3f51b5 0%, #5c6bc0 100%);
    color: #fff;
}

/* ── Status Gradients (system info) ───────────────── */
.status-success {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.status-warning {
    background: linear-gradient(135deg, #f2c94c 0%, #f2994a 100%);
}

.status-danger {
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
}

.status-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* ── Misc Helpers ─────────────────────────────────── */
.country-flag {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
    vertical-align: middle;
    box-shadow: 0 0 1px rgba(0, 0, 0, 0.3);
}

.platform-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.rank-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
}

/* ── Animations ───────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-up {
    animation: fadeInUp 0.5s ease forwards;
}

.animate-up:nth-child(2) {
    animation-delay: 0.1s;
}

.animate-up:nth-child(3) {
    animation-delay: 0.2s;
}

.animate-up:nth-child(4) {
    animation-delay: 0.3s;
}

.animate-up:nth-child(5) {
    animation-delay: 0.35s;
}

.animate-up:nth-child(6) {
    animation-delay: 0.4s;
}

.sparkle {
    display: inline-block;
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.animate-badge-pulse {
    --pulse-color: var(--bs-primary-rgb);
    animation: badge-pulse 2s infinite;
}

@keyframes badge-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--pulse-color), 0.3);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 3px rgba(var(--pulse-color), 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--pulse-color), 0);
    }
}

/* ── Text contrast fixes ──────────────────────────── */
.text-muted {
    color: #5a6268 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #adb5bd !important;
}

/* ── Badges Center Fix ────────────────────────────── */
.badge {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

/* ── Layout Styles ────────────────────────────── */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #f8f9fa;
    /* Light mode background */
}

main {
    flex: 1;
}

.footer {
    background-color: #ffffff;
    border-top: 1px solid #dee2e6;
    padding: 1rem 0;
}

/* Dark mode styles */
[data-bs-theme="dark"] body {
    background-color: #1a1d20;
}

[data-bs-theme="dark"] .footer {
    background-color: #212529;
    border-top-color: #495057;
}

[data-bs-theme="dark"] .bg-light {
    background-color: #343a40 !important;
    color: #f8f9fa !important;
}

[data-bs-theme="dark"] .text-dark {
    color: #f8f9fa !important;
}

[data-bs-theme="dark"] i.bi {
    color: #ffffff !important;
}

#htmx-progress {
    height: 3px;
    border-radius: 0;
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 2000;
    background-color: rgba(0, 0, 0, 0.05);
    pointer-events: none;
}

#htmx-progress .progress-bar {
    width: 40%;
    background-color: #212529;
    /* Dark in light mode */
    animation: progress-indeterminate 1.5s ease-in-out infinite;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.2);
    position: absolute;
    height: 100%;
}

[data-bs-theme="dark"] #htmx-progress {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] #htmx-progress .progress-bar {
    background-color: #ffffff;
    /* White in dark mode */
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

@keyframes progress-indeterminate {
    0% {
        left: -40%;
    }

    100% {
        left: 100%;
    }
}

/* ── Premium App Selector Dropdown ────────────────── */
.app-selector-btn {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--bs-body-color);
    font-weight: 500;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    transition: all 0.2s ease;
}

.app-selector-btn:hover, .app-selector-btn:focus, .show > .app-selector-btn {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.15);
    color: var(--bs-body-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .app-selector-btn {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .app-selector-btn:hover, [data-bs-theme="dark"] .app-selector-btn:focus, [data-bs-theme="dark"] .show > .app-selector-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Make dropdown menu style align with premium feel */
.dropdown-menu {
    border-radius: 12px;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

[data-bs-theme="dark"] .dropdown-menu {
    background: rgba(33, 37, 41, 0.95);
}

.dropdown-item {
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.dropdown-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.07);
}

.dropdown-item.active, .dropdown-item:active {
    background-color: var(--bs-primary) !important;
    color: #fff !important;
}

/* ── Responsive Width Helpers (Custom addition) ── */
@media (min-width: 576px) {
    .w-sm-auto {
        width: auto !important;
    }
    .w-sm-25 {
        width: 25% !important;
    }
    .w-sm-50 {
        width: 50% !important;
    }
    .w-sm-75 {
        width: 75% !important;
    }
    .w-sm-100 {
        width: 100% !important;
    }
}

@media (min-width: 768px) {
    .w-md-auto {
        width: auto !important;
    }
    .w-md-25 {
        width: 25% !important;
    }
    .w-md-50 {
        width: 50% !important;
    }
    .w-md-75 {
        width: 75% !important;
    }
    .w-md-100 {
        width: 100% !important;
    }
}

/* ── HTMX Indicator Helpers ─────────────────────── */
.htmx-indicator {
    display: none !important;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block !important;
}

.htmx-request .htmx-hide-on-request,
.htmx-request.htmx-hide-on-request {
    display: none !important;
}