/* ============================================================
   Lottery AI Prediction - Dark Theme + Glassmorphism
   ============================================================ */

/* ============ CSS VARIABLES ============ */
:root {
    --bg-base: #0a0e1a;
    --bg-surface: rgba(15, 23, 42, 0.8);
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --glass-border: rgba(148, 163, 184, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-orange: #f59e0b;
    --accent-red: #ef4444;
    --accent-pink: #ec4899;
    
    --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-warning: linear-gradient(135deg, #f59e0b, #ef4444);
    --gradient-mn: linear-gradient(135deg, #f59e0b, #ef4444);
    --gradient-mt: linear-gradient(135deg, #3b82f6, #06b6d4);
    --gradient-mb: linear-gradient(135deg, #8b5cf6, #ec4899);
}

/* ============ RESET & BASE ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated background gradients */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 50%);
    z-index: 0;
    pointer-events: none;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

/* ============ HEADER ============ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.header-left .logo { font-size: 1.5rem; }
.header-left h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.header-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: right;
}
.header-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-blue);
}
.header-btn {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
    font-family: inherit;
}
.header-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.header-btn.danger { color: var(--accent-red); }
.header-btn.danger:hover { background: rgba(239, 68, 68, 0.15); }

/* ============ MODEL BAR ============ */
.model-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(20px);
}
.model-bar label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.model-select {
    flex: 1;
    max-width: 320px;
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
}
.model-select option { background: #1e293b; }
.model-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}
.model-badge.top { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.date-picker-inline {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.date-input {
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    color-scheme: dark;
}
.btn-today {
    padding: 0.5rem 0.75rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-today:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Backtest indicator */
.backtest-indicator {
    display: none;
    padding: 0.4rem 0.75rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--accent-orange);
    font-weight: 500;
}
.backtest-indicator.show { display: flex; align-items: center; gap: 0.35rem; }

/* ============ REGION TABS ============ */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
    user-select: none;
}
.tab::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: transparent;
    transition: all 0.3s;
}
.tab:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* Tab active states by region color */
.tab.active-mn { 
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--accent-orange);
}
.tab.active-mn::before { background: var(--gradient-mn); }

.tab.active-mt { 
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--accent-blue);
}
.tab.active-mt::before { background: var(--gradient-mt); }

.tab.active-mb { 
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
    color: var(--accent-purple);
}
.tab.active-mb::before { background: var(--gradient-mb); }

.tab .tab-icon { font-size: 1.1rem; }
.tab .tab-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}
.tab .tab-wr {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
}
.tab .tab-wr.good { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.tab .tab-wr.ok { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }

/* ============ TAB CONTENT ============ */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.tab-content.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============ STATS BAR ============ */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.stat-item {
    padding: 0.85rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    text-align: center;
    backdrop-filter: blur(20px);
}
.stat-item .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}
.stat-item .stat-value {
    font-size: 1.3rem;
    font-weight: 800;
}
.stat-item .stat-value.green { color: var(--accent-green); }
.stat-item .stat-value.blue { color: var(--accent-blue); }
.stat-item .stat-value.orange { color: var(--accent-orange); }
.stat-item .stat-value.purple { color: var(--accent-purple); }
.stat-item .stat-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============ CONTENT GRID (2 cols) ============ */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(20px);
    transition: all 0.3s;
}
.card:hover { border-color: rgba(148, 163, 184, 0.2); }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
}
.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-body { padding: 1.25rem; }

/* ============ PREDICTION NUMBERS ============ */
.prediction-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.pred-num {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.6rem 0.9rem;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    min-width: 56px;
    transition: all 0.2s;
}
.pred-num:hover {
    transform: translateY(-2px);
    background: rgba(59, 130, 246, 0.15);
}
.pred-num .number {
    font-size: 1.4rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.pred-num .conf {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 500;
}
.pred-num.hit {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
}
.pred-num.hit .number {
    background: var(--gradient-success);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Prediction metadata grid */
.pred-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.pred-meta-item {
    padding: 0.5rem 0.75rem;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
}
.pred-meta-item .label {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.pred-meta-item .value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Verdict area */
.prediction-verdict {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 10px;
    text-align: center;
}
.prediction-verdict.skip {
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.2);
}
.prediction-verdict.lose {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.2);
}
.verdict-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}
.verdict-action {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.verdict-reason {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}
.verdict-confidence {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ============ RESULT CARD ============ */
.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.05);
}
.result-row:last-child { border-bottom: none; }
.result-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.result-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}
.result-value.highlight {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.1rem;
}

/* ============ BUTTONS ============ */
.btn-update {
    width: 100%;
    padding: 0.75rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.75rem;
    font-family: inherit;
}
.btn-update:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
}
.btn-update:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-update.mn { background: var(--gradient-mn); }
.btn-update.mn:hover { box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4); }
.btn-update.mt { background: var(--gradient-mt); }
.btn-update.mt:hover { box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4); }
.btn-update.mb { background: var(--gradient-mb); }
.btn-update.mb:hover { box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4); }

.btn-predict {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0.5rem;
    font-family: inherit;
}
.btn-predict.mn { background: var(--gradient-mn); }
.btn-predict.mt { background: var(--gradient-mt); }
.btn-predict.mb { background: var(--gradient-mb); }
.btn-predict:hover { transform: translateY(-1px); }
.btn-predict:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ============ STATUS BADGES ============ */
.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
}
.status-badge.pending { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }
.status-badge.win { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.status-badge.lose { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.status-badge.skip { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}
.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}
.empty-state p { font-size: 0.85rem; }

/* ============ HISTORY TABLE ============ */
.history-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    overflow: hidden;
    backdrop-filter: blur(20px);
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    flex-wrap: wrap;
    gap: 0.5rem;
}
.history-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
}
.history-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.filter-select {
    padding: 0.4rem 0.6rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: inherit;
}
.filter-select option { background: #1e293b; }

.history-actions {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
}

table {
    width: 100%;
    border-collapse: collapse;
}
th {
    padding: 0.7rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 1px solid var(--glass-border);
}
td {
    padding: 0.65rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(148, 163, 184, 0.05);
}
tr:hover td { background: rgba(59, 130, 246, 0.03); }
tr.win-row td { background: rgba(16, 185, 129, 0.03); }
tr.lose-row td { background: rgba(239, 68, 68, 0.03); }

.td-numbers { font-weight: 700; color: var(--text-primary); }
.td-win { color: var(--accent-green); font-weight: 600; }
.td-lose { color: var(--accent-red); }

.region-tag {
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
}
.region-tag.mn { background: rgba(245, 158, 11, 0.15); color: var(--accent-orange); }
.region-tag.mt { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.region-tag.mb { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

.btn-delete-row {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--accent-red);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}
.btn-delete-row:hover {
    background: rgba(239, 68, 68, 0.15);
}
.btn-delete-batch {
    padding: 0.4rem 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    color: var(--accent-red);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-delete-batch:hover { background: rgba(239, 68, 68, 0.2); }
.btn-delete-batch:disabled { opacity: 0.4; cursor: not-allowed; }

/* Model badge in table */
.model-tag {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-block;
}

/* ============ LOADING OVERLAY ============ */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ============ TOAST NOTIFICATIONS ============ */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    backdrop-filter: blur(20px);
    color: var(--text-primary);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease;
    max-width: 400px;
    box-shadow: var(--glass-shadow);
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.warning { border-left: 3px solid var(--accent-orange); }
.toast-icon { font-size: 1rem; }
.toast-message { flex: 1; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.3); }

/* ============ CHECKBOX ============ */
input[type="checkbox"] {
    accent-color: var(--accent-blue);
    width: 14px;
    height: 14px;
    cursor: pointer;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .content-grid { grid-template-columns: 1fr; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .model-bar { flex-wrap: wrap; }
    .date-picker-inline { margin-left: 0; width: 100%; }
    .header { flex-direction: column; gap: 0.75rem; }
    .tabs { flex-direction: column; }
    .history-header { flex-direction: column; align-items: flex-start; }
}
