/* ═══════════════════════════════════════════════════════════════
   BOREEAL CALENDAR — Design System
   Pure, light, airy. Inspired by Linear/Notion/Cal.com
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Core */
  --bg: #FAFBFC;
  --surface: #FFFFFF;
  --border: #E8ECF0;
  --border-light: #F0F3F6;
  --text: #1A1D21;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;

  /* Platform colors */
  --booking: #003580;
  --booking-bg: #EFF6FF;
  --booking-border: #004A99;
  --airbnb: #E85D75;
  --airbnb-bg: #FFF1F2;
  --airbnb-border: #FECDD3;
  --direct: #10B981;
  --direct-bg: #ECFDF5;
  --direct-border: #A7F3D0;
  --blocked: #FFFFFF;
  --blocked-bg: #DC2626;
  --blocked-border: #B91C1C;
  --cancelled: #DC2626;

  /* Accent */
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --danger: #EF4444;
  --warning: #F59E0B;

  /* Sizing */
  --header-h: 60px;
  --tabs-h: 48px;
  --cell-min-h: 140px;
  --radius: 8px;
  --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Header ─────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo {
  height: 36px;
  width: 36px;
  object-fit: cover;
  border-radius: 8px;
}
.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.logo-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.year-label {
  font-size: 18px;
  font-weight: 600;
  min-width: 60px;
  text-align: center;
  letter-spacing: -0.3px;
}

.month-selector {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  appearance: auto;
}
.month-selector:focus {
  outline: none;
  border-color: var(--primary);
}

.nav-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.nav-btn:hover { background: var(--bg); border-color: var(--text-muted); }

.btn-today {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.btn-today:hover { background: var(--bg); }

.header-right { display: flex; align-items: center; }

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 10px;
}

/* ─── Property Tabs ──────────────────────────────────────────── */
.property-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--header-h);
  z-index: 99;
}

.prop-tab {
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.prop-tab:hover { background: var(--bg); }
.prop-tab.active {
  background: var(--text);
  color: white;
}

/* ─── Calendar Container ─────────────────────────────────────── */
.calendar-container {
  padding: 16px 24px 100px;
}

/* ─── Month Sections ─────────────────────────────────────────── */
.month-section {
  margin-bottom: 32px;
}

.month-header {
  position: sticky;
  top: calc(var(--header-h) + var(--tabs-h) + 2px);
  z-index: 50;
  background: var(--bg);
  padding: 12px 0 8px;
}
.month-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* ─── Calendar Grid ──────────────────────────────────────────── */
.calendar-section {
  margin-bottom: 24px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.day-header {
  padding: 6px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.day-cell {
  min-height: var(--cell-min-h);
  padding: 6px;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
  overflow: visible;
  isolation: auto;
}
.day-cell:nth-child(7n) { border-right: none; }
.day-cell:hover { background: #F8FAFD; }
.day-cell.other-month {
  background: #F0F1F3;
}
.day-cell.other-month .day-number {
  color: var(--text-muted);
  opacity: 0.35;
}
.day-cell.other-month .event-bar,
.day-cell.other-month .turnover-row {
  display: none;
}
.day-cell.other-month .note-indicator {
  display: none;
}

/* Today */
.day-cell.today { background: #FEFCE8; }
.day-cell.today .day-number {
  background: var(--text);
  color: white;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Past dates */
.day-cell.past {
  background: #F8F9FA;
}
.day-cell.past .day-number {
  color: var(--text-muted);
}
.day-cell.past .event-bar,
.day-cell.past .turnover-row .event-bar {
  opacity: 0.5;
}
.day-cell.past .event-bar.bar-blocked,
.day-cell.past .turnover-row .event-bar.bar-blocked {
  opacity: 0.75;
}

.day-number {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  display: inline-flex;
}

/* ─── Event Bars (continuous) ────────────────────────────────── */
.event-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 18px;
  margin: 1px 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  cursor: pointer;
  white-space: nowrap;
  overflow: visible;
  transition: opacity 0.12s;
  border-left: 3px solid transparent;
  padding: 0 6px;
  /* Default: full width, no rounding */
  border-radius: 0;
  margin-left: -6px;
  margin-right: -6px;
  padding-left: 8px;
}
.event-bar:hover { opacity: 0.8; }

/* Bar shapes — half-cell start/end for hotel-style check-in/out */
.event-bar.bar-start {
  border-radius: 4px 0 0 4px;
  margin-left: 50%;
  margin-right: -6px;
  z-index: 20;
}
.event-bar.bar-end {
  border-radius: 0 4px 4px 0;
  margin-left: -6px;
  margin-right: 50%;
  border-left: none;
  z-index: 1;
}
.event-bar.bar-mid {
  border-radius: 0;
  margin-left: -6px;
  margin-right: -6px;
  border-left: none;
  z-index: 1;
}
.event-bar.bar-mid.bar-row-start {
  border-left: 3px solid;
  z-index: 20;
}
.event-bar.bar-single {
  border-radius: 4px;
  margin-left: 50%;
  margin-right: 0;
  z-index: 5;
}

/* Blocked — half-cell start/end (same as reservations: PM arrival, AM departure) */
.event-bar.bar-blocked {
  background: var(--blocked-bg);
  border-left-color: var(--blocked);
  color: var(--blocked);
  font-style: italic;
}

/* ─── Turnover Rows (departure + arrival same day) ───────────── */
.turnover-row {
  display: flex;
  gap: 2px;
  margin: 2px 0;
}
.turnover-row .event-bar {
  flex: 1;
  min-width: 0;
  margin-top: 0;
  margin-bottom: 0;
  height: 18px;
  line-height: 18px;
  font-size: 10px;
}

/* Departure half: comes from left, ends at mid-cell (check-out morning) */
.event-bar.turnover-dep {
  border-radius: 0 5px 5px 0;
  margin-left: -6px;
  margin-right: 0;
  border-left: none;
  padding-right: 4px;
  z-index: 1;
}

/* Arrival half: starts at mid-cell, extends right (check-in afternoon) */
.event-bar.turnover-arr {
  border-radius: 5px 0 0 5px;
  margin-left: 0;
  margin-right: -6px;
  border-left: 3px solid;
  padding-left: 4px;
  z-index: 20;
}

/* Solo departure (no matching arrival) — ends at mid-cell */
.event-bar.turnover-dep-solo {
  border-radius: 0 5px 5px 0;
  margin-left: -6px;
  margin-right: 50%;
  border-left: none;
  opacity: 0.8;
  z-index: 1;
}

.turnover-arrow {
  font-size: 9px;
  opacity: 0.5;
  margin: 0 1px;
  flex-shrink: 0;
}

/* ─── Bar Content ────────────────────────────────────────────── */
/* Property badge in merged view */
.bar-prop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 5px;
  background: rgba(255,255,255,0.2);
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.bar-prop.blk {
  background: rgba(255,255,255,0.2);
}

.bar-name {
  overflow: visible;
  font-weight: 800;
  letter-spacing: -0.2px;
}

/* Arrival time */
.bar-time {
  margin-left: 5px;
  font-size: 10px;
  font-weight: 400;
  opacity: 0.65;
  flex-shrink: 0;
}

/* Breakfast icon */
.bar-breakfast {
  margin-left: 4px;
  font-size: 11px;
  flex-shrink: 0;
  line-height: 1;
}

/* Tab dot */
.tab-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.day-cell .more-events {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 4px;
  cursor: pointer;
}

.note-indicator {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 10px;
  color: var(--warning);
}

/* ─── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
}
.modal-header h3 {
  font-size: 17px;
  font-weight: 600;
}
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─── Detail modal ───────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.detail-item { }
.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.detail-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.detail-item.full { grid-column: 1 / -1; }
.detail-grid .form-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  box-sizing: border-box;
}
.detail-grid .form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}
.detail-value.notes-text {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.confirmed { background: var(--booking-bg); color: var(--booking); }
.status-badge.completed { background: var(--direct-bg); color: var(--direct); }
.status-badge.cancelled { background: #FEE2E2; color: var(--danger); }
.status-badge.no-show { background: #FEF3C7; color: var(--warning); }

/* ─── Forms ──────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.form-panel { display: none; }
.form-panel.active { display: block; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.form-group {
  margin-bottom: 12px;
}
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  text-transform: none !important;
  font-weight: 500 !important;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] { width: auto; }

.form-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--blocked);
  color: white;
}
.btn-secondary:hover { background: #64748B; }
.btn-accent {
  background: var(--warning);
  color: white;
}
.btn-accent:hover { background: #D97706; }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: #FEF2F2; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

/* ─── FAB ────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--text);
  color: white;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  transition: all 0.2s;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }
  .header-left { display: none; }
  .header-right { display: none; }
  .header-center { gap: 8px; }
  .year-label { font-size: 16px; min-width: 50px; }

  .property-tabs {
    padding: 8px 12px;
    overflow-x: auto;
    top: auto;
    position: sticky;
  }
  .prop-tab { padding: 6px 12px; font-size: 12px; white-space: nowrap; }

  .calendar-container { padding: 8px 8px 100px; }
  .day-cell { min-height: 80px; padding: 4px; }
  .day-number { font-size: 12px; }
  .event-bar { height: 20px; font-size: 10px; line-height: 20px; }
  .bar-breakfast { font-size: 10px; }

  .month-header { position: static; }
  .month-header h3 { font-size: 16px; }

  .modal { width: 95%; max-width: none; margin: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  .legend { display: none; }
}

@media (max-width: 480px) {
  .day-cell { min-height: 60px; }
  .event-bar { height: 18px; font-size: 9px; line-height: 18px; }
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Utility ────────────────────────────────────────────────── */
/* ─── Lane System (keep property lanes consistent in merged view) ── */
.prop-lane {
  height: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: visible;
  position: relative;
}
.prop-lane .event-bar {
  margin-top: 1px;
  margin-bottom: 1px;
}
.prop-lane .turnover-row {
  margin-top: 1px;
  margin-bottom: 1px;
}

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-12 { margin-top: 12px; }
.mb-8 { margin-bottom: 8px; }
