/*
  Transaction Calendar v2 — mobile-first CSS
  PASS 1 CLEANUP

  Goals:
  - Stop overlapping layers (header vs overlays)
  - Make the calendar grid clearly visible again
  - Make the form overlay scrollable and usable on small screens
  - Remove duplicate/conflicting auth styles (your file had two different auth blocks)
*/

:root {
  --bg: #0b1020;
  --card: #101a33;
  --text: #e9eefc;
  --muted: rgba(233, 238, 252, 0.72);
  --border: rgba(233, 238, 252, 0.12);

  --primary: #2563eb;
  --danger: #ef4444;

  /* Header height used ONLY for overlay padding offset */
  --app-header-h: 64px;

  /* Stable z-index layers (so we never guess) */
  --z-header: 10;
  --z-form: 1000;
  --z-auth: 2000;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);

  /*
    IMPORTANT FIX:
    Your header is "sticky", not "fixed".
    Sticky headers still take up space in the layout.
    So padding-top here creates a weird “double spacing / overlap” feeling.
  */
  padding-top: 0;
}

h1, h2, h3 { margin: 0; }

button, input { font: inherit; }

/* Utility */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }

/* ===============================
   Header (sticky)
=============================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);

  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);

  padding: 0.9rem;
  display: flex;
  gap: 0.75rem;
  flex-direction: column;

  /* Ensure header has a stable height so overlays can offset correctly */
  min-height: var(--app-header-h);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

@media (min-width: 800px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .header-actions {
    grid-template-columns: repeat(3, auto);
  }
}

/* Header title + pill */
.title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.user-pill {
  margin: 0;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  width: fit-content;
}

/* Status card under header */
.status-card {
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  display: grid;
  gap: 0.5rem;
}

.status-actions {
  display: flex;
  justify-content: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Auth button row */
.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

/* ===============================
   Buttons
=============================== */
button {
  border: 1px solid var(--border);
  background: var(--primary);
  color: white;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}

button.secondary {
  background: navy;
}

button.danger {
  background: var(--danger);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===============================
   Page container
=============================== */
main {
  padding: 1rem;
  max-width: 1000px;
  margin: 0 auto;
}

/* ===============================
   Auth overlay (ONE definition only)
=============================== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-auth);

  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-overlay.hidden {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.auth-form {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.auth-form input {
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.auth-error {
  min-height: 1.25rem;
  color: #fecaca;
  margin: 0;
}

.auth-info {
  min-height: 1.25rem;
  color: #86efac;
  margin: 0;
}

.auth-link-btn {
  background: transparent;
  border: none;
  color: var(--text);
  opacity: 0.85;
  padding: 0;
  text-align: left;
  text-decoration: underline;
}

.auth-link-btn:hover {
  opacity: 1;
}

.reset-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.reset-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.reset-card form {
  display: grid;
  gap: 0.6rem;
}

.reset-card input {
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

/* ===============================
   Transaction picker (edit list)
=============================== */
.transaction-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.transaction-list button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  text-align: left;
}

/* ===============================
   Calendar (RESTORED + COMPLETED)
   Your CSS was cut off mid-calendar, so the grid looked broken.
=============================== */
.calendar-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}

.calendar-header h2 {
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}

/* Each day cell */
.calendar-day {
  min-height: 90px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;

  box-shadow: 0 1px 0 rgba(255,255,255,0.05);

  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0.35rem;
}

/* Day number */
.calendar-day .day-number,
.calendar-day-header {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--muted);
}

/* Where events are appended */
.calendar-events {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

/* Event pill (deadline / closing / etc) */
.calendar-event {
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  font-size: 0.78rem;
  font-weight: 800;

  /* If your JS sets background color inline, this will still work */
  background: rgba(37, 99, 235, 0.35);
  border: 1px solid rgba(233, 238, 252, 0.18);

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===============================
   Notifications list
=============================== */
#notifications {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
}

#notificationList {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
/* ===============================
   Form overlay (POLISHED)
   - Always above header
   - Scrollable overlay
   - Offset below sticky header
=============================== */
#formOverlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-form); /* <-- uses your layer system */

  background: rgba(0, 0, 0, 0.65);

  /*
    The overlay itself scrolls on small screens.
    This is the biggest UX upgrade for long forms.
  */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  /*
    Push modal below the sticky header so it never gets covered.
    (Header is sticky, so it still sits visually "on top" of content.)
  */
  padding: calc(var(--app-header-h) + 12px) 12px 12px;

  /*
    Keep it simple: align to top, centered horizontally.
    (Centering vertically looks nice but causes clipping issues.)
  */
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* ===============================
   Form overlay (RESTORED + SCROLLABLE)
   Your HTML did not have the class needed for overlay styling.
=============================== */
.form-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-form);

  background: rgba(0,0,0,0.55);

  /* Overlay itself can scroll on small screens */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  /*
    Push the modal down so the sticky header does not cover it.
    This is why we keep --app-header-h.
  */
  padding: calc(var(--app-header-h) + 12px) 12px 12px;

  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* The modal box itself */
.transaction-form {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;

  display: grid;
  gap: 0.75rem;

  /* If form is taller than viewport, it scrolls inside too */
  max-height: calc(100vh - var(--app-header-h) - 24px);
  overflow-y: auto;
}

.transaction-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.transaction-form input {
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.transaction-form select {
  padding: 0.75rem;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.team-input {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.team-input input {
  flex: 1 1 220px;
}

.team-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.team-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.team-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.team-list {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.35rem;
}

.team-list li {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#teamSelect {
  display: flex;
}

.team-selected {
  display: flex;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(37, 99, 235, 0.12);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

@media (min-width: 720px) {
  .team-columns {
        flex-direction: row;
  }

  .team-columns > div {
    flex: 1 1 0;
  }
}

@media (min-width: 520px) {
  .form-actions {
    grid-template-columns: 1fr 1fr;
  }
}


/* Mobile tweak */
@media (max-width: 600px) {
  .calendar-grid { gap: 0.4rem; }
  .calendar-day { min-height: 85px; }
}
