/* ============================================================
   FinAI — Mobile-First Responsive Styles
   ============================================================ */

html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.nav-item.active { background: rgba(99,102,241,0.25); color: #a5b4fc; }
.mode-btn.active { background: white; color: #4f46e5; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }

.card {
  background: white;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-hover:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); transition: box-shadow 0.2s; }

.stat-card {
  background: white;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  padding: 1rem;
}

.badge {
  display: inline-flex; align-items: center;
  padding: 0.125rem 0.5rem; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 500;
}
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray { background: #f1f5f9; color: #475569; }

.progress-bar { height: 0.5rem; background: #e2e8f0; border-radius: 9999px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 9999px; transition: width 0.5s ease; }

.chat-user { background: #4f46e5; color: white; border-radius: 1rem 1rem 0.25rem 1rem; }
.chat-ai { background: #f1f5f9; color: #1e293b; border-radius: 1rem 1rem 1rem 0.25rem; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.slide-up { animation: slideUp 0.35s ease; }

.score-ring { position: relative; width: 88px; height: 88px; }
.score-ring svg { transform: rotate(-90deg); }
.score-ring .score-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  min-width: 520px;
}
table.data-table th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  white-space: nowrap;
  font-size: 0.75rem;
}
table.data-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.data-table tr:active td { background: #f1f5f9; }

/* Modal — bottom sheet on mobile */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.5);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-box {
  background: white;
  border-radius: 1.25rem 1.25rem 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
  -webkit-overflow-scrolling: touch;
}
.modal-box::before {
  content: '';
  display: block;
  width: 40px; height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  margin: 0.6rem auto 0.25rem;
}

/* Prevent iOS zoom on inputs */
input, select, textarea, button {
  font-size: 16px !important;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.35);
  border-color: #818cf8;
}

.empty-state { text-align: center; padding: 2.5rem 1rem; color: #94a3b8; }

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 15px rgba(0,0,0,0.12);
  animation: slideUp 0.3s ease;
  max-width: calc(100vw - 2rem);
}
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-info { background: #4f46e5; }

.chart-container { position: relative; height: 200px; }

/* ========== BOTTOM NAV ========== */
#bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
#bottom-nav .bn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.4rem 0.25rem;
  color: #94a3b8;
  font-size: 0.65rem;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  min-height: 52px;
  transition: color 0.15s;
}
#bottom-nav .bn-item i { font-size: 1.15rem; }
#bottom-nav .bn-item.active { color: #4f46e5; }
#bottom-nav .bn-item.bn-add .bn-fab {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(79,70,229,0.4);
  margin-top: -18px;
  border: 3px solid white;
}

@media (max-width: 1023px) {
  #bottom-nav { display: flex; }
  #main-content {
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)) !important;
  }
  #toast-container {
    bottom: calc(4.5rem + env(safe-area-inset-bottom)) !important;
    right: 1rem !important;
    left: 1rem !important;
  }
  header .mode-btn { padding: 0.35rem 0.65rem; font-size: 0.75rem; }
  .stat-card { padding: 0.85rem; }
  .stat-card .text-2xl { font-size: 1.25rem !important; }
  .score-ring { width: 76px; height: 76px; }
  .chart-container { height: 180px; }
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 1rem;
  }
  .modal-box {
    border-radius: 1.25rem;
    max-width: 32rem;
    max-height: 90vh;
  }
  .modal-box::before { display: none; }
  table.data-table { font-size: 0.875rem; min-width: 0; }
  table.data-table th, table.data-table td { padding: 0.75rem 1rem; }
  .chart-container { height: 220px; }
  .score-ring { width: 100px; height: 100px; }
}

@media (min-width: 1024px) {
  #bottom-nav { display: none !important; }
  #main-content { padding-bottom: 1.5rem !important; }
  #toast-container {
    bottom: 1rem !important;
    right: 1rem !important;
    left: auto !important;
  }
}

@media (max-width: 1023px) {
  
}

@media print {
  #sidebar, header, #bottom-nav, #quick-add-btn, #notif-btn { display: none !important; }
  .lg\:ml-64 { margin-left: 0 !important; }
}
