/* ==========================================================================
   Sui Project Funds Manager - Glassmorphism Theme
   Product of Sui Generis Technologies
   ========================================================================== */

:root {
  --spm-bg-start: #0f2027;
  --spm-bg-mid: #203a43;
  --spm-bg-end: #2c5364;
  --spm-primary: #3ddc97;
  --spm-primary-dark: #21a179;
  --spm-accent: #6c63ff;
  --spm-danger: #ff6b6b;
  --spm-warning: #ffb703;
  --spm-glass-bg: rgba(15, 32, 39, 0.55);
  --spm-glass-border: rgba(255, 255, 255, 0.22);
  --spm-text-light: #f4f7f6;
  --spm-text-muted: rgba(244, 247, 246, 0.78);
  --spm-radius: 18px;
  --spm-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);

  /* Bootstrap 5.3 components (modals, form labels, close buttons, etc.) read
     these variables directly rather than truly inheriting page color, so
     overriding body's `color` alone was not enough - this is the same class
     of bug fixed for tables, applied at the root so it covers every
     component (current and future) instead of one at a time. */
  --bs-body-color: #f4f7f6;
  --bs-body-color-rgb: 244, 247, 246;
  --bs-heading-color: #f4f7f6;
  --bs-emphasis-color: #f4f7f6;
  --bs-secondary-color: rgba(244, 247, 246, 0.78);
  --bs-tertiary-color: rgba(244, 247, 246, 0.6);
  --bs-border-color: rgba(255, 255, 255, 0.22);
  --bs-border-color-translucent: rgba(255, 255, 255, 0.22);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, var(--spm-bg-start), var(--spm-bg-mid) 55%, var(--spm-bg-end));
  background-attachment: fixed;
  color: var(--spm-text-light);
}

/* Decorative blurred blobs for depth */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: 0;
  opacity: 0.35;
  pointer-events: none;
}
body::before {
  width: 420px; height: 420px;
  background: var(--spm-primary);
  top: -120px; left: -120px;
}
body::after {
  width: 520px; height: 520px;
  background: var(--spm-accent);
  bottom: -160px; right: -160px;
}

.spm-app { position: relative; z-index: 1; }

/* ---- Glass surfaces ---- */
.glass-card {
  background: var(--spm-glass-bg);
  border: 1px solid var(--spm-glass-border);
  border-radius: var(--spm-radius);
  box-shadow: var(--spm-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
@media (hover: hover) and (pointer: fine) {
  .glass-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.35);
  }
}
.glass-panel {
  background: var(--spm-glass-bg);
  border: 1px solid var(--spm-glass-border);
  border-radius: var(--spm-radius);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

/* ---- Brand ---- */
.spm-brand { display: flex; align-items: center; gap: 0.65rem; }
.spm-brand-text { font-weight: 700; font-size: 0.95rem; letter-spacing: 0.2px; line-height: 1.2; }
.spm-tagline { color: var(--spm-text-muted); font-size: 0.72rem; line-height: 1.2; }
.spm-brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(61, 220, 151, 0.25);
  flex-shrink: 0;
}
.spm-brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- Layout ---- */
.spm-sidebar {
  min-height: 100vh;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--spm-glass-border);
}
.spm-sidebar .nav-link {
  color: var(--spm-text-muted);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.25rem;
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 500;
  transition: all .15s ease;
}
.spm-sidebar .nav-link:hover,
.spm-sidebar .nav-link.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--spm-text-light);
}
.spm-sidebar .nav-link i { width: 18px; text-align: center; }

.spm-topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--spm-glass-border);
}

.spm-main { padding: 1.5rem; }

/* ---- Buttons ---- */
.btn-spm-primary,
.btn-glass-primary {
  background: linear-gradient(135deg, var(--spm-primary), var(--spm-primary-dark));
  border: none; color: #06231a; font-weight: 600;
  border-radius: 12px; padding: 0.55rem 1.2rem;
  box-shadow: 0 4px 14px rgba(61, 220, 151, 0.35);
}
.btn-spm-primary:hover,
.btn-glass-primary:hover { color: #06231a; filter: brightness(1.08); transform: translateY(-1px); }

.btn-spm-outline {
  background: transparent; border: 1px solid var(--spm-glass-border);
  color: var(--spm-text-light); border-radius: 12px; padding: 0.55rem 1.2rem;
}
.btn-spm-outline:hover { background: rgba(255,255,255,0.1); color: var(--spm-text-light); }

.btn-spm-danger {
  background: rgba(255, 107, 107, 0.18); border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ffb3b3; border-radius: 12px; padding: 0.5rem 1rem;
}

/* ---- Forms ---- */
.form-control, .form-select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--spm-glass-border);
  color: var(--spm-text-light);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
}
.form-control:focus, .form-select:focus {
  background: rgba(255, 255, 255, 0.14);
  color: var(--spm-text-light);
  border-color: var(--spm-primary);
  box-shadow: 0 0 0 0.2rem rgba(61, 220, 151, 0.18);
}
.form-control::placeholder { color: rgba(244,247,246,0.45); }
input[type="file"].form-control { color: var(--spm-text-muted); }
input[type="file"].form-control::file-selector-button {
  background: var(--spm-primary);
  color: #06231a;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
  margin-right: 0.75rem;
  cursor: pointer;
}
input[type="file"].form-control::-webkit-file-upload-button {
  background: var(--spm-primary);
  color: #06231a;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font-weight: 600;
  margin-right: 0.75rem;
  cursor: pointer;
}
label { color: var(--spm-text-muted); font-weight: 500; font-size: 0.88rem; }

/* ---- Stat cards ---- */
.stat-card { padding: 1.25rem 1.4rem; }
.stat-card .stat-label { color: var(--spm-text-muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; margin-top: .25rem; }
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.12); font-size: 1.15rem;
}

/* ---- Progress ---- */
.progress { background: rgba(255,255,255,0.12); border-radius: 999px; height: 10px; }
.progress-bar { background: linear-gradient(90deg, var(--spm-primary), var(--spm-accent)); border-radius: 999px; }

/* ---- Badges ---- */
.badge-spm { border-radius: 999px; padding: 0.35em 0.8em; font-weight: 600; font-size: 0.72rem; }
.badge-active, .badge-submitted, .badge-approved { background: rgba(61,220,151,0.2); color: #7ef2c1; }
.badge-pending { background: rgba(255,183,3,0.2); color: #ffd166; }
.badge-rejected, .badge-cancelled, .badge-voided { background: rgba(255,107,107,0.2); color: #ffb3b3; }
.badge-completed { background: rgba(108,99,255,0.22); color: #c3bfff; }
.badge-editable { background: rgba(255,255,255,0.16); color: var(--spm-text-light); }
.badge-inactive, .badge-suspended { background: rgba(255,183,3,0.18); color: #ffd166; }

/* ---- Tables ---- */
.table-spm {
  /* Override Bootstrap 5.3's own table theming variables directly -
     its .table > :not(caption) > * > * rule reads these, so this is the
     authoritative fix rather than trying to out-specificity it. */
  --bs-table-color: var(--spm-text-light);
  --bs-table-bg: transparent;
  --bs-table-border-color: rgba(255,255,255,0.08);
  --bs-table-striped-color: var(--spm-text-light);
  --bs-table-striped-bg: rgba(255,255,255,0.04);
  --bs-table-active-color: var(--spm-text-light);
  --bs-table-active-bg: rgba(255,255,255,0.08);
  --bs-table-hover-color: var(--spm-text-light);
  --bs-table-hover-bg: rgba(255,255,255,0.06);
  color: var(--spm-text-light);
  background: transparent;
}
.table-spm th,
.table-spm td { color: var(--spm-text-light) !important; background-color: transparent !important; }
.table-spm th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--spm-glass-border); opacity: 0.85; white-space: nowrap; }
.table-spm td { border-bottom: 1px solid rgba(255,255,255,0.08); vertical-align: middle; white-space: nowrap; }
.table-spm tr:hover td { background-color: rgba(255,255,255,0.06) !important; }
/* Table cells scroll horizontally by default (via .table-responsive below) rather
   than wrapping - this keeps short values like refs, dates, amounts, statuses, and
   action buttons on one line instead of breaking mid-word/mid-number on narrow
   screens. Opt a specific cell into wrapping with .cell-wrap when its content is
   genuinely long free text (descriptions, notes, reasons). */
.cell-wrap {
  white-space: normal !important;
  word-break: break-word;
  overflow-wrap: break-word;
}
.table-responsive {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-spm td.text-muted-spm,
.table-spm td .text-muted-spm { color: var(--spm-text-muted) !important; }

/* ---- Alerts (Bootstrap's default alert text colors are tuned for light
   pages - #842029 on #f8d7da etc - and render as low-contrast dark text on
   this dark glass theme, so override to match the existing badge palette) ---- */
.alert-danger  { color: #ffb3b3 !important; background-color: rgba(255,107,107,0.14) !important; border-color: rgba(255,107,107,0.4) !important; }
.alert-success { color: #7ef2c1 !important; background-color: rgba(61,220,151,0.12) !important; border-color: rgba(61,220,151,0.4) !important; }
.alert-warning { color: #ffd166 !important; background-color: rgba(255,183,3,0.14) !important; border-color: rgba(255,183,3,0.4) !important; }
.alert-info    { color: #9ad4ff !important; background-color: rgba(108,163,255,0.14) !important; border-color: rgba(108,163,255,0.4) !important; }
.alert-danger .btn-close, .alert-warning .btn-close, .alert-info .btn-close { filter: invert(1) grayscale(1); }

/* ---- Mobile card list (compact summary, tap to expand full details) ---- */
.mobile-item-card { padding: 1rem 1.1rem; }
.mobile-item-card .mic-toggle { cursor: pointer; }
.mobile-item-card .mic-chevron { transition: transform 0.2s ease; color: var(--spm-text-muted); }
.mobile-item-card .mic-toggle:not(.collapsed) .mic-chevron { transform: rotate(180deg); }
.mobile-item-card .mic-details { border-top: 1px solid rgba(255,255,255,0.1); margin-top: 0.85rem; padding-top: 0.85rem; }
.mobile-item-card .mic-row { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.3rem 0; font-size: 0.85rem; }
.mobile-item-card .mic-row .mic-label { color: var(--spm-text-muted); flex-shrink: 0; }
.mobile-item-card .mic-row .mic-value { text-align: right; }

@media (min-width: 768px) {
  .mobile-only-cards { display: none !important; }
}
@media (max-width: 767.98px) {
  .desktop-only-table { display: none !important; }
  /* Project card mini-stats (Allocated/Expenses/Balance etc.) stack into
     full-width rows instead of squeezing into narrow side-by-side columns */
  .stat-mini-row > [class*="col-"] {
    flex: 0 0 100%;
    max-width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .stat-mini-row > [class*="col-"]:last-child { border-bottom: none; }
  .stat-mini-row .stat-mini-label { margin-bottom: 0; }
}

/* ---- Modals ----
   iOS Safari has a known issue where backdrop-filter blur on a fixed-position
   container can swallow touch events meant for its own form fields, so modal
   content uses a solid tinted background instead of blur (unlike glass-card
   elsewhere in the page, which isn't fixed-position and doesn't hit this bug). */
.modal-content.glass-card {
  background: rgba(15, 32, 39, 0.96);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
/* Cancel the page-card :hover lift effect inside modals - on iOS Safari, an
   element with a :hover-triggered transform can require a first "phantom" tap
   to simulate :hover before a second tap actually focuses a child input, which
   is almost certainly why textareas inside modals weren't responding to taps. */
.modal-content.glass-card:hover { transform: none; box-shadow: var(--spm-shadow); }
.modal { z-index: 1060; }
.modal-backdrop { z-index: 1055; }
.modal-content, .modal-body, .modal-body * { pointer-events: auto; }
.modal-body textarea, .modal-body input, .modal-body select, .modal-body button { position: relative; z-index: 2; }
.modal-title { color: var(--spm-text-light); }
.modal .btn-close { filter: invert(1) grayscale(1) brightness(1.7); opacity: 0.85; }
.modal .btn-close:hover { opacity: 1; }

/* ---- Detail stack card (mobile-only vertical card: title, badge, stacked
   label/value rows, full-width action buttons - matches the My Projects
   card style, reused across other list pages on mobile) ---- */
.detail-stack-card { padding: 1.25rem 1.25rem 1.4rem; }
.detail-stack-card .dsc-eyebrow { color: var(--spm-text-muted); font-size: 0.85rem; margin-bottom: 0.15rem; }
.detail-stack-card .dsc-title { font-size: 1.25rem; font-weight: 700; line-height: 1.25; }
.detail-stack-card .dsc-sub { color: var(--spm-text-muted); font-size: 0.85rem; margin-top: 0.2rem; }
.detail-stack-card .dsc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; margin-bottom: 1rem; }
.detail-stack-card .dsc-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.65rem 0; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 1rem; }
.detail-stack-card .dsc-row:last-of-type { border-bottom: none; }
.detail-stack-card .dsc-label { color: var(--spm-text-light); }
.detail-stack-card .dsc-value { font-weight: 600; text-align: right; }
.detail-stack-card .dsc-actions { display: flex; gap: 0.5rem; margin-top: 1.1rem; flex-wrap: wrap; }
.detail-stack-card .dsc-actions > * { flex: 1 1 auto; }

/* ---- Total balance banner (subtle pulse to draw attention) ---- */
.total-balance-banner {
  background: linear-gradient(135deg, rgba(61,220,151,0.18), rgba(33,161,121,0.10));
  border: 1px solid rgba(61,220,151,0.45);
  border-radius: var(--spm-radius);
  padding: 1.1rem 1.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  animation: spm-pulse-glow 2.2s ease-in-out infinite;
}
.total-balance-banner .tbb-label { color: var(--spm-text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 0.15rem; }
.total-balance-banner .tbb-value { font-size: 1.6rem; font-weight: 800; color: var(--spm-primary); }
.total-balance-banner .tbb-sub { color: var(--spm-text-muted); font-size: 0.8rem; }
@keyframes spm-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61,220,151,0.35); border-color: rgba(61,220,151,0.45); }
  50% { box-shadow: 0 0 0 10px rgba(61,220,151,0); border-color: rgba(61,220,151,0.9); }
}
@media (prefers-reduced-motion: reduce) {
  .total-balance-banner { animation: none; }
}

/* ---- Auth pages ---- */
.spm-auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.spm-auth-card { width: 100%; max-width: 420px; padding: 2.2rem; }

/* ---- Misc ---- */
a { color: var(--spm-primary); text-decoration: none; }
a:hover { color: var(--spm-primary-dark); }
.text-muted-spm { color: var(--spm-text-muted) !important; }
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--spm-text-muted); }
.empty-state i { font-size: 2.4rem; margin-bottom: .75rem; opacity: 0.7; }

@media (max-width: 768px) {
  .spm-sidebar { position: fixed; left: -260px; top: 0; width: 260px; z-index: 1050; background: #14232b; transition: left .2s ease; }
  .spm-sidebar.show { left: 0; }
  .spm-main { padding: 1rem; }
}
