/* IntelliLotto Admin - 與主站風格一致 */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --text: #1a1a1a;
    --text-muted: #666;
    --bg: #fff;
    --bg-alt: #f5f5f5;
    --bg-hover: #fafafa;
    --border: #e5e5e5;
    --accent: #6366F1;
    --accent-dark: #4F46E5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

[data-theme="dark"] {
    --text: #f5f5f5;
    --text-muted: #999;
    --bg: #0a0a0a;
    --bg-alt: #141414;
    --bg-hover: #1a1a1a;
    --border: #2a2a2a;
}

body {
    font-family: 'Noto Sans TC', -apple-system, sans-serif;
    background: var(--bg-alt);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-width: 1200px;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ========================================
   LAYOUT
   ======================================== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* 側邊欄 */
.sidebar {
    width: 240px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.sidebar-header span {
    font-weight: 700;
    font-size: 16px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 4px;
}

.nav-link:hover {
    background: var(--bg-alt);
    color: var(--text);
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* 主內容 */
.main {
    flex: 1;
    margin-left: 240px;
}

.topbar {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 20px;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content {
    padding: 24px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-secondary {
    background: var(--bg-alt);
    border-color: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    border-color: var(--danger);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header svg {
    width: 18px;
    height: 18px;
    fill: var(--accent);
}

.card-body {
    padding: 20px;
}

/* 統計卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.15s;
}

.stat-card:hover {
    border-color: var(--accent);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.primary { background: #eef2ff; }
.stat-icon.primary svg { fill: var(--accent); }
.stat-icon.warning { background: #fef3c7; }
.stat-icon.warning svg { fill: var(--warning); }
.stat-icon.success { background: #d1fae5; }
.stat-icon.success svg { fill: var(--success); }
.stat-icon.info { background: #dbeafe; }
.stat-icon.info svg { fill: var(--info); }

[data-theme="dark"] .stat-icon.primary { background: rgba(99, 102, 241, 0.15); }
[data-theme="dark"] .stat-icon.warning { background: rgba(245, 158, 11, 0.15); }
[data-theme="dark"] .stat-icon.success { background: rgba(16, 185, 129, 0.15); }
[data-theme="dark"] .stat-icon.info { background: rgba(59, 130, 246, 0.15); }

/* ========================================
   FORMS
   ======================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    transition: all 0.15s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.input-group {
    display: flex;
}

.input-icon {
    padding: 10px 14px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 10px 0 0 10px;
    display: flex;
    align-items: center;
}

.input-icon svg {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
}

.input-group .form-input {
    border-radius: 0 10px 10px 0;
}

/* ========================================
   TABLES
   ======================================== */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
}

.table th {
    background: var(--bg-alt);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.table td {
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ========================================
   BADGES
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
}

.badge-primary {
    background: #eef2ff;
    color: var(--accent);
}

.badge-success {
    background: #d1fae5;
    color: #059669;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

[data-theme="dark"] .badge-primary { background: rgba(99, 102, 241, 0.15); }
[data-theme="dark"] .badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
[data-theme="dark"] .badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg);
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    border: 1px solid var(--border);
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-alt);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--border);
}

.modal-close svg {
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ========================================
   ALERT
   ======================================== */
.alert {
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 14px;
    display: none;
}

.alert.show {
    display: block;
}

.alert-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

[data-theme="dark"] .alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-alt);
}

.login-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    position: relative;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    margin: 0 auto 16px;
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 14px;
    color: var(--text-muted);
}

.login-card .theme-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
}

/* ========================================
   THEME TOGGLE
   ======================================== */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    transition: all 0.15s;
    font-family: inherit;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ========================================
   GRIDS
   ======================================== */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.row {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.row > * {
    flex: 1;
}

/* ========================================
   STATUS GRID
   ======================================== */
.status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: 12px;
}

.status-item .stat-icon {
    width: 44px;
    height: 44px;
}

.status-item .stat-icon svg {
    width: 20px;
    height: 20px;
}

.status-info {
    font-size: 14px;
    font-weight: 600;
}

.status-info small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========================================
   USER AVATAR
   ======================================== */
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    font-size: 14px;
}

.user-info small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

/* ========================================
   NUMBER BALLS
   ======================================== */
.number-balls {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.number-ball {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-ball.special {
    background: linear-gradient(135deg, var(--warning), #d97706);
}

/* ========================================
   FILTERS
   ======================================== */
.filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.filters .form-group {
    margin-bottom: 0;
    flex: 1;
}

.filters .btn {
    flex-shrink: 0;
}

/* ========================================
   SPINNER
   ======================================== */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn svg {
    transition: none;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    fill: var(--border);
    margin-bottom: 16px;
}

/* ========================================
   CHART CONTAINER
   ======================================== */
.chart-container {
    position: relative;
    height: 260px;
}

/* ========================================
   AI STATS
   ======================================== */
.ai-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.ai-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-alt);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.15s;
}

.ai-stat:hover {
    border-color: var(--accent);
}

.ai-stat img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.ai-stat-info {
    flex: 1;
}

.ai-stat-name {
    font-size: 14px;
    font-weight: 600;
}

.ai-stat-count {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
}

/* ========================================
   UTILITIES
   ======================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.hidden { display: none !important; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
