/* Elyzea admin — brand tokens mirrored from web/assets/css/styles.css */
:root {
  --color-ivory: #F5F0EB;
  --color-linen: #EDE8E2;
  --color-gold: #C5A572;
  --color-gold-dark: #7D6230;
  --color-dark: #2D2D2D;
  --color-muted: #6B6459;
  --color-white: #FFFFFF;
  --radius: 8px;
  --shadow: 0 4px 20px rgba(0,0,0,.08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--color-ivory); color: var(--color-dark); }
.hidden { display: none !important; }
.muted { color: var(--color-muted); font-size: .9rem; }
.error { color: #b3261e; min-height: 1.2em; font-size: .9rem; }

button { cursor: pointer; border: none; border-radius: var(--radius); padding: .55rem 1rem; font-size: .9rem; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Loading state: dim + a spinner (visible on touch too, where cursor:progress isn't). */
button.is-loading { opacity: .75; cursor: progress; pointer-events: none; }
button.is-loading::before {
  content: ""; display: inline-block; width: .85em; height: .85em;
  margin-right: .45em; vertical-align: -.12em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .6s linear infinite;
}
button.primary { background: var(--color-gold); color: #fff; }
button.primary:hover { background: var(--color-gold-dark); }
button.ghost { background: transparent; color: var(--color-muted); border: 1px solid var(--color-linen); }
button.danger { background: #b3261e; color: #fff; }
input, select { padding: .5rem .6rem; border: 1px solid #d8d0c6; border-radius: var(--radius); font-size: .9rem; background: #fff; }

/* Login */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--color-ivory); }
.login-card { background: #fff; padding: 2.5rem; border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .75rem; width: 320px; }
.brand { letter-spacing: .35em; text-align: center; margin: 0; font-weight: 600; }
.brand-sub { text-align: center; color: var(--color-muted); margin: 0 0 1rem; font-size: .85rem; }
.login-card button { background: var(--color-gold); color: #fff; padding: .7rem; }

/* Topbar */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; background: var(--color-dark); color: #fff; flex-wrap: wrap; }
.brand-small { letter-spacing: .2em; font-weight: 600; font-size: .85rem; }
.tabs { display: flex; gap: .25rem; }
.tab { background: transparent; color: #cfc9c0; padding: .4rem .8rem; }
.tab.active { background: rgba(255,255,255,.12); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.who { font-size: .8rem; color: #cfc9c0; }

main { padding: 1rem 1.2rem 3rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }

/* Wider calendar so the 7 day-columns aren't cramped. Its height is set as a px value
   by calH() in app.js so the grid fits the viewport and the time grid scrolls internally. */
#calendar { background: #fff; padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 1400px; }

/* Calendar legend (confirmation colour code) */
.legend { display: flex; flex-wrap: wrap; gap: .2rem 1rem; margin: 0 0 .6rem; font-size: .82rem; color: var(--color-muted); max-width: 1400px; }
.legend__item { display: inline-flex; align-items: center; gap: .35rem; }
.legend__dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
/* The grid is always Lima time; amber when the device clock disagrees (see renderTzNote). */
.legend__tz { margin-left: auto; }
.legend__tz--warn { color: #e0a32e; font-weight: 600; }

/* Comfortable week/day grid: taller rows + wrapping, readable event titles. */
.fc .fc-timegrid-slot { height: 2.2em; }
/* Closed time (see businessHours in app.js: Mon-Fri 13:00-20:00 since 2026-08-30) —
   the whole Sat/Sun column plus the 8am-1pm and 8-9pm strips. Brand linen instead of
   FullCalendar's default flat grey, so it reads as part of the app. Advisory only:
   dragging an appointment there still works, because the team needs that escape hatch. */
.fc .fc-non-business { background: var(--color-linen); opacity: .85; }
.fc-timegrid-event .fc-event-main { padding: 2px 5px; }
.fc-timegrid-event .fc-event-title { white-space: normal; font-size: .8rem; line-height: 1.2; font-weight: 500; }
/* Cancelled appointments: shown but struck through + faded — in the timegrid, month,
   AND the mobile agenda/list view (whose titles use .fc-list-event-title, not .fc-event-title). */
.ev-cancelled { opacity: .65; }
.ev-cancelled .fc-event-title,
.ev-cancelled .fc-list-event-title,
.ev-cancelled .fc-list-event-title a { text-decoration: line-through; }

/* Cards (responsive lists) */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .7rem; max-width: 1000px; }
.cards > p { grid-column: 1 / -1; }
.card { background: #fff; border: 1px solid var(--color-linen); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem .9rem; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--color-gold); }
.card__title { font-weight: 600; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.card__sub { color: var(--color-muted); font-size: .85rem; margin-top: .2rem; }
.card__row { display: flex; gap: .7rem; align-items: flex-end; flex-wrap: wrap; margin-top: .6rem; }
.card__field { display: flex; flex-direction: column; gap: .15rem; font-size: .72rem; color: var(--color-muted); }
.card__field input[type=number] { width: 88px; padding: .4rem .5rem; border: 1px solid #d8d0c6; border-radius: var(--radius); font-size: .9rem; }
.card__field--check { flex-direction: row; align-items: center; gap: .35rem; font-size: .85rem; color: var(--color-dark); }
.cards__more { grid-column: 1 / -1; justify-self: center; margin-top: .3rem; }
.badge { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 4px; background: var(--color-linen); color: var(--color-gold-dark); }
.badge--off { background: #f3e0de; color: #b3261e; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; flex: none; }

/* History list (client modal) */
.hist-list { display: flex; flex-direction: column; gap: .4rem; }
.hist { padding: .5rem .6rem; border: 1px solid var(--color-linen); border-radius: var(--radius); }
.hist--legacy { background: #faf7f3; }
.hist__main { font-size: .92rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* Clients */
.head-actions { display: flex; gap: .5rem; }
#client-search { width: 100%; max-width: 360px; margin: .2rem 0 .9rem; }
.filter-select { margin: .2rem 0 .9rem; max-width: 360px; }
.modal-card--wide { width: 680px; max-width: 92vw; max-height: 85vh; overflow-y: auto; }
.modal-card--wide h4 { margin: 1.1rem 0 .5rem; }
.cd-imported { margin: .2rem 0 .6rem; font-size: .9rem; line-height: 1.5; max-width: 1000px; }
.legacy-tag { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 4px; background: var(--color-linen); color: var(--color-gold-dark); }
.cd-notes { display: grid; gap: .4rem; max-width: 520px; margin: .3rem 0 .6rem; }
.cd-notes label { color: var(--color-muted); font-size: .85rem; }
.cd-notes textarea { padding: .5rem .6rem; border: 1px solid #d8d0c6; border-radius: var(--radius); font-size: .9rem; font-family: inherit; resize: vertical; }
.cd-notes button { justify-self: start; }

/* Hours editor */
.hours-editor { display: grid; gap: .4rem; max-width: 540px; margin: .8rem 0; }
.hours-day { display: flex; align-items: center; gap: .5rem; }
.hours-day .day-name { width: 90px; }
.hours-day input[type=time] { width: 110px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50; }
.modal-card { background: #fff; padding: 1.5rem; border-radius: 14px; width: 380px; max-width: 92vw; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 1rem; }
.modal .row { display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: .5rem; margin-bottom: .6rem; }
.modal .row label { color: var(--color-muted); font-size: .85rem; }
/* Uniform control width: minmax(0,1fr) + min-width:0 stop long <select>/date
   options from forcing their column (and the card) wider than the rest. */
.modal .row input:not([type=checkbox]), .modal .row select { width: 100%; min-width: 0; }
/* WhatsApp field: input + "open chat" icon */
.wa-field { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.wa-field input { flex: 1; min-width: 0; }
.wa-open { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 38px; padding: .45rem; background: #25D366; color: #fff; border-radius: var(--radius); }
.wa-open:hover { background: #1ebe5b; }
.modal .check-inline { display: flex; align-items: center; gap: .4rem; margin-top: .45rem; font-size: .85rem; }
.modal .check-inline input { width: auto; }
/* Client picker (appointment modal) */
.client-pick { position: relative; }
.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 60; background: #fff; border: 1px solid #d8d0c6; border-top: none; border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); max-height: 220px; overflow-y: auto; }
.suggest-item { padding: .45rem .6rem; cursor: pointer; font-size: .9rem; }
.suggest-item:hover { background: var(--color-ivory); }
.suggest-item .s-phone { color: var(--color-muted); font-size: .8rem; }
.client-status { font-size: .8rem; min-height: 1em; }
.client-status.exists { color: var(--color-gold-dark); }
.client-status.new { color: var(--color-muted); }

.modal-actions { display: flex; align-items: center; gap: .5rem; margin-top: 1rem; }
.modal-actions .spacer { flex: 1; }
.confirmed-tag { font-size: .8rem; color: var(--color-gold-dark); }
hr { border: none; border-top: 1px solid var(--color-linen); margin: 1.5rem 0; }
h2 small { color: var(--color-muted); font-weight: 400; font-size: .8rem; }

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  main { padding: .8rem .7rem 3rem; }

  /* Mobile shows only the Calendario + Clientes tabs */
  .desktop-only { display: none !important; }

  /* Topbar: keep brand + filter on top, let tabs wrap to a scrollable row */
  .topbar { gap: .5rem .75rem; padding: .55rem .8rem; }
  .topbar-right { margin-left: 0; width: 100%; order: 3; }
  .tabs { order: 4; width: 100%; overflow-x: auto; gap: .15rem; -webkit-overflow-scrolling: touch; }
  .tab { padding: .4rem .6rem; white-space: nowrap; }
  #staff-filter { flex: 1; min-width: 0; }

  /* Calendar header: stack title and button groups instead of cramming one row */
  #calendar { padding: .6rem; }
  .fc .fc-toolbar.fc-header-toolbar { flex-direction: column; align-items: stretch; gap: .5rem; margin-bottom: .8rem; }
  .fc .fc-toolbar-title { font-size: 1.15rem; text-align: center; white-space: normal; }
  .fc .fc-toolbar-chunk { display: flex; justify-content: center; flex-wrap: wrap; gap: .25rem; }
  .fc .fc-button { padding: .3rem .6rem; font-size: .85rem; }
  /* Agenda (list) view — the mobile "week": roomy, tappable rows. */
  .fc .fc-list-event-title { font-size: .95rem; padding: .55rem .4rem; }
  /* Agenda: make the start time the clear anchor of each row. */
  .fc .fc-list-event-time { font-size: .9rem; font-weight: 700; color: var(--color-dark); white-space: nowrap; min-width: 4.7rem; padding: .55rem .5rem; }
  .fc .fc-list-event-dot { border-width: 6px; }
  .fc .fc-list-day-cushion { font-size: .9rem; }
  /* Month view — smaller event chips + bigger day-number tap target. */
  .fc .fc-daygrid-event { font-size: .68rem; padding: 0 2px; }
  .fc .fc-daygrid-day-number { font-size: .9rem; padding: 4px 6px; }

  .panel-head { flex-wrap: wrap; gap: .5rem; }
  .head-actions { flex-wrap: wrap; }
  .modal-card { padding: 1rem; width: 100%; max-width: 96vw; }
  .modal-card--wide { max-height: 92vh; }
}
