/* ====================================================
   BookingManager Simplify — Styles
   ==================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e2e5eb;
  --primary: #4F6DFF;
  --primary-light: #e8edff;
  --primary-hover: #3d5be6;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --indigo: #6366f1;
  --indigo-light: #e0e7ff;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --nav-h: 64px;
  --header-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --surface-2: #232840;
  --text: #e8eeff;
  --text-muted: #9aa8cf;
  --border: #2a3150;
  --primary: #6f8bff;
  --primary-light: #1e2547;
  --primary-hover: #5a75e8;
  --success-light: #0d3326;
  --warning-light: #3b2e0a;
  --danger-light: #3b1515;
  --indigo-light: #1e1f3d;
  --shadow: 0 2px 8px rgba(0,0,0,0.25);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  color-scheme: dark;
}

html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 28px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.form-error {
  color: var(--danger);
  font-size: 13px;
  background: var(--danger-light);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
}
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  margin-top: 16px;
  text-decoration: underline;
}

/* ---------- App Shell ---------- */
[hidden] { display: none !important; }
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--header-h);
  padding-top: var(--safe-t);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}
.app-title { font-size: 17px; font-weight: 700; }
.app-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
}
.section { display: none; padding: 16px; animation: fadeIn 0.2s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Bottom Nav ---------- */
.bottom-nav {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-top: 1px solid var(--border);
  height: var(--nav-h);
  padding-bottom: var(--safe-b);
  flex-shrink: 0;
  z-index: 20;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  transition: color 0.15s;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  position: relative;
}
.nav-btn.active { color: var(--primary); }
.nav-btn.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-weight: 500; }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  right: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79,109,255,0.4);
  z-index: 15;
  touch-action: manipulation;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.92); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.success { background: var(--success); color: #fff; }
.btn.warning { background: var(--warning); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn.outline:hover { background: var(--surface-2); }
.btn.small { padding: 6px 14px; font-size: 13px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  color: var(--text-muted);
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  border-radius: 50%;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- Form Elements ---------- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s;
  touch-action: manipulation;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 70px; }
label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 12px; }
.form-row > .form-group { flex: 1; }
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.form-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* Radio buttons as pills */
.radio-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.radio-pill input { display: none; }
.radio-pill span {
  padding: 6px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  color: var(--text-muted);
}
.radio-pill input:checked + span {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

/* Search bar */
.search-bar {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 24px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}
.search-bar:focus { border-color: var(--primary); background: var(--surface); }

.section-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.section-topbar-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
}

/* ---------- Cards ---------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: box-shadow 0.15s;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.card-title { font-weight: 600; font-size: 15px; }
.card-subtitle { color: var(--text-muted); font-size: 13px; }
.card-body { font-size: 14px; color: var(--text-muted); }
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.card-actions .btn { flex: 1; padding: 7px 10px; font-size: 12px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.scheduled { background: var(--warning-light); color: var(--warning); }
.badge.completed { background: var(--success-light); color: var(--success); }
.badge.paid { background: var(--indigo-light); color: var(--indigo); }
.badge.cancelled { background: var(--danger-light); color: var(--danger); }

/* ---------- Calendar ---------- */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cal-month-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
}
.cal-arrow { font-size: 14px; }
.calendar { margin-bottom: 16px; }
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.empty { cursor: default; }
.cal-cell.empty:hover { background: transparent; }
.cal-day-num {
  font-size: 14px;
  font-weight: 500;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.cal-cell.today .cal-day-num {
  border: 2px solid var(--primary);
  color: var(--primary);
  font-weight: 700;
}
.cal-cell.selected .cal-day-num {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.cal-cell.today.selected .cal-day-num { border-color: var(--primary); }
.cal-dots {
  display: flex;
  gap: 3px;
  margin-top: 1px;
  position: absolute;
  bottom: 3px;
}
.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.dot.pending { background: var(--warning); }
.dot.done { background: var(--success); }
.dot.money { background: var(--indigo); }

/* Agenda header */
.agenda-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.agenda-header h2 { font-size: 16px; font-weight: 700; }

/* Reservation card extras */
.res-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-right: 10px;
  min-width: 48px;
}
.res-info { flex: 1; }
.res-customer { font-weight: 600; font-size: 14px; }
.res-service { font-size: 13px; color: var(--text-muted); }
.res-top {
  display: flex;
  align-items: flex-start;
}

/* ---------- Sub-tabs ---------- */
.sub-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}
.sub-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  touch-action: manipulation;
}
.sub-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

/* ---------- Reports ---------- */
.report-range {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.range-field { flex: 1; min-width: 120px; }
.range-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 4px; }
.report-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.report-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--border);
  text-align: center;
}
.report-card .rc-value {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 2px;
}
.report-card .rc-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.report-card.income .rc-value { color: var(--success); }
.report-card.expense .rc-value { color: var(--danger); }
.report-card.balance .rc-value { color: var(--primary); }
.report-details {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--border);
}
.report-details h4 {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-muted);
}
.report-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.report-row:last-child { border-bottom: none; }

/* ---------- Settings ---------- */
.settings-list { display: flex; flex-direction: column; gap: 12px; }
.settings-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
}
.settings-card h3 { font-size: 15px; margin-bottom: 4px; }
.settings-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.version-label {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 24px;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeOverlay 0.2s ease;
}
@keyframes fadeOverlay { from { opacity: 0; } }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-x { font-size: 20px; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.modal-footer {
  padding: 12px 20px;
  padding-bottom: calc(12px + var(--safe-b));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.modal-footer .btn { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: calc(var(--header-h) + var(--safe-t) + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s ease;
  max-width: calc(100% - 32px);
  text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* ---------- Tablet / Desktop ---------- */
@media (min-width: 600px) {
  .modal-box {
    border-radius: var(--radius);
    margin-bottom: 40px;
    max-height: 85vh;
    align-self: center;
  }
  .modal-overlay { align-items: center; }
  .report-cards { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 900px) {
  .app { flex-direction: row; }
  .app-header { position: fixed; top: 0; left: 0; right: 0; z-index: 30; }
  .app-main { padding-bottom: 16px; padding-top: var(--header-h); margin-left: 80px; }
  .bottom-nav {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    width: 80px;
    flex-direction: column;
    height: auto;
    border-top: none;
    border-right: 1px solid var(--border);
    padding: 12px 0;
    z-index: 20;
  }
  .nav-btn { flex: 0; padding: 14px 0; }
  .nav-btn.active::after {
    top: 0; bottom: 0; left: 0;
    right: auto; width: 3px; height: auto;
    border-radius: 0 3px 3px 0;
  }
  .fab { bottom: 24px; }
}
