/* ScratchOff Analytics - Custom CSS */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%) !important;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
    padding: 0.75rem 1rem;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    color: #fff !important;
}

.navbar-brand .brand-icon {
    font-size: 1.5rem;
    margin-right: 8px;
}

.navbar-nav .nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.15);
}

/* Main content */
main {
    padding: 2rem 0;
    min-height: calc(100vh - 120px);
}

/* Cards */
.card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: 0 4px 7px -1px rgba(0,0,0,0.08);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.25rem;
}

/* Stat cards */
.stat-card {
    border-radius: 0.375rem;
    padding: 1.25rem;
    border: none;
    color: white;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
}

.stat-card.primary   { background: #2563eb !important; }
.stat-card.success   { background: #16a34a !important; }
.stat-card.warning   { background: #f59e0b !important; color: #1e293b; }
.stat-card.danger    { background: #dc2626 !important; }
.stat-card.info      { background: #06b6d4 !important; }
.stat-card.secondary { background: #64748b !important; }

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

.stat-card .stat-label {
    font-size: 0.90rem;
    opacity: 0.85;
    margin-top: 4px;
}

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.25;
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
}

/* Health score badges */
.health-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* Use Bootstrap badge colors for health-badge if needed */

.health-excellent { background: #dcfce7; color: #166534; }
.health-good      { background: #dbeafe; color: #1d4ed8; }
.health-fair      { background: #fef9c3; color: #854d0e; }
.health-poor      { background: #fee2e2; color: #991b1b; }

/* Rank badges */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.85rem;
    background: var(--primary);
    color: white;
}

.rank-badge.rank-1 { background: #f59e0b; }
.rank-badge.rank-2 { background: #94a3b8; }
.rank-badge.rank-3 { background: #b45309; }

/* Tables */
.table {
    font-size: 0.93rem;
    border-color: #dee2e6;
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.76rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e9ecef;
}

.table td {
    vertical-align: middle;
    border-color: #dee2e6;
}

.table-hover tbody tr:hover {
    background-color: #eaf2fb;
}

/* Alert severity colors */
.alert-severity-success { border-left: 4px solid var(--success); }
.alert-severity-warning { border-left: 4px solid var(--warning); }
.alert-severity-danger  { border-left: 4px solid var(--danger); }
.alert-severity-info    { border-left: 4px solid var(--info); }

/* Progress bars */
.progress {
    height: 8px;
    border-radius: 4px;
    background: #e9ecef; /* Bootstrap default light color */
}

.progress-bar {
    border-radius: 4px;
    /* Remove custom colors, use Bootstrap .bg-* in markup if needed */
}

/* Charts */
.chart-container {
    position: relative;
    min-height: 220px;
    min-width: 100%;
    padding-bottom: 1rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
}

/* Badges */
.badge {
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 0.35em 0.65em;
    border-radius: 0.375rem;
    /* Use Bootstrap badge sizing/shape */
}

/* Game cards on dashboard */
.game-row {
    transition: background 0.15s;
}

.game-row:hover {
    background: #f0f7ff;
}

.game-name {
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.game-name:hover {
    text-decoration: underline;
}

/* Alert items */
.alert-item {
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: white;
    border: 1px solid var(--border);
}

.alert-item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.alert-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Footer */
footer {
    background: #1e293b;
    color: rgba(255,255,255,0.6);
    padding: 1.5rem 0;
    margin-top: 3rem;
    font-size: 0.85rem;
}

footer a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
}

footer a:hover {
    color: white;
}


/* Daily Digest expand/collapse — 9rem shows ~4 lines before the fade */
.digest-preview {
    max-height: 9rem;
    overflow: hidden;
    position: relative;
}
.digest-preview::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3rem;
    background: linear-gradient(transparent, var(--card-bg, #fff));
    pointer-events: none;
}
.digest-preview.expanded {
    max-height: none;
    overflow: visible;
}
.digest-preview.expanded::after {
    display: none;
}

/* Ask AI */
.ask-bubble {
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    max-width: 85%;
}

.ask-bubble.user {
    background: var(--primary);
    color: white;
    margin-left: auto;
}

.ask-bubble.ai {
    background: #f1f5f9;
    border: 1px solid var(--border);
}

/* Settings */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section h5 {
    color: var(--secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .stat-card .stat-value { font-size: 1.25rem; }
    .chart-container { min-height: 140px; }
    main { padding: 1rem 0; }
}

/* Collapsible card section toggle */
.collapse-toggle-btn {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
}
.collapse-toggle-btn:hover { color: var(--text); }
.collapse-toggle-btn .bi-chevron-up,
.collapse-toggle-btn[aria-expanded="false"] .bi-chevron-up { display: none; }
.collapse-toggle-btn[aria-expanded="true"] .bi-chevron-up  { display: inline; }
.collapse-toggle-btn[aria-expanded="false"] .bi-chevron-down { display: inline; }
.collapse-toggle-btn[aria-expanded="true"] .bi-chevron-down  { display: none; }

/* AI review notes — normalize aggressive all-caps AI output */
.ai-review-notes { text-transform: none; }

/* Secondary metrics row — dimmer to signal lower priority */
.metrics-secondary .stat-card .stat-value { font-size: 1.1rem; }

/* Extended metrics grid — always stretch to fill row */
.extended-metrics-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.extended-metrics-row > div { flex: 1 1 150px; min-width: 0; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: 0.85rem; }
.gap-2 { gap: 0.5rem; }

/* Loading spinner */
.spinner-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

/* Trend arrows */
.trend-up   { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--text-muted); }

/* Prize tier table */
.prize-tier-top {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    font-weight: 700;
}

.prize-tier-top td:first-child::before {
    content: '🏆 ';
}

/* Mobile bottom tab bar */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    background: #fff;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: space-around;
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.65rem;
    color: #6c757d;
    text-decoration: none;
    flex: 1;
    gap: 2px;
}

.mobile-nav-item i {
    font-size: 1.3rem;
}

.mobile-nav-item.active {
    color: #2563eb;
}

@media (max-width: 767.98px) {
    main { padding-bottom: 72px; }
    footer { padding-bottom: 72px; }
}

/* ── Cron Log Viewer ─────────────────────────────────────────────────────── */

/* Status badges (icons included via PHP) — shared size via .log-badge */
.log-badge             { font-size: 0.78rem; }
.log-badge-ok          { background-color: #198754; color: #fff; }
.log-badge-warning     { background-color: #ffc107; color: #000; }
.log-badge-error       { background-color: #dc3545; color: #fff; }
.log-badge-timeout     { background-color: #6c757d; color: #fff; }

/* Left-border accent on the first cell and a subtle row tint.
   Use a more-specific selector (table row) to avoid needing !important. */
table .log-row-error   { background-color: rgba(220, 53, 69, 0.05); }
table .log-row-warning { background-color: rgba(255, 193, 7, 0.07); }
.log-row-error   > td:first-child { box-shadow: inset 4px 0 0 #dc3545; }
.log-row-warning > td:first-child { box-shadow: inset 4px 0 0 #ffc107; }
.log-row-timeout > td:first-child { box-shadow: inset 4px 0 0 #6c757d; }

/* Message cell – word-wrap instead of hard CSS truncation */
.log-msg { word-break: break-word; max-width: 320px; }

/* Relative-time sub-label shown below the absolute timestamp */
.log-ts-relative {
    display: block;
    font-size: 0.68rem;
    color: #94a3b8;
    margin-top: 1px;
    line-height: 1;
}

/* Details panel background */
.log-details-panel { background: #f8fafc; border-top: 1px solid #e9ecef; }

/* Metric chips grid */
.log-metrics-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.log-metric-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 0.4rem 0.85rem;
    text-align: center;
    min-width: 88px;
}
.log-metric-chip .metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}
.log-metric-chip .metric-label {
    font-size: 0.63rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* JSON code block – dark-themed for easy scanning */
.log-json {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.78rem;
    background: #1e293b;
    color: #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
    white-space: pre-wrap;
    word-break: break-all;
}
