@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ─── RESET & BASE ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:      #0D1B2A;
  --navy-mid:  #162436;
  --sand:      #F2E8D9;
  --sand-dark: #E8D9C4;
  --terra:     #C4622D;
  --terra-lt:  #D4734A;
  --gold:      #D4A853;
  --white:     #FDFAF6;
  --text:      #2C2C2C;
  --muted:     #8A7F72;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(13,27,42,0.12);
  --shadow-lg: 0 12px 48px rgba(13,27,42,0.18);
  --transition: 0.25s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--sand);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* Grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

h1, h2, h3 { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 500; }

a { color: var(--terra); text-decoration: none; }
a:hover { color: var(--terra-lt); }

/* ─── HEADER / NAV ─── */
.site-header {
  background: var(--navy);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.3);
}

.site-header .logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  color: var(--sand);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.site-header .logo span { color: var(--gold); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a, .nav-links button {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(242,232,217,0.7);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 6px;
  transition: all var(--transition);
}

.nav-links a:hover, .nav-links button:hover {
  color: var(--sand);
  background: rgba(255,255,255,0.08);
}

.nav-links a.active { color: var(--gold); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sand);
  font-size: 14px;
}

.badge-admin {
  background: var(--terra);
  color: white;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
}

/* ─── MAIN CONTAINER ─── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px;
}

/* ─── LOGIN PAGE ─── */
.login-page {
  min-height: 100vh;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(196,98,45,0.15) 0%, transparent 70%);
  top: -100px; right: -100px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(212,168,83,0.1) 0%, transparent 70%);
  bottom: -50px; left: -50px;
}

.login-card {
  background: var(--navy-mid);
  border: 1px solid rgba(242,232,217,0.1);
  border-radius: 20px;
  padding: 56px 48px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease;
}

.login-card .house-icon {
  text-align: center;
  margin-bottom: 24px;
  font-size: 40px;
}

.login-card h1 {
  font-size: 32px;
  color: var(--sand);
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.2;
}

.login-card .subtitle {
  color: var(--gold);
  text-align: center;
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 40px;
  font-family: 'DM Sans', sans-serif;
}

.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(242,232,217,0.6);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(242,232,217,0.15);
  border-radius: 8px;
  color: var(--sand);
  font-family: 'DM Sans', sans-serif;
  font-size: 15px;
  transition: all var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--gold);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 3px rgba(212,168,83,0.15);
}

.form-group input::placeholder { color: rgba(242,232,217,0.3); }

.btn-primary {
  width: 100%;
  padding: 15px;
  background: var(--terra);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}

.btn-primary:hover {
  background: var(--terra-lt);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(196,98,45,0.4);
}

.btn-primary:active { transform: translateY(0); }

.error-msg {
  background: rgba(196,98,45,0.15);
  border: 1px solid rgba(196,98,45,0.4);
  color: #f4a07a;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-top: 16px;
  display: none;
}

/* ─── CALENDAR ─── */
.calendar-section { margin-bottom: 40px; }

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.calendar-header h2 {
  font-size: 28px;
  color: var(--navy);
  font-weight: 400;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.month-nav button {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--sand-dark);
  background: white;
  cursor: pointer;
  font-size: 18px;
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}

.month-nav button:hover {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.month-nav .month-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  color: var(--navy);
  min-width: 200px;
  text-align: center;
}

.calendar-grid {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--navy);
}

.calendar-weekdays div {
  padding: 12px 0;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(242,232,217,0.6);
}

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

.calendar-day {
  min-height: 90px;
  padding: 8px 8px 34px 8px; /* bottom space for bar */
  border-right: 1px solid #f0ebe4;
  border-bottom: 1px solid #f0ebe4;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  overflow: visible;
}

.calendar-day:nth-child(7n) { border-right: none; }
.calendar-day:hover:not(.empty):not(.past) { background: #fdf8f4; }

.calendar-day.empty { background: #fafafa; cursor: default; }
.calendar-day.past { opacity: 0.45; cursor: not-allowed; }
.calendar-day.today .day-num {
  background: var(--gold);
  color: white;
  border-radius: 50%;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
}

.day-num {
  font-size: 13px;
  font-weight: 500;
  color: var(--navy);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
  position: relative;
  z-index: 2;
}

/* ─── BOOKING BARS (spanning) ─── */
.booking-bar {
  position: absolute;
  left: -1px;   /* bridge the 1px cell border to neighbour */
  right: -1px;
  height: 22px;
  display: flex;
  align-items: center;
  z-index: 1;
  pointer-events: none;
}

/* First visible day of a booking segment: inset left + rounded left */
.booking-bar.bar-start {
  left: 5px;
  border-radius: 6px 0 0 6px;
}

/* Last visible day of a booking segment: inset right + rounded right */
.booking-bar.bar-end {
  right: 5px;
  border-radius: 0 6px 6px 0;
}

/* Single-day booking or segment (start AND end) */
.booking-bar.bar-start.bar-end {
  left: 5px;
  right: 5px;
  border-radius: 6px;
}

.booking-bar.own    { background: rgba(196, 98,  45, 0.22); }
.booking-bar.other  { background: rgba( 13, 27,  42, 0.13); }
.booking-bar.agency {
  background: repeating-linear-gradient(
    45deg,
    rgba(0,0,0,0.07) 0px, rgba(0,0,0,0.07) 2px,
    rgba(0,0,0,0.02) 2px, rgba(0,0,0,0.02) 6px
  );
}

.bar-name {
  font-size: 10px;
  font-weight: 600;
  padding: 0 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.booking-bar.own   .bar-name { color: #7a2e08; }
.booking-bar.other .bar-name { color: #1a2e3f; }
.booking-bar.agency .bar-name { color: #6b5c4a; }

/* Legend */
.calendar-legend {
  display: flex;
  gap: 24px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.legend-bar {
  width: 32px;
  height: 12px;
  border-radius: 3px;
}

.legend-bar.own    { background: rgba(196,98,45,0.4); }
.legend-bar.other  { background: rgba(13,27,42,0.2); }
.legend-bar.agency {
  background: repeating-linear-gradient(
    45deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.04) 2px, rgba(0,0,0,0.04) 6px
  );
}

/* ─── STATS BAR ─── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--terra);
  animation: fadeIn 0.4s ease;
}

.stat-card .stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  color: var(--navy);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h2 {
  font-size: 26px;
  color: var(--navy);
  margin-bottom: 6px;
}

.modal .modal-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.modal .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--sand-dark);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}

.modal .form-group input:focus,
.modal .form-group select:focus,
.modal .form-group textarea:focus {
  border-color: var(--terra);
  box-shadow: 0 0 0 3px rgba(196,98,45,0.1);
}

.modal .form-group textarea { resize: vertical; min-height: 80px; }

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

.btn-secondary {
  flex: 1;
  padding: 13px;
  background: transparent;
  border: 1px solid var(--sand-dark);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover { border-color: var(--navy); color: var(--navy); }

.btn-confirm {
  flex: 2;
  padding: 13px;
  background: var(--terra);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-confirm:hover {
  background: var(--terra-lt);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(196,98,45,0.35);
}

.modal-error {
  background: rgba(196,98,45,0.1);
  border: 1px solid rgba(196,98,45,0.3);
  color: #a0400f;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

/* ─── BOOKINGS TABLE ─── */
.bookings-table-wrap {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.bookings-table-wrap table {
  width: 100%;
  border-collapse: collapse;
}

.bookings-table-wrap th {
  background: var(--navy);
  color: var(--sand);
  padding: 14px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.bookings-table-wrap td {
  padding: 14px 20px;
  border-bottom: 1px solid #f0ebe4;
  font-size: 14px;
}

.bookings-table-wrap tr:last-child td { border-bottom: none; }
.bookings-table-wrap tbody tr:hover { background: #fdfaf6; }

.type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.type-badge.family { background: rgba(196,98,45,0.15); color: #8b3515; }
.type-badge.agency { background: rgba(13,27,42,0.1); color: var(--navy); }

.btn-cancel {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(196,98,45,0.4);
  border-radius: 6px;
  color: var(--terra);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-cancel:hover {
  background: var(--terra);
  color: white;
  border-color: var(--terra);
}

/* ─── ADMIN PANEL ─── */
.admin-tabs {
  display: flex;
  gap: 4px;
  background: white;
  padding: 6px;
  border-radius: 10px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
  width: fit-content;
}

.admin-tab {
  padding: 10px 20px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}

.admin-tab.active {
  background: var(--navy);
  color: white;
}

.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }

/* Filters */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar select, .filter-bar input {
  padding: 9px 12px;
  border: 1px solid var(--sand-dark);
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: white;
  color: var(--text);
  outline: none;
}

.btn-pdf {
  padding: 10px 20px;
  background: var(--navy);
  color: var(--sand);
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-pdf:hover { background: var(--navy-mid); }

/* ─── PAGE HEADER ─── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header h1 {
  font-size: 40px;
  color: var(--navy);
  line-height: 1.1;
}

.page-header .subtitle {
  font-size: 15px;
  color: var(--muted);
  margin-top: 4px;
}

.btn-new-booking {
  padding: 12px 24px;
  background: var(--terra);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-new-booking:hover {
  background: var(--terra-lt);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(196,98,45,0.35);
}

/* ─── TOAST ─── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--navy);
  color: var(--sand);
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 9000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success { border-left: 4px solid var(--gold); }
.toast.error { border-left: 4px solid var(--terra); }

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 20px; color: var(--navy); margin-bottom: 8px; }

/* ─── ANIMATIONS ─── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.fade-in { animation: fadeIn 0.4s ease; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .site-header { padding: 0 16px; }
  .site-header .logo { font-size: 18px; }
  .nav-links a, .nav-links button { padding: 8px 10px; font-size: 12px; }
  .container { padding: 24px 16px; }
  .page-header h1 { font-size: 30px; }
  .calendar-day { min-height: 68px; padding-bottom: 30px; }
  .day-num { font-size: 12px; }
  .booking-bar { height: 20px; }
  .bar-name { font-size: 9px; padding: 0 5px; }
  .modal { padding: 28px 20px; }
  .modal .form-row { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 36px 24px; }
}

@media (max-width: 480px) {
  .stats-bar { grid-template-columns: 1fr; }
  .calendar-day { min-height: 44px; padding: 4px; }
  .nav-links .hide-mobile { display: none; }
}
