/* =========================
   RESET + BASE
========================= */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(circle at top, #0f172a 0%, #020617 65%);
  color: #e5e7eb;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

a { color: inherit; }

.hidden { display: none !important; }

/* Evită zoom / gesturi ciudate pe mobile */
html, body {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
#calendar { touch-action: manipulation; }

/* =========================
   FULLCALENDAR THEME (global)
========================= */
.fc {
  --fc-page-bg-color: transparent;
  --fc-border-color: rgba(255,255,255,.12);
  --fc-neutral-bg-color: rgba(255,255,255,.06);
  --fc-neutral-text-color: rgba(255,255,255,.86);
  --fc-today-bg-color: rgba(59,130,246,.14);
  color: rgba(255,255,255,.92);
}

/* ascunde toolbar-ul FullCalendar (folosim header-ul nostru iOS) */
.fc .fc-header-toolbar { display: none !important; }

/* header zile */
.fc .fc-col-header-cell-cushion {
  padding: 10px 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
}

/* TimeGrid labels */
.fc .fc-timegrid-slot-label-cushion,
.fc .fc-timegrid-axis-cushion {
  color: rgba(255,255,255,.62);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .2px;
}

/* azi */
.fc .fc-day-today { background: rgba(59,130,246,.14) !important; }

/* zile trecute (soft) */
.fc .fc-day-past { opacity: .72; }

/* =========================
   iOS-like MONTH VIEW (fix height + pills + text)
========================= */

/* scoatem grila tip “table” */
.fc-theme-standard .fc-scrollgrid,
.fc-theme-standard td,
.fc-theme-standard th {
  border: 0 !important;
}

/* separatoare între săptămâni */
.fc .fc-daygrid-body tr {
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.fc .fc-daygrid-body tr:last-child { border-bottom: 0; }

/* fiecare zi: înălțime fixă => rândurile NU se mai întind */
.fc .fc-daygrid-day-frame {
  display: flex;
  flex-direction: column;
  padding: 10px 10px 14px;
  min-height: 132px;
  max-height: 132px;
}

/* numărul zilei */
.fc .fc-daygrid-day-number {
  font-size: 22px;
  font-weight: 800;
  color: rgba(255,255,255,.92);
  padding: 0;
}

/* zile outside month fade */
.fc .fc-day-other .fc-daygrid-day-number {
  color: rgba(255,255,255,.25);
}

/* zona de evenimente: taie overflow */
.fc .fc-daygrid-day-events {
  flex: 1 1 auto;
  overflow: hidden;
  margin-top: 6px;
}

/* spațiere mică între evenimente */
.fc .fc-daygrid-event-harness { margin-top: 4px !important; }

/* event container (FullCalendar) */
.fc .fc-daygrid-event {
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 12px !important;

  /* IMPORTANT: păstrăm culoarea de background dată de FullCalendar (eventColor) */
  color: #fff !important;
  overflow: hidden;
}

/* FullCalendar pune conținutul în fc-event-main – îl lăsăm gol, noi randăm în .ev-pill */
.fc .fc-daygrid-event .fc-event-main { padding: 0 !important; color: #fff !important; }

/* pill-ul nostru */
.ev-pill {
  background: transparent !important;
  border-radius: 12px;
  padding: 2px 6px;
  line-height: 1.15;
  max-width: 100%;
}

/* o linie: “HH:mm Nume”, cu ellipsis */
.ev-title {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* dacă mai există elemente default, nu le ascundem (doar le facem inline) */
.fc .fc-daygrid-event .fc-event-title,
.fc .fc-daygrid-event .fc-event-time {
  display: inline !important;
  color: #fff !important;
}

/* "+X more" */
.fc-daygrid-more-link,
.fc .fc-more-link {
  margin-top: 4px !important;
  font-size: 11px !important;
  font-weight: 800 !important;
  color: rgba(255,255,255,.65) !important;
}

/* =========================
   TIMEGRID / DAY VIEW (events)
========================= */
.fc .fc-timegrid-event {
  border-radius: 10px !important;
  border: 1px solid rgba(255,255,255,.30) !important;
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
  overflow: hidden;
}

.fc .fc-timegrid-event .fc-event-main {
  padding: 6px 8px;
  color: rgba(255,255,255,.96) !important;
}

.fc .fc-timegrid-event .fc-event-title,
.fc .fc-timegrid-event .fc-event-time {
  color: rgba(255,255,255,.96) !important;
  font-weight: 800;
  font-size: 12px;
}

/* =========================
   MOBILE tweaks (timegrid)
========================= */
@media (max-width: 900px) {
  .fc .fc-timegrid-slot { height: 48px; }
  .fc .fc-timegrid-axis { width: 46px !important; }
}

/* =========================
   MODALS (appointment/search/settings)
========================= */

/* Appointment modal (backdrop + box) */
#modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}
#modalBackdrop.hidden { display: none !important; }

#modal {
  position: relative;
  width: min(96vw, 520px);
  max-height: 85vh;
  overflow: auto;
  background: #020617;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 25px 60px rgba(0,0,0,.65);
  z-index: 9999;
}
#modal.hidden { display: none !important; }

#modal h2, #modal h3 {
  margin: 0 0 10px 0;
  color: #f9fafb;
  font-weight: 900;
  letter-spacing: .2px;
}

#modal label {
  display: block;
  margin-top: 10px;
  margin-bottom: 6px;
  color: rgba(255,255,255,.72);
  font-weight: 700;
  font-size: 12px;
}

#modal input,
#modal select,
#modal textarea {
  width: 100%;
  background: #0b1220;
  border: 1px solid rgba(255,255,255,.16);
  color: #f9fafb;
  border-radius: 10px;
  padding: 12px 12px;
  outline: none;
  font-size: 16px; /* important pt iOS: fără zoom */
}

#modal textarea {
  min-height: 90px;
  resize: vertical;
}

#modal .modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}

#modal button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 900;
  color: #fff;
}
#modal button:hover { filter: brightness(1.08); }

#saveBtn { background: #22c55e !important; }
#saveBtn:hover { background: #16a34a !important; }

#deleteBtn { background: #233754 !important; }
#deleteBtn:hover { background: #1b2c43 !important; }

#cancelBtn { background: #ef4444 !important; }
#cancelBtn:hover { background: #dc2626 !important; }

/* Search modal */
#searchBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
  z-index: 9998;
}
#searchBackdrop.hidden { display: none !important; }

#searchModal {
  width: min(96vw, 560px);
  background: #020617;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  box-shadow: 0 25px 60px rgba(0,0,0,.65);
  overflow: hidden;
  z-index: 9999;
}
#searchModal.hidden { display: none !important; }

.search-head {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
#searchInput {
  flex: 1;
  width: 100%;
  background: #0b1220;
  border: 1px solid rgba(255,255,255,.16);
  color: #f9fafb;
  border-radius: 12px;
  padding: 12px 12px;
  outline: none;
  font-size: 16px;
}
.search-results {
  max-height: 70vh;
  overflow: auto;
}
.search-item {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
}
.search-item:hover { background: rgba(255,255,255,.04); }
.search-item .t { font-weight: 900; }
.search-item .s {
  margin-top: 2px;
  opacity: .75;
  font-weight: 700;
  font-size: 12px;
}

/* Settings modal */
#settingsBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  z-index: 9998;
}
#settingsBackdrop.hidden { display: none !important; }

#settingsModal {
  width: min(96vw, 560px);
  background: #020617;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0,0,0,.65);
  padding: 14px;
  z-index: 9999;
}
#settingsModal.hidden { display: none !important; }

.settings-title {
  margin: 4px 4px 10px;
  font-size: 20px;
  font-weight: 900;
}

.settings-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  padding: 12px;
}

.rowline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.label { opacity: .65; font-weight: 800; font-size: 12px; }
.value { margin-top: 2px; }

.switchline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  font-weight: 800;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}

.chip-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: #f9fafb;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
}
.chip-btn:hover { background: rgba(255,255,255,.10); }
.chip-btn.danger {
  border-color: rgba(255,69,58,.35);
  color: #ff453a;
}

/* =========================
   iOS SHELL (header + tabbar)
========================= */
.ios-shell {
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

.ios-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 16px 8px;
  background: rgba(0,0,0,.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.ios-toprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ios-back {
  appearance: none;
  border: 0;
  background: transparent;
  color: #ff453a;
  font-weight: 800;
  padding: 8px 6px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.ios-back .chev { font-size: 22px; line-height: 1; }

.ios-icons {
  display: inline-flex;
  gap: 10px;
  align-items: center;
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: #ff453a; }

.ios-title {
  margin-top: 6px;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: .2px;
  text-transform: capitalize;
}

.ios-main { padding: 0 0 8px; }

.ios-tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(0,0,0,.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(255,255,255,.10);
}

.tab-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #ff453a;
  font-weight: 800;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
}
.tab-btn.active { background: rgba(255,69,58,.14); }