/* ========================================
   YiKount 🦞 - Multi-Event Expense Splitter
   Dark Gaming Theme
   ======================================== */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #1f1f35;
  --bg-modal: #16162a;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --accent-glow: rgba(233, 69, 96, 0.3);
  --neon-blue: #0f3460;
  --neon-blue-light: #16213e;
  --neon-cyan: #00d2ff;
  --neon-green: #00ff88;
  --neon-yellow: #ffd700;
  --neon-purple: #a855f7;
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --border: #2a2a44;
  --border-focus: #e94560;
  --danger: #ff4444;
  --danger-hover: #ff6666;
  --success: #00cc66;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --transition: 0.2s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: linear-gradient(180deg, rgba(233, 69, 96, 0.08) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding-bottom: 100px;
}

/* Header */
.header {
  padding: 24px 20px 16px;
  text-align: center;
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.logo {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #e94560, #ff6b81, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(233, 69, 96, 0.3));
}

.subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--neon-cyan);
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-top: 4px;
  text-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
}

/* Event Selector Bar */
.event-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  position: relative;
}

.event-select {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238888aa'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.event-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.event-select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px;
}

.event-select optgroup {
  color: var(--text-muted);
  font-style: normal;
  font-weight: 500;
}

.btn-accent {
  background: var(--accent);
  color: white;
  font-weight: 700;
  white-space: nowrap;
}

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

.event-menu-btn {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.event-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 16px;
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  z-index: 200;
  min-width: 200px;
  box-shadow: var(--shadow);
}

.event-menu.open {
  display: block;
  animation: fadeIn 0.15s ease;
}

.event-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}

.event-menu button:hover {
  background: var(--bg-card-hover);
}

.event-menu button.danger {
  color: var(--danger);
}

.event-menu button.danger:hover {
  background: rgba(255, 68, 68, 0.1);
}

/* Finalized Banner */
.finalized-banner {
  margin: 0 16px 4px;
  padding: 10px 16px;
  background: rgba(0, 204, 102, 0.1);
  border: 1px solid rgba(0, 204, 102, 0.3);
  border-radius: var(--radius-sm);
  color: var(--neon-green);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

/* Navigation Tabs */
.tabs {
  display: flex;
  padding: 12px 16px;
  gap: 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-icon {
  font-size: 1.2rem;
}

.tab.active {
  background: linear-gradient(135deg, var(--accent), #c73a52);
  border-color: var(--accent);
  color: white;
  box-shadow: var(--shadow-glow);
}

.tab:not(.active):active {
  transform: scale(0.96);
}

/* Content */
.content {
  padding: 0 16px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0;
}

.section-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #c73a52);
  color: white;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 1rem;
}

.btn-add span {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Expenses List */
.expenses-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.expense-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.expense-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.expense-card.finalized::before {
  background: var(--neon-green);
}

.expense-card:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.expense-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.expense-concept {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.expense-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--neon-green);
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
  white-space: nowrap;
  margin-left: 12px;
}

.expense-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.expense-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.expense-participants {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.participant-chip {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--neon-blue);
  color: var(--neon-cyan);
  font-weight: 500;
}

.expense-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-icon.delete:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Balances */
.balance-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}

.total-spent {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--neon-green);
  text-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
}

.total-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.balance-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 20px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.balance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.balance-person {
  font-weight: 600;
  font-size: 0.95rem;
}

.balance-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 1rem;
}

.balance-positive { color: var(--neon-green); }
.balance-negative { color: var(--danger); }
.balance-zero { color: var(--text-muted); }

.transfer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.transfer-arrow {
  color: var(--accent);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.transfer-from {
  font-weight: 600;
  color: var(--danger);
  min-width: 60px;
}

.transfer-to {
  font-weight: 600;
  color: var(--neon-green);
  min-width: 60px;
}

.transfer-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
  margin-left: auto;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.person-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.person-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.person-stat-name {
  font-weight: 600;
  font-size: 1rem;
}

.person-stat-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--neon-cyan);
}

.person-stat-bar {
  height: 6px;
  background: var(--neon-blue);
  border-radius: 3px;
  overflow: hidden;
}

.person-stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--neon-purple));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.person-stat-details {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 16px;
  overflow-y: auto;
  align-items: flex-start;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  margin-top: 40px;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

.modal-sm {
  max-width: 360px;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  transition: all var(--transition);
}

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

/* Form */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  transition: all var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* Radio & Checkbox Grids */
.radio-grid, .checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.radio-grid label, .checkbox-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--transition);
  color: var(--text-primary);
  margin-bottom: 0;
}

.radio-grid input, .checkbox-grid input {
  display: none;
}

.radio-grid label:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: var(--shadow-glow);
}

.checkbox-grid label:has(input:checked) {
  background: var(--neon-blue);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.2);
}

.radio-grid label:active, .checkbox-grid label:active {
  transform: scale(0.95);
}

.participants-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.delete-text {
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.delete-detail {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Loading & Empty */
.loading, .empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--success);
  color: white;
}

.toast.error {
  background: var(--danger);
  color: white;
}

/* No expenses */
.no-expenses {
  text-align: center;
  padding: 60px 20px;
}

.no-expenses .empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.no-expenses p {
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Date input color fix for dark mode */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
}

/* Responsive */
@media (max-width: 360px) {
  .radio-grid, .checkbox-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
}
