/* ===================================================
   GST Invoice Management SaaS - Main Stylesheet
   Mobile App Style UI
   =================================================== */

:root {
  --primary: #667eea;
  --primary-dark: #764ba2;
  --secondary: #f093fb;
  --success: #0abe76;
  --danger: #fc5c7d;
  --warning: #f7b731;
  --info: #3498db;
  --dark: #1a1d2e;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  --card-radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.15);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: #f0f2f8;
  color: #2d3748;
  margin: 0;
  overflow-x: hidden;
}

/* ─── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

/* ─── Sidebar ────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--dark) 0%, #2d1b69 100%);
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: 4px 0 20px rgba(0,0,0,.2);
}

.sidebar-brand {
  padding: 20px;
  background: rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.sidebar-menu { padding: 15px 0; }

.sidebar-section-title {
  padding: 10px 20px 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.4);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all .2s;
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.sidebar-item.active {
  background: rgba(102,126,234,.2);
  color: #fff;
  border-left-color: var(--primary);
}

.sidebar-item .item-icon { font-size: 18px; flex-shrink: 0; }
.sidebar-item .badge { margin-left: auto; }

/* ─── Topbar ─────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 900;
  gap: 15px;
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
  padding: 5px;
  display: none;
}

.topbar-title { font-size: 18px; font-weight: 700; color: var(--dark); flex: 1; }
.topbar-title small { display: block; font-size: 12px; color: #999; font-weight: 400; }

.topbar-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  cursor: pointer;
}

/* ─── Main Content ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 25px;
  min-height: calc(100vh - var(--topbar-height));
}

/* ─── Cards ──────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  background: #fff;
  overflow: hidden;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #f0f2f8;
  padding: 18px 20px;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-body { padding: 20px; }

/* ─── Stat Cards ─────────────────────────────────── */
.stat-card {
  border-radius: var(--card-radius);
  padding: 22px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: transform .2s;
  cursor: default;
}

.stat-card:hover { transform: translateY(-3px); }
.stat-card .stat-bg { position: absolute; right: -20px; bottom: -20px; font-size: 80px; opacity: .15; }
.stat-card .stat-label { font-size: 13px; font-weight: 600; opacity: .85; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-card .stat-sub { font-size: 12px; opacity: .75; margin-top: 8px; }
.stat-card.grad-1 { background: linear-gradient(135deg, #667eea, #764ba2); }
.stat-card.grad-2 { background: linear-gradient(135deg, #f093fb, #f5576c); }
.stat-card.grad-3 { background: linear-gradient(135deg, #0abe76, #00b09b); }
.stat-card.grad-4 { background: linear-gradient(135deg, #f7b731, #f5631e); }
.stat-card.grad-5 { background: linear-gradient(135deg, #3498db, #2980b9); }
.stat-card.grad-6 { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }

/* ─── Forms ──────────────────────────────────────── */
.form-label { font-weight: 600; font-size: 14px; margin-bottom: 5px; color: #444; }
.form-control, .form-select {
  border-radius: 10px;
  border: 2px solid #e9ecef;
  padding: 10px 14px;
  font-size: 14px;
  transition: all .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102,126,234,.12);
  outline: none;
}
.input-group-text {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 10px 0 0 10px;
}
.input-group .form-control { border-radius: 0 10px 10px 0; }

/* ─── Buttons ────────────────────────────────────── */
.btn { border-radius: 10px; font-weight: 600; padding: 9px 20px; font-size: 14px; transition: all .2s; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border: none; }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(102,126,234,.4); }
.btn-success { background: linear-gradient(135deg, #0abe76, #00b09b); border: none; }
.btn-danger { background: linear-gradient(135deg, #fc5c7d, #f5365c); border: none; }
.btn-warning { background: linear-gradient(135deg, #f7b731, #f5631e); border: none; color: #fff; }
.btn-info { background: linear-gradient(135deg, #3498db, #2980b9); border: none; color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }

/* ─── Tables ─────────────────────────────────────── */
.table { font-size: 14px; }
.table thead th {
  background: #f8f9fa;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #888;
  border: none;
  padding: 12px 15px;
  white-space: nowrap;
}
.table tbody td { padding: 12px 15px; vertical-align: middle; border-color: #f0f2f8; }
.table tbody tr:hover { background: #f8f9fa; }
.table-responsive { border-radius: var(--card-radius); overflow: hidden; }

/* ─── Badges ─────────────────────────────────────── */
.badge { border-radius: 6px; font-weight: 600; padding: 4px 9px; font-size: 11px; }

/* ─── Invoice items ──────────────────────────────── */
.invoice-item-row { background: #f8f9fa; border-radius: 10px; padding: 15px; margin-bottom: 10px; }
.invoice-item-row .remove-item { cursor: pointer; color: var(--danger); }

/* ─── Banner ──────────────────────────────────────── */
.site-banner {
  border-radius: var(--card-radius);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.site-banner img { width: 100%; max-height: 120px; object-fit: cover; display: block; }

/* ─── Overlay ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* ─── Bottom nav (mobile) ────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e9ecef;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 800;
  box-shadow: 0 -4px 15px rgba(0,0,0,.1);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: #999;
  font-size: 10px;
  font-weight: 600;
  transition: color .2s;
  padding: 4px 0;
}
.bottom-nav-item .nav-icon { font-size: 22px; line-height: 1; }
.bottom-nav-item.active { color: var(--primary); }

/* ─── Loader ─────────────────────────────────────── */
.page-loader {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; transition: opacity .4s;
}
.page-loader .spinner {
  width: 50px; height: 50px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Misc ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: #aaa; }
.empty-state .empty-icon { font-size: 60px; margin-bottom: 15px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.section-title { font-size: 20px; font-weight: 800; color: var(--dark); margin: 0; }

/* ─── Pagination ─────────────────────────────────── */
.pagination .page-link { border-radius: 8px; margin: 0 2px; border: none; color: var(--primary); font-weight: 600; }
.pagination .page-item.active .page-link { background: var(--primary); }

/* ─── Alert ──────────────────────────────────────── */
.alert { border-radius: 12px; border: none; font-size: 14px; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ─── Progress ───────────────────────────────────── */
.progress { border-radius: 10px; height: 8px; background: #e9ecef; }
.progress-bar { border-radius: 10px; }

/* ─── Modal ──────────────────────────────────────── */
.modal-content { border-radius: 20px; border: none; }
.modal-header { border-bottom: 1px solid #f0f2f8; padding: 20px 25px; }
.modal-footer { border-top: 1px solid #f0f2f8; padding: 15px 25px; }
.modal-body { padding: 25px; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar { left: 0; }
  .topbar-toggle { display: block; }
  .main-content { margin-left: 0; padding: 15px; padding-bottom: 80px; }
  .bottom-nav { display: flex; }
}

@media (max-width: 576px) {
  .main-content { padding: 10px; padding-bottom: 80px; }
  .stat-value { font-size: 22px!important; }
  .card-header { flex-direction: column; align-items: flex-start; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ─── Animation ─────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .4s ease forwards; }
.fade-in-up:nth-child(2) { animation-delay: .1s; }
.fade-in-up:nth-child(3) { animation-delay: .15s; }
.fade-in-up:nth-child(4) { animation-delay: .2s; }

/* Print styles */
@media print {
  .sidebar, .topbar, .bottom-nav, .btn, .no-print { display: none!important; }
  .main-content { margin: 0; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
