/* ==========================================================================
   APPLE DESIGN SYSTEM AESTHETICS - BANNAI RESORT ADMIN BOOKING
   ========================================================================== */

/* --- Apple System Design Tokens (Default Light Theme) --- */
:root {
  --primary: #0071e3;         /* Apple Link Blue */
  --primary-dark: #005bb5;
  --primary-light: #47a3ff;
  
  --system-green: #34c759;    /* Apple Green */
  --system-orange: #ff9500;   /* Apple Orange */
  --system-red: #ff3b30;      /* Apple Red */
  --system-gray: #8e8e93;      /* Apple Gray */
  
  --bg-app: #f5f5f7;          /* Apple off-white grey background */
  --bg-card: #ffffff;         /* Pure white cards */
  --bg-input: #ffffff;
  --bg-input-inset: #f5f5f7;
  
  --text-main: #1d1d1f;       /* Apple charcoal text */
  --text-muted: #86868b;      /* Secondary text */
  
  --border-color: #d2d2d7;    /* Light gray borders */
  --border-focus: #0071e3;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  --font-body: 'Inter', 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-title: 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* --- Apple Dark Theme (OLED / True Black) --- */
body.dark-theme {
  --primary: #0a84ff;         /* iOS System Blue Dark */
  --primary-dark: #0071e3;
  --primary-light: #54a6ff;
  
  --system-green: #30d158;
  --system-orange: #ff9f0a;
  --system-red: #ff453a;
  --system-gray: #8e8e93;
  
  --bg-app: #000000;          /* True black for OLED screens */
  --bg-card: #1c1c1e;         /* Apple System Gray 6 */
  --bg-input: #2c2c2e;         /* Apple System Gray 5 */
  --bg-input-inset: #1c1c1e;
  
  --text-main: #f5f5f7;
  --text-muted: #86868b;
  
  --border-color: #2c2c2e;    /* Dark gray borders */
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* --- General Reset & Typographies --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent; /* Disable tap highlight on iOS */
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.4s ease, color 0.4s ease;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  opacity: 0.8;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   UI COMPONENTS (Buttons, Inputs, iOS Switches)
   ========================================================================== */

/* Apple Style Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 0.92rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  gap: 6px;
  user-select: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  opacity: 0.9;
  transform: scale(0.98);
}
.btn-primary:active {
  transform: scale(0.95);
}

.btn-secondary {
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: var(--bg-app);
  border-color: var(--text-muted);
}
.btn-secondary:active {
  transform: scale(0.98);
}

.btn-danger {
  background-color: var(--system-red);
  color: #ffffff;
}
.btn-danger:hover {
  opacity: 0.9;
  transform: scale(0.98);
}
.btn-danger:active {
  transform: scale(0.95);
}

.btn-sm {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  border-radius: 6px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: var(--transition);
}

.btn-icon:hover {
  background-color: var(--border-color);
}

/* Apple Style Inputs */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-family: var(--font-title);
  font-size: 0.86rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-label-sm {
  display: block;
  font-size: 0.76rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  color: var(--text-muted);
}

.form-control {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  background-color: var(--bg-input-inset);
  color: var(--text-main);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: var(--transition);
}

.form-control:focus {
  background-color: var(--bg-card);
  border-color: var(--border-focus);
}

.form-control-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.86rem;
}

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.form-row .form-group {
  margin-bottom: 0;
}

.col-6 { flex: 1; }
.col-4 { width: 33.33%; }
.col-8 { width: 66.66%; }
.col-7 { width: 58.33%; }
.col-5 { width: 41.66%; }

textarea.form-control {
  resize: vertical;
}

.required {
  color: var(--system-red);
}

/* Custom iOS Toggle Switch Style */
.ios-settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
}

.ios-settings-row:last-child {
  border-bottom: none;
}

.ios-row-label {
  display: flex;
  flex-direction: column;
  padding-right: 12px;
}

.ios-row-label strong {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-main);
}

.ios-row-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ios-switch {
  position: relative;
  display: inline-block;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}

.ios-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ios-switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-color);
  transition: .3s cubic-bezier(0.25, 1, 0.5, 1);
  border-radius: 34px;
}

.ios-switch-slider:before {
  position: absolute;
  content: "";
  height: 27px;
  width: 27px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s cubic-bezier(0.25, 1, 0.5, 1);
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.ios-switch input:checked + .ios-switch-slider {
  background-color: var(--system-green);
}

.ios-switch input:focus + .ios-switch-slider {
  box-shadow: 0 0 1px var(--system-green);
}

.ios-switch input:checked + .ios-switch-slider:before {
  transform: translateX(20px);
}

/* Alerts */
.alert {
  padding: 0.8rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  text-align: center;
}
.alert-danger {
  background-color: rgba(255, 59, 48, 0.1);
  color: var(--system-red);
  border: 1px solid rgba(255, 59, 48, 0.2);
}

/* ==========================================================================
   1. LOGIN PAGE STYLING
   ========================================================================== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(135deg, #0e1411 0%, #151e1a 50%, #202d27 100%);
  position: relative;
}

.login-card {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  width: 100%;
  max-width: 380px;
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: loginFadeIn 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

body.dark-theme .login-card {
  background: rgba(28, 28, 30, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.login-logo-container {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 1.5rem;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.login-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-title {
  font-size: 1.45rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
  text-align: center;
}

.login-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2.25rem;
  text-align: center;
}

.login-card .form-group {
  text-align: left;
}

@keyframes loginFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ==========================================================================
   2. MAIN APPLICATION STYLING (Navbar, Header, Layout)
   ========================================================================== */
.app-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Apple Frosted Glass Navbar */
.app-header {
  background-color: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: var(--transition);
}

body.dark-theme .app-header {
  background-color: rgba(28, 28, 30, 0.75);
}

.app-nav-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  width: 100%;
}

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

.app-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--border-color);
  object-fit: cover;
}

.app-title {
  font-size: 1.05rem;
  margin-bottom: 0;
  color: var(--text-main);
  font-weight: 600;
}

.app-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
}

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

.admin-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  border-right: 1px solid var(--border-color);
  padding-right: 16px;
}

.admin-avatar {
  background-color: var(--bg-app);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
}

/* Main Dashboard Body */
.app-main-content {
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
}

/* ==========================================================================
   METRICS SECTION (Apple Widgets Style)
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-icon-box {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.metric-info {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

/* ==========================================================================
   VIEW SWITCHER (iOS Segmented Control Style)
   ========================================================================== */
.view-switcher-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.ios-segmented-control {
  background-color: var(--border-color);
  padding: 2px;
  border-radius: 10px;
  display: flex;
  width: 320px;
  user-select: none;
}

body.dark-theme .ios-segmented-control {
  background-color: #2c2c2e;
}

.segment-btn {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--font-title);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.45rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.segment-btn.active {
  background-color: var(--bg-card);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

/* ==========================================================================
   CONTROLS PANEL (Apple Search & Buttons Layout)
   ========================================================================== */
.controls-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.search-filter-group {
  display: flex;
  gap: 10px;
  flex-grow: 1;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 260px;
  flex-grow: 1;
}

.search-box input {
  padding-left: 2rem;
  background-color: var(--bg-input-inset);
  border: 1px solid transparent;
}

.search-box input:focus {
  background-color: var(--bg-card);
  border-color: var(--border-focus);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.filter-box {
  min-width: 170px;
}

.backup-add-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   DATA TABLE STYLING
   ========================================================================== */
.table-container {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  transition: var(--transition);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: rgba(0, 0, 0, 0.015);
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-muted);
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

body.dark-theme th {
  background-color: rgba(255, 255, 255, 0.01);
}

td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
  color: var(--text-main);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: rgba(0, 113, 227, 0.01);
}

/* Apple Status Badges */
.badge {
  display: inline-flex;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
}

.badge-pending {
  background-color: rgba(255, 149, 0, 0.12);
  color: var(--system-orange);
}

.badge-confirmed {
  background-color: rgba(52, 199, 89, 0.12);
  color: var(--system-green);
}

.badge-checkedin {
  background-color: rgba(0, 113, 227, 0.12);
  color: var(--primary);
}

.badge-checkedout {
  background-color: rgba(142, 142, 147, 0.15);
  color: var(--system-gray);
}

.table-other-costs-list {
  font-size: 0.78rem;
  color: var(--text-muted);
  list-style: none;
}

.table-other-costs-list li {
  margin-bottom: 1px;
}

.phone-txt {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

.price-txt {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.no-data-msg {
  padding: 4rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Actions */
.action-buttons {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.action-btn {
  background: none;
  border: 1px solid var(--border-color);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-main);
}

.action-btn:hover {
  background-color: var(--border-color);
}

.btn-edit:hover {
  border-color: var(--primary);
  color: var(--primary);
  background-color: rgba(0, 113, 227, 0.05);
}

.btn-delete:hover {
  border-color: var(--system-red);
  color: var(--system-red);
  background-color: rgba(255, 59, 48, 0.05);
}

.btn-view:hover {
  border-color: var(--system-green);
  color: var(--system-green);
  background-color: rgba(52, 199, 89, 0.05);
}

/* ==========================================================================
   3. APPLE INTERACTIVE CALENDAR VIEW STYLING
   ========================================================================== */
.calendar-container-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.calendar-header-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.calendar-month-title {
  font-size: 1.25rem;
  margin-bottom: 0;
  color: var(--text-main);
  font-weight: 600;
}

.calendar-grid-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.calendar-weekdays-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background-color: rgba(0, 0, 0, 0.015);
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-title);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

body.dark-theme .calendar-weekdays-grid {
  background-color: rgba(255, 255, 255, 0.01);
}

.weekday-cell {
  padding: 0.65rem 0.5rem;
  font-size: 0.8rem;
}

.weekday-cell.weekend {
  color: var(--system-red);
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background-color: var(--border-color);
  gap: 1px;
}

.calendar-day-cell {
  background-color: var(--bg-card);
  min-height: 110px;
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  transition: var(--transition);
}

.calendar-day-cell:hover {
  background-color: rgba(0, 113, 227, 0.02);
}

.calendar-day-cell.other-month {
  opacity: 0.35;
}

/* Today highlighted with Apple Blue */
.calendar-day-cell.today .day-number {
  background-color: var(--primary);
  color: #ffffff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.day-number {
  align-self: flex-end;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  font-weight: 500;
}

/* Desktop Calendar Bars styling */
.calendar-booking-bar {
  font-size: 0.7rem;
  padding: 3px 6px;
  border-radius: 4px;
  color: #ffffff;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  display: block;
  text-align: left;
}

.calendar-booking-bar:hover {
  transform: scale(0.98);
  filter: brightness(1.05);
}

/* iOS Status Bar colors */
.bar-pending { background-color: var(--system-orange); }
.bar-confirmed { background-color: var(--system-green); }
.bar-checkedin { background-color: var(--primary); }
.bar-checkedout { background-color: var(--system-gray); }

/* MOBILE DOTS INDICATOR */
.calendar-dots-container {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 4px;
}

.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* Selected calendar day on mobile */
.calendar-day-cell.selected {
  background-color: rgba(0, 113, 227, 0.08) !important;
  box-shadow: inset 0 0 0 2px var(--primary);
}

/* iOS Style list drawer under calendar (displays selected day bookings on mobile) */
.calendar-mobile-drawer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  display: none; /* Only show on mobile */
}

.drawer-date-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-main);
  border-left: 3px solid var(--primary);
  padding-left: 8px;
}

.drawer-bookings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-booking-card {
  background-color: var(--bg-app);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

body.dark-theme .drawer-booking-card {
  background-color: var(--bg-input);
}

/* ==========================================================================
   4. APPLE MODALS & FORM SHEET STYLING
   ========================================================================== */
.modal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

.modal-wrapper.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-wrapper.active .modal-card {
  transform: scale(1) translateY(0);
}

/* Form iOS Settings Card wrapper */
.apple-settings-card {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: var(--transition);
}

body.dark-theme .apple-settings-card {
  background-color: rgba(255, 255, 255, 0.015);
}

.ios-drag-handle {
  display: none;
  width: 36px;
  height: 5px;
  background-color: var(--border-color);
  border-radius: 3px;
  margin: 10px auto 0;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.2rem;
  margin-bottom: 0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.btn-close:hover {
  color: var(--system-red);
}

/* Modal form grid layout */
.modal-body-form {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}

.modal-section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.modal-col-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

.modal-form-col {
  display: flex;
  flex-direction: column;
}

/* Sub cost section */
.cost-sub-panel {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background-color: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  animation: slideDownSub 0.25s cubic-bezier(0.25, 1, 0.5, 1);
}

body.dark-theme .cost-sub-panel {
  background-color: var(--bg-input);
}

@keyframes slideDownSub {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden-number {
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

/* Equip list */
.equip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.equip-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.equip-title {
  font-size: 0.8rem;
  color: var(--text-main);
}

.inline-num {
  width: 55px;
  padding: 0.25rem;
  font-size: 0.8rem;
  text-align: center;
}

/* Custom costs rows */
.custom-cost-row {
  display: flex;
  gap: 8px;
  margin-bottom: 0.5rem;
}

.custom-cost-row .form-control {
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
}

/* Apple-style real-time breakdown */
.form-calculator-breakdown {
  background-color: var(--bg-app);
  color: var(--text-main);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
}

body.dark-theme .form-calculator-breakdown {
  background-color: rgba(255, 255, 255, 0.01);
}

.breakdown-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
  color: var(--primary);
}

body.dark-theme .breakdown-title {
  color: var(--accent-light);
}

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 20px;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.breakdown-val {
  font-weight: 500;
  color: var(--text-main);
}

.breakdown-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1.5px solid var(--border-color);
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1.1rem;
}

#calc-grand-total-display {
  font-size: 1.3rem;
  color: var(--primary);
  font-weight: 700;
}

body.dark-theme #calc-grand-total-display {
  color: var(--primary-light);
}

/* Modal Footer */
.modal-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   5. DETAIL VIEW / RECEIPT STYLING
   ========================================================================== */
.detail-modal-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  transform: scale(0.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
}

.modal-wrapper.active .detail-modal-card {
  transform: scale(1) translateY(0);
}

.detail-modal-body {
  padding: 2.25rem;
  background-color: #ffffff;
  color: #1d1d1f;
}

body.dark-theme .detail-modal-body {
  background-color: #ffffff; /* Receipt must stay light colored for printing */
  color: #1d1d1f;
}

/* Receipt */
.receipt-header {
  text-align: center;
  border-bottom: 1.5px solid #1d1d1f;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.receipt-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1.5px solid #8e8e93;
  object-fit: cover;
  margin-bottom: 0.4rem;
}

.receipt-title {
  font-size: 1.3rem;
  color: #1d1d1f;
  font-weight: 700;
  margin-bottom: 2px;
}

.receipt-subtitle {
  font-size: 0.78rem;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.receipt-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.receipt-meta-item strong {
  color: #1d1d1f;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
}

.receipt-table th {
  background-color: #f5f5f7 !important;
  border-bottom: 1.5px solid #1d1d1f;
  color: #1d1d1f !important;
  padding: 8px 10px;
}

.receipt-table td {
  border-bottom: 1px solid #e5e5ea;
  padding: 10px;
  color: #1d1d1f;
}

.receipt-table tr:hover td {
  background-color: transparent;
}

.receipt-total-section {
  float: right;
  width: 280px;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.receipt-total-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.receipt-total-grand {
  border-top: 1.5px solid #1d1d1f;
  border-bottom: 2px double #1d1d1f;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1d1d1f;
  padding: 6px 0;
  margin-top: 4px;
}

.receipt-notes {
  margin-top: 1.5rem;
  border-top: 1px dashed #d2d2d7;
  padding-top: 0.75rem;
  font-size: 0.8rem;
  color: #86868b;
  clear: both;
}

.receipt-notes strong {
  color: #1d1d1f;
}

.receipt-footer {
  text-align: center;
  margin-top: 3rem;
  font-size: 0.78rem;
  color: #86868b;
  border-top: 1px solid #e5e5ea;
  padding-top: 0.85rem;
}

/* ==========================================================================
   6. RESPONSIVE DESIGN (Media Queries & Mobile Enhancements)
   ========================================================================== */
@media (max-width: 900px) {
  .modal-section-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .modal-card {
    max-width: 95%;
  }
}

@media (max-width: 768px) {
  .app-main-content {
    padding: 1.25rem 1rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  
  .metric-card {
    padding: 1rem;
    gap: 10px;
    border-radius: var(--radius-md);
  }
  
  .metric-icon-box {
    width: 38px;
    height: 38px;
    font-size: 1.2rem;
  }
  
  .metric-value {
    font-size: 1.25rem;
  }

  .controls-panel {
    flex-direction: column;
    align-items: stretch;
    padding: 0.85rem;
  }
  
  .search-filter-group {
    flex-direction: column;
    gap: 8px;
  }
  
  .search-box {
    width: 100%;
    min-width: unset;
  }
  
  .backup-add-group {
    justify-content: space-between;
    margin-top: 4px;
  }
  
  .app-nav-container {
    flex-direction: column;
    gap: 10px;
    text-align: center;
    padding: 0.75rem 1rem;
  }
  
  .app-brand {
    flex-direction: column;
    gap: 2px;
  }
  
  .app-nav-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  .admin-profile {
    border-right: none;
    padding-right: 0;
  }

  /* IOS BOTTOM SHEET SLIDE UP FOR FORM MODAL */
  .modal-wrapper {
    align-items: flex-end; /* Align sheet to bottom of screen */
  }

  .modal-card {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 90vh !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important; /* round top corners only */
    border-bottom: none !important;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal-wrapper.active .modal-card {
    transform: translateY(0);
  }
  
  .ios-drag-handle {
    display: block; /* show top handle */
  }

  .modal-header {
    padding: 0.85rem 1.25rem 0.5rem;
    border-bottom: none;
  }

  .modal-body-form {
    padding: 1rem;
  }

  .apple-settings-card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  /* IOS MOBILE LIST CARDS INSTEAD OF TABLE */
  table, thead, tbody, th, td, tr {
    display: block;
  }
  
  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  tr {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.85rem;
    background-color: var(--bg-card);
    padding: 8px 12px;
    box-shadow: var(--shadow-sm);
  }
  
  td {
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    position: relative;
    padding: 0.5rem 0 0.5rem 45%;
    text-align: right;
    font-size: 0.86rem;
  }
  
  td:last-child {
    border-bottom: none;
  }
  
  td:before {
    position: absolute;
    left: 0;
    width: 40%;
    white-space: nowrap;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    content: attr(data-label);
  }
  
  .action-buttons {
    justify-content: flex-end;
  }

  /* CALENDAR RESPONSIVE (IOS DOTS) */
  .calendar-day-cell {
    min-height: 52px; /* much smaller height to save screen space */
    padding: 0.25rem;
    align-items: center;
    justify-content: flex-start;
  }

  .day-number {
    align-self: center;
    margin-bottom: 0;
  }

  .calendar-booking-bar {
    display: none !important; /* Hide bars completely on mobile calendar */
  }

  .calendar-mobile-drawer {
    display: block; /* Show bookings details list below calendar */
  }
}

/* ==========================================================================
   7. PRINT MEDIA STYLING
   ========================================================================== */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt;
  }
  
  body.dark-theme {
    --bg-app: #ffffff !important;
    --text-main: #000000 !important;
  }
  
  .no-print, 
  .app-header, 
  .metrics-grid, 
  .controls-panel, 
  .table-container, 
  .view-switcher-wrapper,
  .calendar-container-section,
  .modal-wrapper:not(.active),
  .modal-header,
  .modal-footer {
    display: none !important;
  }
  
  .modal-wrapper.active {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    background: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    z-index: 1 !important;
  }
  
  .detail-modal-card {
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
  }
  
  .detail-modal-body {
    padding: 0 !important;
    background: none !important;
  }
  
  .receipt-header {
    border-bottom: 1.5px solid #000000 !important;
  }
  
  .receipt-table th {
    background-color: #f2f2f2 !important;
    border-bottom: 1.5px solid #000000 !important;
    color: #000000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  .receipt-table td {
    border-bottom: 1px solid #cccccc !important;
  }
  
  .receipt-total-grand {
    border-top: 1.5px solid #000000 !important;
    border-bottom: 2px double #000000 !important;
    color: #000000 !important;
  }
}
