/* Splash Screen */
.splash-screen {
  position: fixed;
  inset: 0;
  background: #F5D000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-screen img {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.splash-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.splash-title .black { color: #1A1A1A; }
.splash-title .red { color: #DC2626; }

.splash-version {
  margin-top: 8px;
  font-size: 0.85rem;
  color: rgba(0,0,0,0.45);
  font-weight: 500;
}

.splash-developer {
  margin-top: 6px;
  font-size: 0.75rem;
  color: rgba(0,0,0,0.35);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #3D5A80;
  --primary-dark: #2B4162;
  --primary-light: #EDF2F7;
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --text: #2D3748;
  --text-light: #718096;
  --border: #E2E8F0;
  --success: #2A9D8F;
  --danger: #DC2626;
  --warning: #E9C46A;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

html { font-size: 18px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 80px;
  -webkit-tap-highlight-color: transparent;
}

/* Top Header */
.top-header {
  background: var(--primary);
  color: #fff;
  text-align: center;
  padding: 14px 16px;
  font-size: 1.2rem;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  display: flex;
  border-top: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
}

.bottom-nav .nav-item {
  flex: 1;
  text-align: center;
  padding: 6px 0 8px;
  font-size: 0.6rem;
  color: var(--text-light);
  cursor: pointer;
  transition: color 0.2s;
  border: none;
  background: none;
  min-height: 56px;
  min-width: 0;
}

.bottom-nav .nav-item.active {
  color: var(--primary);
}

.bottom-nav .nav-item .nav-icon {
  font-size: 1.3rem;
  display: block;
  margin-bottom: 1px;
}

/* Home Quick Menu Grid */
.home-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.home-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 8px;
  background: var(--primary-light);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary-dark);
  transition: background 0.2s;
}

.home-quick-btn:active {
  background: #D4E1F0;
}

.home-quick-icon {
  font-size: 1.5rem;
}

/* Page Sections */
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* Cards */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

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

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

input[type="text"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
}

textarea { resize: vertical; min-height: 60px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  gap: 6px;
  min-height: 48px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}
.btn-primary:active { background: var(--primary-dark); }

.btn-success {
  background: var(--success);
  color: #fff;
  width: 100%;
}

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

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

.btn-sm {
  padding: 10px 16px;
  font-size: 0.9rem;
  min-height: 44px;
}

.btn-block { width: 100%; }

/* Toggle Button Group */
.btn-group {
  display: flex;
  gap: 8px;
}

.btn-group .btn-toggle {
  flex: 1;
  padding: 12px 8px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text-light);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  min-height: 46px;
}

.btn-group .btn-toggle.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Voice Button */
.voice-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 2.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 20px auto;
  box-shadow: 0 4px 16px rgba(61,90,128,0.35);
  transition: all 0.2s;
}

.voice-btn:active {
  transform: scale(0.95);
}

.voice-btn.recording {
  background: var(--danger);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,111,81,0.4); }
  50% { box-shadow: 0 0 0 16px rgba(231,111,81,0); }
}

/* Menu Item Row */
.menu-item-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.menu-item-row select { flex: 2; }
.menu-item-row input { flex: 1; }
.custom-menu-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.custom-menu-row input { flex: 1; }
.custom-menu-row .btn-remove {
  width: 40px;
  height: 44px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

.menu-item-row .btn-remove {
  width: 40px;
  height: 44px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1.2rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  background: var(--primary-light);
  padding: 10px 6px;
  text-align: center;
  font-weight: 600;
  color: var(--primary-dark);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.data-table tr:active { background: var(--primary-light); }

/* List Items */
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.list-item .item-info {
  flex: 1;
}

.list-item .item-info .item-name {
  font-weight: 600;
  font-size: 1rem;
}

.list-item .item-info .item-sub {
  font-size: 0.83rem;
  color: var(--text-light);
  margin-top: 2px;
}

.list-item .item-actions {
  display: flex;
  gap: 6px;
}

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-paid { background: #E8F0FE; color: #1A56DB; }
.badge-unpaid { background: #FEE8E8; color: #C81E1E; }
.badge-receipt { background: #E3F2FD; color: #1565C0; }

/* Section Title */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

/* Divider */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Amount Display */
.total-amount {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  text-align: right;
  padding: 12px 0;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.modal-actions .btn { flex: 1; }

/* Settlement Preview */
.settlement-preview {
  background: #FAFAFA;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.9rem;
  line-height: 1.8;
}

/* Search Box */
.search-box {
  position: relative;
  margin-bottom: 12px;
}

.search-box input {
  padding-left: 40px;
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 1.1rem;
}

/* Filter Row */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-row > * { flex: 1; }

/* Toast */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  color: #333;
  border: 2px solid #3D5A80;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 0.85rem;
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* Scrollable Table Wrapper */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Dashboard Cards */
.dashboard-cards {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.dash-card {
  flex: 1;
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}

.dash-card .dash-label {
  font-size: 0.83rem;
  font-weight: 600;
  margin-bottom: 6px;
  opacity: 0.9;
}

.dash-card .dash-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.dash-total {
  background: linear-gradient(135deg, #3D5A80, #2B4162);
  color: #fff;
}

.dash-paid {
  background: linear-gradient(135deg, #3B82F6, #1D4ED8);
  color: #fff;
}

.dash-unpaid {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: #fff;
}

/* month input styling */
input[type="month"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.2s;
}

input[type="month"]:focus {
  border-color: var(--primary);
}

/* Utility */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Voice Preview Cards */
.voice-result-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--primary-light);
  border-radius: 8px;
}

.voice-result-item .voice-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-light);
}

.voice-result-item .voice-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* ── AI Chat ── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  background: var(--bg);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--card);
  border-bottom: 1px solid #E2E8F0;
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-tts-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-tts-toggle.off {
  border-color: #CBD5E1;
  background: #F1F5F9;
  color: var(--text-light);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  display: flex;
  max-width: 85%;
}

.chat-msg.user {
  align-self: flex-end;
}

.chat-msg.bot {
  align-self: flex-start;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg.bot .chat-bubble {
  background: var(--card);
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-top: 1px solid #E2E8F0;
}

.chat-input-bar input {
  flex: 1;
  border: 1.5px solid #E2E8F0;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9rem;
  outline: none;
  background: var(--bg);
}

.chat-input-bar input:focus {
  border-color: var(--primary);
}

.chat-voice-btn,
.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-voice-btn {
  background: var(--bg);
  color: var(--text-light);
}

.chat-voice-btn.recording {
  background: var(--danger);
  color: #fff;
  animation: pulse 1.5s infinite;
}

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

.chat-send-btn:active {
  opacity: 0.8;
}

/* Chat data display */
.chat-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-top: 8px;
}

.chat-data-table th,
.chat-data-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #E2E8F0;
  text-align: left;
}

.chat-data-table th {
  background: var(--primary-light);
  font-weight: 600;
  font-size: 0.75rem;
}

.chat-confirm-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chat-confirm-btns button {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.chat-confirm-btns .btn-yes {
  background: var(--primary);
  color: #fff;
}

.chat-confirm-btns .btn-no {
  background: #E2E8F0;
  color: var(--text);
}

.chat-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}
