@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(99, 102, 241, 0.15);
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --dark: #0f172a;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

body {
  background: var(--gray-50);
  overflow-x: hidden;
  color: var(--gray-700);
  -webkit-font-smoothing: antialiased;
}

/* ========== LOGIN ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-card .logo { text-align: center; margin-bottom: 1.5rem; }
.login-card .logo h2 { color: var(--primary); font-weight: 700; }
.login-card .logo p { color: var(--gray-500); font-size: 0.875rem; }

@media (max-width: 480px) {
  .login-card { padding: 1.5rem; }
  .login-card .logo h2 { font-size: 1.25rem; }
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1050;
  transition: transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-header h4 { color: white; font-weight: 700; margin: 0; font-size: 1.15rem; }
.sidebar-header h4 span { color: var(--primary); }
.sidebar .nav-link {
  color: rgba(255,255,255,0.65);
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar .nav-link:hover { color: white; background: var(--sidebar-hover); }
.sidebar .nav-link.active { color: white; background: var(--sidebar-active); border-left-color: var(--primary); }
.sidebar .nav-link i { width: 20px; text-align: center; font-size: 1rem; }
.sidebar .nav-section {
  color: var(--gray-400);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.85rem 1.25rem 0.4rem;
  font-weight: 600;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-600); border-radius: 2px; }

/* ========== SIDEBAR OVERLAY (mobile) ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1040;
}
.sidebar-overlay.show { display: block; }

/* ========== MAIN CONTENT ========== */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.topbar {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 1040;
}
.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-600);
  cursor: pointer;
  display: none;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s;
}
.sidebar-toggle:hover { background: var(--gray-100); }
.page-title {
  margin: 0;
  font-weight: 700;
  color: var(--dark);
  font-size: 1.25rem;
}
.page-content {
  padding: 2rem;
  flex: 1;
}

/* ========== CARDS & TABLES ========== */
.stat-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid rgba(0,0,0,0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 1rem;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--dark); line-height: 1.2; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.2rem; }

/* ========== TABLES ========== */
.table-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
  margin-bottom: 1rem;
}
.table-container .table-header {
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 1px solid var(--gray-200);
}
.table-container .table-header h5 { margin: 0; font-weight: 600; font-size: 0.95rem; }
.table-container .table-toolbar {
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-100);
}
.table-container .table-footer {
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-top: 1px solid var(--gray-200);
}
.table-container .table-footer .pagination-info {
  color: var(--gray-500);
  font-size: 0.8rem;
  white-space: nowrap;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table { margin-bottom: 0; }
.table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  white-space: nowrap;
  padding: 0.65rem 0.75rem;
}
.table td {
  vertical-align: middle;
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem;
}
.table td .badge { white-space: nowrap; }
.table td .action-btn { white-space: nowrap; }

/* ========== FILTERS ========== */
.filter-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.filter-row .form-control,
.filter-row .form-select {
  width: auto;
  min-width: 120px;
  font-size: 0.8rem;
  padding: 0.3rem 0.5rem;
  height: auto;
}

/* ========== MODALS ========== */
.modal-content { border-radius: 12px; border: none; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { border-bottom: 1px solid var(--gray-200); padding: 1rem 1.25rem; }
.modal-header .modal-title { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer { border-top: 1px solid var(--gray-200); padding: 0.85rem 1.25rem; }

/* ========== BADGES ========== */
.badge-status {
  padding: 0.3em 0.6em;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 20px;
}
.badge-paid, .badge-success { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-failed, .badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-active { background: #dbeafe; color: #1e40af; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

/* ========== LOADING ========== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.loading-overlay.show { display: flex; }

/* ========== UTILITY ========== */
.btn:active { transform: scale(0.97); }
.action-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.8rem;
}
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-400);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }

/* ========== RESPONSIVE ========== */

/* Large: < 1200px */
@media (max-width: 1199.98px) {
  .stat-card .stat-value { font-size: 1.3rem; }
}

/* Medium: < 992px - hide sidebar, show toggle */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
  }
  .sidebar-overlay.show { display: block; }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .topbar .user-info .username-label { display: inline; font-size: 0.85rem; }
  .page-content { padding: 1rem; }
}

/* Small: < 768px */
@media (max-width: 767.98px) {
  .sidebar { width: 260px; }
  .stat-card { padding: 1rem; }
  .stat-card .stat-icon { width: 38px; height: 38px; font-size: 1rem; }
  .stat-card .stat-value { font-size: 1.15rem; }
  .stat-card .stat-label { font-size: 0.75rem; }
  .filter-row .form-control,
  .filter-row .form-select {
    min-width: 80px;
    font-size: 0.75rem;
  }
  .table-container .table-header { padding: 0.7rem 1rem; }
  .table-container .table-toolbar { padding: 0.5rem 1rem; }
  .table-container .table-footer { padding: 0.5rem 1rem; }
  .page-content { padding: 0.75rem; }
  .topbar { padding: 0.6rem 1rem; }
  .topbar .page-title { font-size: 0.9rem; }
  .modal-dialog { margin: 0.5rem; }
}

/* Extra Small: < 576px */
@media (max-width: 575.98px) {
  .stat-card { padding: 0.85rem; }
  .stat-card .stat-value { font-size: 1rem; }
  .stat-card .stat-icon { width: 34px; height: 34px; font-size: 0.9rem; margin-bottom: 0.5rem; }
  .table-container .table-header h5 { font-size: 0.85rem; }
  .table-container .table-header .btn { font-size: 0.8rem; padding: 0.25rem 0.5rem; }
  .table th { font-size: 0.7rem; padding: 0.5rem; }
  .table td { font-size: 0.8rem; padding: 0.4rem 0.5rem; }
  .filter-row .form-control,
  .filter-row .form-select {
    min-width: 70px;
    font-size: 0.7rem;
  }
  .topbar .user-info .username-label { display: none; }
  .btn-sm { font-size: 0.75rem; padding: 0.2rem 0.4rem; }
}
