/* ==========================================================================
   Al-Muqaddas Tours & Travels — Google Material Design 3 Enterprise CRM
   ========================================================================== */

:root {
  /* MD3 Color Tokens — Navy Primary + Clean Light Surface */
  --md-sys-color-primary: #0f3d7a;
  --md-sys-color-primary-hover: #0b2f5f;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #dbeafe;
  --md-sys-color-on-primary-container: #0a254d;

  --md-sys-color-secondary: #475569;
  --md-sys-color-secondary-container: #e2e8f0;
  --md-sys-color-on-secondary-container: #1e293b;

  --md-sys-color-surface: #ffffff;
  --md-sys-color-surface-dim: #f4f6fa;
  --md-sys-color-surface-container: #f1f5f9;
  --md-sys-color-surface-container-high: #e8eef5;
  --md-sys-color-on-surface: #0f172a;
  --md-sys-color-on-surface-variant: #475569;
  --md-sys-color-outline: #cbd5e1;
  --md-sys-color-outline-variant: #e2e8f0;

  /* Semantic Status Colors */
  --status-paid-bg: #dcfce7;
  --status-paid-fg: #15803d;
  --status-paid-border: #bbf7d0;

  --status-partial-bg: #fef3c7;
  --status-partial-fg: #b45309;
  --status-partial-border: #fde68a;

  --status-unpaid-bg: #fee2e2;
  --status-unpaid-fg: #b91c1c;
  --status-unpaid-border: #fecaca;

  --status-overpaid-bg: #e0f2fe;
  --status-overpaid-fg: #0369a1;
  --status-overpaid-border: #bae6fd;

  /* Elevation & Shape */
  --md-elevation-1: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.06);
  --md-elevation-2: 0 4px 10px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --md-elevation-3: 0 10px 25px rgba(15, 23, 42, 0.1);
  --md-radius-sm: 8px;
  --md-radius-md: 12px;
  --md-radius-lg: 16px;
  --md-radius-xl: 24px;

  --sidebar-width: 264px;
  --topbar-height: 64px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background-color: var(--md-sys-color-surface-dim);
  color: var(--md-sys-color-on-surface);
  font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  line-height: 1;
  user-select: none;
}

/* ==========================================================================
   App Shell: Sidebar Navigation Drawer + Main Workspace
   ========================================================================== */

.crm-shell {
  display: flex;
  min-height: 100vh;
}

.crm-sidebar {
  width: var(--sidebar-width);
  background-color: var(--md-sys-color-surface);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  transition: transform 0.24s cubic-bezier(0.2, 0, 0, 1);
}

.crm-sidebar-brand {
  padding: 16px 18px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-height);
}

.crm-sidebar-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 2px;
  flex-shrink: 0;
}

.crm-brand-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  line-height: 1.2;
}

.crm-brand-sub {
  font-size: 11px;
  color: var(--md-sys-color-on-surface-variant);
}

.crm-nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.crm-nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-sys-color-on-surface-variant);
  padding: 10px 14px 4px;
}

.crm-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background-color 0.15s ease, color 0.15s ease;
  min-height: 42px;
}

.crm-nav-link:hover {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

.crm-nav-link.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: 600;
}

.crm-nav-link.active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

.crm-nav-link-logout {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: #b91c1c;
}

.crm-nav-link-logout:hover {
  background-color: #fee2e2;
  color: #991b1b;
}

.crm-sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container);
}

.crm-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.crm-topbar {
  height: var(--topbar-height);
  background-color: var(--md-sys-color-surface);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.crm-content {
  padding: 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.crm-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1035;
}

.crm-backdrop.show {
  display: block;
}

.crm-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}

@media (max-width: 991.98px) {
  .crm-sidebar {
    transform: translateX(-100%);
  }
  .crm-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--md-elevation-3);
  }
  .crm-main {
    margin-left: 0;
  }
  .crm-menu-btn {
    display: inline-flex;
  }
  .crm-topbar {
    padding: 0 14px;
  }
  .crm-content {
    padding: 16px 12px;
  }
}

/* ==========================================================================
   MD3 Cards, Surfaces, and Summary Metrics
   ========================================================================== */

.md3-card {
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-1);
}

.md3-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.md3-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.md3-card-body {
  padding: 20px;
}

.stat-card {
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-lg);
  padding: 16px 18px;
  box-shadow: var(--md-elevation-1);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  height: 100%;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  box-shadow: var(--md-elevation-2);
  border-color: var(--md-sys-color-outline);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 21px;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  line-height: 1.2;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-primary {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
}
.stat-icon-success {
  background: var(--status-paid-bg);
  color: var(--status-paid-fg);
}
.stat-icon-warning {
  background: var(--status-partial-bg);
  color: var(--status-partial-fg);
}
.stat-icon-danger {
  background: var(--status-unpaid-bg);
  color: var(--status-unpaid-fg);
}

/* ==========================================================================
   Haji Profile Cards
   ========================================================================== */

.haji-card {
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-1);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}

.haji-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--md-elevation-2);
  border-color: #94a3b8;
}

.haji-card-top {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.haji-avatar {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  object-fit: cover;
  border: 2px solid var(--md-sys-color-outline-variant);
  flex-shrink: 0;
  background-color: var(--md-sys-color-surface-container);
}

.haji-avatar-fallback {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  font-weight: 700;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #bfdbfe;
}

.haji-name-link {
  font-size: 16px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  text-decoration: none;
  display: block;
  line-height: 1.25;
}

.haji-name-link:hover {
  text-decoration: underline;
}

.haji-card-body {
  padding: 14px 18px;
  flex: 1;
}

.haji-kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
}

.haji-kv-label {
  color: var(--md-sys-color-on-surface-variant);
}

.haji-kv-val {
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  text-align: right;
}

.haji-card-footer {
  padding: 12px 18px;
  background-color: var(--md-sys-color-surface-container);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ==========================================================================
   Status Badges & Chips
   ========================================================================== */

.md3-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.badge-paid {
  background-color: var(--status-paid-bg);
  color: var(--status-paid-fg);
  border: 1px solid var(--status-paid-border);
}

.badge-partial {
  background-color: var(--status-partial-bg);
  color: var(--status-partial-fg);
  border: 1px solid var(--status-partial-border);
}

.badge-unpaid {
  background-color: var(--status-unpaid-bg);
  color: var(--status-unpaid-fg);
  border: 1px solid var(--status-unpaid-border);
}

.badge-overpaid {
  background-color: var(--status-overpaid-bg);
  color: var(--status-overpaid-fg);
  border: 1px solid var(--status-overpaid-border);
}

.badge-neutral {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
}

/* ==========================================================================
   MD3 Buttons & Inputs
   ========================================================================== */

.md3-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  min-height: 40px;
  white-space: nowrap;
}

.md3-btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  min-height: 34px;
}

.md3-btn-primary {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.md3-btn-primary:hover {
  background-color: var(--md-sys-color-primary-hover);
  color: var(--md-sys-color-on-primary);
  box-shadow: var(--md-elevation-1);
}

.md3-btn-tonal {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.md3-btn-tonal:hover {
  background-color: #bfdbfe;
  color: var(--md-sys-color-on-primary-container);
}

.md3-btn-outlined {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  border-color: var(--md-sys-color-outline);
}

.md3-btn-outlined:hover {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
}

.md3-btn-danger {
  background-color: #dc2626;
  color: #ffffff;
}

.md3-btn-danger:hover {
  background-color: #b91c1c;
  color: #ffffff;
}

.md3-btn-danger-outlined {
  background-color: var(--md-sys-color-surface);
  color: #b91c1c;
  border-color: #fecaca;
}

.md3-btn-danger-outlined:hover {
  background-color: #fee2e2;
}

.md3-field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  margin-bottom: 6px;
}

.md3-input,
.md3-select,
.md3-file-input {
  width: 100%;
  padding: 10px 13px;
  font-size: 14px;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-family: inherit;
}

.md3-input:focus,
.md3-select:focus {
  outline: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(15, 61, 122, 0.14);
}

.md3-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--md-sys-color-primary);
  cursor: pointer;
}

.md3-help-text {
  font-size: 12px;
  color: var(--md-sys-color-on-surface-variant);
  margin-top: 4px;
}

.md3-error-text {
  font-size: 12px;
  color: #b91c1c;
  margin-top: 4px;
  font-weight: 500;
}

/* ==========================================================================
   Data Tables
   ========================================================================== */

.md3-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.md3-table th {
  background-color: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  white-space: nowrap;
  text-align: left;
}

.md3-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  vertical-align: middle;
}

.md3-table tbody tr:hover {
  background-color: #f8fafc;
}

.md3-table tr.row-reversed {
  background-color: #fef2f2;
  color: #64748b;
}

/* ==========================================================================
   Profile Photo & Print Helpers
   ========================================================================== */

.profile-hero-photo {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  object-fit: cover;
  border: 3px solid var(--md-sys-color-outline-variant);
  background: #fff;
}

.profile-hero-fallback {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.report-tab-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface-variant);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.report-tab-chip.active {
  background: var(--md-sys-color-primary);
  color: #ffffff;
  border-color: var(--md-sys-color-primary);
}

@media print {
  .no-print,
  .crm-sidebar,
  .crm-topbar,
  .crm-backdrop {
    display: none !important;
  }
  .crm-main {
    margin-left: 0 !important;
  }
  .crm-content {
    padding: 0 !important;
    max-width: 100% !important;
  }
  body {
    background: #ffffff !important;
  }
  .md3-card {
    box-shadow: none !important;
    border-color: #cbd5e1 !important;
  }
}
