/* ============================================
   iOS App Analytics — 樣式表
   ============================================ */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --success: #22c55e;
  --danger: #ef4444;
  --danger-hover: #f87171;
  --warning: #f59e0b;
  --border: #334155;
  --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }
a { color: var(--primary-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: var(--bg-card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.nav-brand { font-size: 1.2em; font-weight: 700; }
.nav-icon { margin-right: 6px; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: var(--text-muted); padding: 6px 12px; border-radius: var(--radius); transition: background .2s; }
.nav-links a:hover, .nav-links a.active { background: var(--bg-hover); color: var(--text); text-decoration: none; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.card h2 { font-size: 1.2em; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card h2 .btn { margin-left: auto; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-grid.small { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; text-align: center; transition: transform .2s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 1.8em; margin-bottom: 8px; }
.stat-value { font-size: 2em; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 0.85em; color: var(--text-muted); }
.stat-blue { border-left: 3px solid #3b82f6; }
.stat-green { border-left: 3px solid #22c55e; }
.stat-purple { border-left: 3px solid #a855f7; }
.stat-teal { border-left: 3px solid #14b8a6; }
.stat-red { border-left: 3px solid #ef4444; }
.stat-orange { border-left: 3px solid #f97316; }
.stat-yellow { border-left: 3px solid #eab308; }
.stat-pink { border-left: 3px solid #ec4899; }

/* Tables */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.data-table th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 600; border-bottom: 2px solid var(--border); color: var(--text-muted); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover { background: var(--bg-hover); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); font-size: 0.85em; }
.text-center { text-align: center; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--bg); border: 1px solid var(--border); font-size: 0.8em; }
.user-link { font-weight: 600; }
.user-link:hover { text-decoration: underline; }

/* Status badges */
.status-badge { padding: 2px 8px; border-radius: 4px; font-size: 0.8em; font-weight: 600; }
.status-active { background: rgba(34,197,94,0.15); color: #4ade80; }
.status-completed { background: rgba(59,130,246,0.15); color: #60a5fa; }
.status-abandoned { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* Session cards */
.session-list { display: flex; flex-direction: column; gap: 12px; }
.session-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.session-card.compact { padding: 12px; }
.session-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.session-user { font-weight: 600; }
.session-status { padding: 2px 8px; border-radius: 4px; font-size: 0.8em; font-weight: 600; }
.status-completed { background: rgba(34,197,94,0.15); color: #4ade80; }
.status-failed { background: rgba(239,68,68,0.15); color: #f87171; }
.status-queued { background: rgba(245,158,11,0.15); color: #fbbf24; }
.status-active { background: rgba(59,130,246,0.15); color: #60a5fa; }
.session-body { font-size: 0.9em; }
.session-query { margin-bottom: 4px; color: #cbd5e1; }
.session-response { color: var(--text-muted); }
.session-query strong, .session-response strong { color: var(--text); }

/* Bar chart */
.bar-chart { margin-top: 16px; }
.bar-group { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.bar-label { width: 40px; text-align: right; font-size: 0.8em; color: var(--text-muted); }
.bar-wrapper { flex: 1; height: 20px; background: var(--bg); border-radius: 4px; position: relative; overflow: hidden; }
.bar { position: absolute; height: 100%; border-radius: 4px; transition: width .3s; }
.bar-success { background: var(--success); opacity: 0.7; }
.bar-failed { background: var(--danger); opacity: 0.7; }
.bar-count { width: 30px; font-size: 0.8em; color: var(--text-muted); }

/* Progress bar */
.progress-bar { width: 100%; height: 22px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); color: white; font-size: 0.75em; display: flex; align-items: center; justify-content: center; min-width: 32px; transition: width .3s; }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: var(--radius); cursor: pointer; font-size: 0.9em; font-weight: 600; transition: all .2s; display: inline-flex; align-items: center; gap: 4px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text); }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 4px 10px; font-size: 0.8em; }
.btn-block { width: 100%; justify-content: center; }

/* Inline form */
.inline-form { display: flex; gap: 8px; align-items: center; margin: 12px 0; padding: 12px; background: var(--bg); border-radius: var(--radius); flex-wrap: wrap; }
.inline-form input, .inline-form select { padding: 6px 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 0.9em; }
.inline-form input:focus, .inline-form select:focus { outline: none; border-color: var(--primary); }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-item label { font-size: 0.8em; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.detail-item span { font-size: 1em; }
.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85em; word-break: break-all; }

/* Danger zone */
.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }

/* Modal */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-content { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 460px; width: 90%; z-index: 1; }
.modal-content h3 { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 12px; margin-top: 20px; justify-content: flex-end; }

/* Login page */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-container { width: 100%; max-width: 400px; padding: 24px; }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 32px; }
.login-header { text-align: center; margin-bottom: 32px; }
.login-icon { font-size: 3em; display: block; margin-bottom: 12px; }
.login-header h1 { font-size: 1.5em; margin-bottom: 4px; }
.login-header p { color: var(--text-muted); font-size: 0.9em; }
.login-form .form-group { margin-bottom: 20px; }
.login-form label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9em; }
.login-form input { width: 100%; padding: 12px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-size: 1em; }
.login-form input:focus { outline: none; border-color: var(--primary); }

/* Alert */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.alert-error { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 1.5em; }
  .navbar { padding: 10px 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
}
