/* ==========================================================================
   MASJID PRO BY AstraPX - Main CSS Design System
   Emerald Green & Pure White Theme (True 100% Fit-to-Screen Architecture)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Outfit:wght@400;500;600;700;800;900&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Emerald Green & Pure White Theme */
  --primary-green: #065f46;
  --primary-green-dark: #022c22;
  --primary-green-deep: #011d16;
  --primary-green-light: #10b981;
  --primary-green-bright: #34d399;
  --primary-green-mint: #d1fae5;
  --primary-green-subtle: rgba(16, 185, 129, 0.08);
  --primary-green-glow: rgba(16, 185, 129, 0.22);

  --accent-gold: #d97706;
  --accent-gold-bright: #fbbf24;
  --accent-gold-light: #fef3c7;
  --accent-gold-glow: rgba(217, 119, 6, 0.22);

  --bg-app: #f4f7f5;
  --bg-sidebar: #022c22;
  --bg-sidebar-active: #065f46;
  --bg-card: #ffffff;
  --bg-card-elevated: #ffffff;
  --bg-header: #ffffff;
  --bg-input: #f8fafc;
  --bg-hover: #f1f5f9;

  --text-main: #0f172a;
  --text-heading: #064e3b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --text-white: #ffffff;

  --border-color: #e2e8f0;
  --border-green: rgba(6, 95, 70, 0.18);
  --border-gold: rgba(217, 119, 6, 0.25);

  --status-paid: #10b981;
  --status-paid-bg: #d1fae5;
  --status-due: #f59e0b;
  --status-due-bg: #fef3c7;
  --status-pending: #ea580c;
  --status-pending-bg: #ffedd5;
  --status-overdue: #ef4444;
  --status-overdue-bg: #fee2e2;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 5px rgba(6, 78, 59, 0.04);
  --shadow-md: 0 5px 15px rgba(6, 78, 59, 0.07);
  --shadow-lg: 0 10px 24px rgba(6, 78, 59, 0.1);

  --sidebar-width: 245px;
  --header-height: 60px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Theme */
[data-theme="dark"] {
  --bg-app: #031c15;
  --bg-sidebar: #011711;
  --bg-sidebar-active: #065f46;
  --bg-card: #082f25;
  --bg-card-elevated: #0d3d31;
  --bg-header: #04241b;
  --bg-input: #021e17;
  --bg-hover: #0a4034;

  --text-main: #f8fafc;
  --text-heading: #34d399;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-light: #f8fafc;
  --text-white: #ffffff;

  --border-color: rgba(52, 211, 153, 0.15);
  --border-green: rgba(52, 211, 153, 0.25);
  --border-gold: rgba(251, 191, 36, 0.35);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.55);
}

/* ==========================================================================
   RESET & FOUNDATIONS
   ========================================================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html, body {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden; /* Lock viewport to prevent outer body scrolling */
  background-color: var(--bg-app);
  color: var(--text-main);
  transition: background-color var(--transition), color var(--transition);
}

/* ==========================================================================
   STANDALONE VECTOR SVG ICON STYLES
   ========================================================================== */
.svg-vector-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.15em;
  flex-shrink: 0;
  line-height: 1;
}

.svg-vector-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==========================================================================
   FIT-TO-SCREEN APP CONTAINER & LAYOUT
   ========================================================================== */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Sidebar Layout */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-md);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.brand-icon-box {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-gold-bright), var(--accent-gold));
  color: #1c1917;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(217, 119, 6, 0.3);
  flex-shrink: 0;
}

.brand-icon-box .svg-vector-icon {
  width: 22px;
  height: 22px;
}

.brand-title-wrap {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.12rem;
  font-weight: 900;
  letter-spacing: 0.4px;
  color: #ffffff;
  line-height: 1.15;
}

.brand-title span {
  color: var(--accent-gold-bright);
}

.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary-green-mint);
  letter-spacing: 0.8px;
}

/* Sidebar Menu (Fit Scroll) */
.sidebar-menu {
  list-style: none;
  padding: 0.6rem 0.5rem;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}
.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.menu-category-header {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.45);
  padding: 0.65rem 0.65rem 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.15rem;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  user-select: none;
}

.nav-item .svg-vector-icon {
  width: 17px;
  height: 17px;
  color: rgba(255, 255, 255, 0.65);
  transition: var(--transition);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-item:hover .svg-vector-icon {
  color: var(--accent-gold-bright);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary-green), var(--primary-green-light));
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(6, 95, 70, 0.35);
}

.nav-item.active .svg-vector-icon {
  color: #ffffff;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.12rem 0.4rem;
  border-radius: var(--radius-full);
  background: var(--primary-green-light);
  color: #ffffff;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   MAIN WRAPPER & VIEWPORT (Fit-to-Screen Fluid Container)
   ========================================================================== */
.main-wrapper {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  min-width: 0;
  background: var(--bg-app);
  box-sizing: border-box;
}

/* Sticky Top Header */
.top-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.mobile-toggle-btn {
  display: none;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.header-title-box h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.15;
}

.header-title-box p {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 450px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.hijri-prayer-pill {
  background: var(--primary-green-subtle);
  border: 1px solid var(--border-green);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-green);
  white-space: nowrap;
}

[data-theme="dark"] .hijri-prayer-pill {
  color: var(--primary-green-bright);
}

.theme-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--primary-green-light);
}

/* Page Content Viewport */
.content-viewport {
  padding: 1rem 1.25rem 1.5rem;
  flex: 1;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.view-section {
  display: none;
  animation: fadeIn 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

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

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

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: 95;
}

.sidebar-backdrop.active {
  display: block;
}

/* ==========================================================================
   FLUID & FIT-TO-SCREEN RESPONSIVE GRID BREAKPOINTS
   ========================================================================== */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
  box-sizing: border-box;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
  box-sizing: border-box;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  width: 100%;
  box-sizing: border-box;
}

/* Screen Width <= 1366px (Standard Laptop Displays & Windows Scaled Viewports) */
@media (max-width: 1366px) {
  .grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.65rem;
  }
}

/* Screen Width <= 1180px */
@media (max-width: 1180px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

/* Screen Width <= 1024px (Tablets) */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-toggle-btn {
    display: inline-flex;
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-viewport {
    padding: 0.9rem;
  }
}

/* Screen Width <= 768px (Mobile & Small Tablets) */
@media (max-width: 768px) {
  .top-header {
    height: auto;
    min-height: 56px;
    padding: 0.5rem 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-title-box h2 {
    font-size: 1.05rem;
  }

  .header-title-box p {
    display: none;
  }

  .header-right {
    gap: 0.35rem;
    flex-wrap: wrap;
  }

  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }

  .content-viewport {
    padding: 0.75rem;
  }
}

/* Screen Width <= 540px */
@media (max-width: 540px) {
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }
}
