/* ==========================================================================
   KomunitasKu - Modern Mobile-First Stylesheet
   ========================================================================== */

/* 1. Design System & CSS Tokens */
:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-primary: #090d16;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-input: #1f293d;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-rose: #f43f5e;
  --accent-rose-glow: rgba(244, 63, 94, 0.25);
  --accent-indigo: #6366f1;
  --accent-indigo-glow: rgba(99, 102, 241, 0.25);
  --accent-amber: #f59e0b;
  --accent-blue: #3b82f6;

  /* Fonts & Shadows */
  --font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 32px rgba(0,0,0,0.4);
  --glass-blur: blur(14px);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-width: 260px;
  --mobile-nav-height: 68px;
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-input: #e2e8f0;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --border-color: rgba(0, 0, 0, 0.08);
  --border-highlight: rgba(0, 0, 0, 0.15);

  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 16px 32px rgba(0,0,0,0.12);
}

/* 2. Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Typography Utilities */
h1, h2, h3, h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

p {
  color: var(--text-muted);
}

.text-emerald { color: var(--accent-emerald) !important; }
.text-rose { color: var(--accent-rose) !important; }
.text-indigo { color: var(--accent-indigo) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* 3. Glassmorphism Card Style */
.glass {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.glass:hover {
  border-color: var(--border-highlight);
}

/* 4. Layout Structure */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100vw;
}

/* Sidebar Desktop */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px 12px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.brand-text h2 {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.2;
}

.badge-sub {
  font-size: 0.72rem;
  color: var(--accent-emerald);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Navigation Links */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 24px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.nav-item.active {
  background: var(--accent-emerald);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

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

.community-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.comm-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-indigo);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.comm-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.comm-status {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 28px 32px var(--mobile-nav-height) 32px;
  max-width: 1400px;
}

/* Top Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.header-title h1 {
  font-size: 1.75rem;
  font-weight: 800;
}

.header-title p {
  font-size: 0.9rem;
  margin-top: 2px;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--accent-emerald);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-emerald-glow);
}

.btn-primary:hover {
  background: #0ea5e9;
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-highlight);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.82rem;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-emerald);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;

}
.btn-link:hover {
  text-decoration: underline;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-highlight);
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* 5. Tab Views */
.tab-view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-view.active {
  display: block;
}

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

/* 6. Dashboard Layout & Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
}

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

.stat-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-muted);
}

.icon-chip {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-chip.green { background: var(--accent-emerald-glow); color: var(--accent-emerald); }
.icon-chip.emerald { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.icon-chip.rose { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }
.icon-chip.indigo { background: rgba(99, 102, 241, 0.15); color: var(--accent-indigo); }

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-footer {
  margin-top: 10px;
  font-size: 0.8rem;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.positive { background: rgba(16, 185, 129, 0.15); color: var(--accent-emerald); }
.badge.info { background: rgba(99, 102, 241, 0.15); color: var(--accent-indigo); }
.badge.warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.badge.danger { background: rgba(244, 63, 94, 0.15); color: var(--accent-rose); }

/* Dashboard Grids */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.card {
  padding: 22px;
}

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

.card-header h3 {
  font-size: 1.1rem;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-card {
  grid-column: span 1;
}

.chart-container {
  width: 100%;
  position: relative;
}

.banner-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(16, 185, 129, 0.15));
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
}

.banner-content h3 {
  font-size: 1.25rem;
  margin: 10px 0 6px 0;
}

.banner-content p {
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.banner-btns {
  display: flex;
  gap: 10px;
}

/* 7. Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* 8. Activities Grid & Mini List */
.activities-list-mini {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.act-item-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.act-info h4 {
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.act-info p {
  font-size: 0.78rem;
}

/* Activities Grid Page */
.activities-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.activity-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.act-card-img {
  width: 100%;
  height: 170px;
  object-fit: cover;
}

.act-card-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.act-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.act-card-title {
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.act-meta {
  display: flex;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.act-budget-box {
  background: var(--bg-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 14px;
  border: 1px solid var(--border-color);
}

.act-card-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 9. Section Toolbars & Filters */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.search-filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.search-input-box {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
}

.search-input-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

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

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-emerald);
}

.tab-filters {
  display: flex;
  gap: 8px;
}

.filter-chip {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip.active {
  background: var(--accent-emerald);
  color: #fff;
  border-color: var(--accent-emerald);
}

.financial-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 16px 24px;
  margin-bottom: 20px;
}

.summary-item {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.sub-label {
  font-size: 0.78rem;
  color: var(--text-muted);

}

.sub-val {
  font-size: 1.2rem;
  font-weight: 800;
}

.summary-divider {
  width: 1px;
  height: 36px;
  background: var(--border-color);
}

/* 10. Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-lg {
  max-width: 720px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-muted);
  cursor: pointer;
}

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

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* 11. Report Export & Print Preview */
.report-export-box {
  padding: 32px;
}

.report-header {
  text-align: center;
  max-width: 600px;
  margin: 0 auto 28px auto;
}

.report-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent-indigo-glow);
  color: var(--accent-indigo);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.report-controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 700px;
  margin: 0 auto 24px auto;
}

.report-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 36px;
}

.printable-preview-card {
  background: #ffffff;
  color: #000000;
  padding: 40px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  max-width: 900px;
  margin: 0 auto;
}

.print-header {
  text-align: center;
  border-bottom: 2px solid #000;
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.print-header h2 { font-size: 1.3rem; color: #000; }
.print-header h3 { font-size: 1rem; color: #444; font-weight: 600; }
.print-header p { font-size: 0.82rem; color: #666; }

.print-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.print-sum-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  padding: 12px;
  text-align: center;
  border-radius: 6px;
}

.print-sum-box .p-label { font-size: 0.75rem; color: #64748b; display: block; }
.print-sum-box .p-val { font-size: 1.1rem; font-weight: 800; color: #0f172a; }

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.85rem;
}

.print-table th, .print-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 10px;
  text-align: left;
  color: #000000;
}

.print-table th {
  background: #f1f5f9;
  font-weight: 700;
}

.print-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 48px;
}

.sig-box {
  text-align: center;
  width: 200px;
  font-size: 0.85rem;
  color: #000;
}

.sig-space {
  height: 60px;
}

/* 12. Bottom Mobile Navigation */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--mobile-nav-height);
  background: var(--bg-secondary);
  backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-color);
  z-index: 90;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  height: 100%;
}

.mobile-nav-item.active {
  color: var(--accent-emerald);
}

.mobile-nav-item.active svg {
  stroke: var(--accent-emerald);
  transform: translateY(-2px);
}

/* 13. Responsive Media Queries */
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .report-controls-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none; /* Hidden on mobile, bottom nav used instead */
  }

  .main-content {
    margin-left: 0;
    padding: 16px 16px calc(var(--mobile-nav-height) + 16px) 16px;
  }

  .mobile-nav {
    display: flex;
  }

  .top-header {
    margin-bottom: 20px;
  }

  .header-title h1 {
    font-size: 1.4rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .financial-summary-bar {
    flex-direction: column;
    gap: 12px;
  }

  .summary-divider {
    width: 100%;
    height: 1px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* 14. Print Media Rules */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .sidebar, .mobile-nav, .top-header, .section-toolbar, .report-controls-grid, .report-actions, .report-header, .report-badge {
    display: none !important;
  }
  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
  .tab-view {
    display: none !important;
  }
  #view-laporan {
    display: block !important;
  }
  .report-export-box {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
  }
  .printable-preview-card {
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
  }
}
