/* ==========================================================================
   AGONG-AMA EXPENSE DASHBOARD - PRO MAX DESIGN SYSTEM (UI/UX PRO MAX STANDARD)
   ========================================================================== */

:root {
  /* Color Palette */
  --primary-50: #ecfdf5;
  --primary-100: #d1fae5;
  --primary-500: #10b981;
  --primary-600: #059669;
  --primary-700: #047857;
  
  --indigo-50: #eep2ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  
  /* Neutral Scales */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  
  /* Surface & Glassmorphism Tokens */
  --bg-app: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-hover: rgba(255, 255, 255, 0.96);
  --glass-border: rgba(226, 232, 240, 0.8);
  --glass-backdrop: blur(12px);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  /* Elevation & Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
  --shadow-xl: 0 20px 30px -10px rgba(0, 0, 0, 0.12);
  
  /* Spacing Rhythm */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

/* Dark Theme Variables */
[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.95);
  --glass-border: rgba(51, 65, 85, 0.7);
  
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image: 
    radial-gradient(at 0% 0%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Mitr', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
}

/* Layout App Container */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
  width: 270px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-backdrop);
  border-right: 1px solid var(--glass-border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 24px 12px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 20px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-600), var(--indigo-600));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.logo-text h2 {
  font-size: 1.25rem;
  line-height: 1.2;
}

.logo-text span {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 12px 8px 12px;

}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-family: 'Mitr', sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
  background: rgba(5, 150, 105, 0.08);
  color: var(--primary-600);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.nav-item.active i {
  color: white;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--glass-border);
}

.btn-sidebar-settings {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Mitr', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-sidebar-settings:hover {
  background: var(--slate-100);
  color: var(--text-primary);
}

/* Main Content Area */
.main-content {
  margin-left: 270px;
  flex: 1;
  padding: 24px 32px;
  max-width: 1350px;
}

/* Top Navbar Header */
.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-backdrop);
  padding: 16px 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
}

.header-title h1 {
  font-size: 1.45rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-title .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--slate-100);
}

.status-online {
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary-700);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-500);
  box-shadow: 0 0 8px var(--primary-500);
}

/* Primary Button Tokens */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: 'Mitr', sans-serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(5, 150, 105, 0.35);
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: var(--bg-card);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--slate-100);
  color: var(--text-primary);
}

/* Sections */
.content-section {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.content-section.active {
  display: block;
}

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

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--bg-card-hover);
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.icon-expense {
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary-600);
}

.icon-donation {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber-600);
}

.icon-average {
  background: rgba(99, 102, 241, 0.12);
  color: var(--indigo-600);
}

.icon-pooling {
  background: rgba(244, 63, 94, 0.12);
  color: var(--rose-600);
}

.kpi-info {
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.kpi-value {
  font-size: 1.45rem;
  font-weight: 700;
  font-family: 'Outfit', 'Mitr', sans-serif;
  letter-spacing: -0.02em;
}

.kpi-trend {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

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

.card-header h3 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Top 5 Category List below chart */
.cat-top5-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.cat-top5-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(241, 245, 249, 0.6);
}

.cat-top5-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.cat-top5-amount {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
}

/* Data Table Component */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background: var(--slate-100);
  padding: 14px 16px;
  font-family: 'Mitr', sans-serif;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--glass-border);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--glass-border);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: rgba(241, 245, 249, 0.7);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge-cat {
  background: rgba(99, 102, 241, 0.1);
  color: var(--indigo-600);
}

.badge-refund {
  background: rgba(244, 63, 94, 0.1);
  color: var(--rose-600);
}

.badge-donation {
  background: rgba(245, 158, 11, 0.12);
  color: var(--amber-600);
}

.avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Modal Dialog */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--bg-card);
  backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  width: 90%;
  max-width: 520px;
  padding: 28px;
  box-shadow: var(--shadow-xl);
  transform: translateY(12px);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.active .modal-content {
  transform: translateY(0);
}

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

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

.form-group {
  margin-bottom: 16px;
}

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

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--glass-border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: 'Sarabun', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--slate-800);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive Media Queries */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.active {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}
