/* ==========================================================================
   Room Booking System - Responsive, Cross-Browser Stylesheet
   Tested on: Chrome, Firefox, Safari (macOS + iOS), Edge, Samsung Internet
   ========================================================================== */

/* ---------- 1. Reset ---------- */
*, *::before, *::after {
  -webkit-box-sizing: border-box;
     -moz-box-sizing: border-box;
          box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
      -ms-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, "Noto Sans", sans-serif,
               "Apple Color Emoji", "Segoe UI Emoji";
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
     -moz-osx-font-smoothing: grayscale;
}

/* ---------- 2. Design tokens ---------- */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --danger:         #dc2626;
  --danger-dark:    #b91c1c;
  --success:        #16a34a;
  --success-bg:     #dcfce7;
  --success-text:   #166534;
  --error-bg:       #fee2e2;
  --error-text:     #991b1b;
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --border-strong:  #cbd5e1;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --radius:         8px;
  --radius-sm:      6px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.06);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.08);
  --focus-ring:     0 0 0 3px rgba(37,99,235,0.35);
  --transition:     0.15s ease-in-out;
}

/* ---------- 3. Typography ---------- */
h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin: 0 0 1rem; line-height: 1.2; }
h2 { font-size: clamp(1.15rem, 3vw, 1.4rem); margin: 0 0 0.75rem; line-height: 1.25; }
h3 { font-size: 1.05rem; margin: 0 0 0.25rem; }
p  { margin: 0 0 1rem; }
a  { color: var(--primary); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; }

/* ---------- 4. Navbar ---------- */
.navbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem clamp(1rem, 3vw, 1.5rem);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.navbar .brand a {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.navbar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1.25rem);
}
.navbar a {
  color: var(--text);
  font-weight: 500;
  padding: 0.35rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.navbar a:hover, .navbar a:focus-visible { color: var(--primary); }
.navbar .user { color: var(--text-muted); font-size: 0.9rem; white-space: nowrap; }

/* ---------- 5. Container ---------- */
.container {
  width: 100%;
  max-width: 1100px;
  margin: clamp(1rem, 3vw, 2rem) auto;
  padding: 0 clamp(0.75rem, 3vw, 1.5rem);
}

/* ---------- 6. Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.5rem);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
}
.card label {
  display: flex;
  flex-direction: column;
  font-weight: 500;
  gap: 0.35rem;
  font-size: 0.95rem;
}
.row { display: flex; flex-wrap: wrap; gap: 1rem; }
.row > label { flex: 1 1 160px; }

/* ---------- 7. Form controls ---------- */
input, select, textarea, button {
  font: inherit;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; }

input[type="date"], input[type="time"] {
  -webkit-appearance: none;
  min-height: 42px;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
a:focus-visible, button:focus-visible, .btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ---------- 8. Buttons ---------- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  min-height: 42px;
  transition: background-color var(--transition), transform var(--transition),
              box-shadow var(--transition);
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  touch-action: manipulation;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn.small, button.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  min-height: 34px;
}
.btn.secondary, button.secondary { background: #64748b; }
.btn.secondary:hover { background: #475569; }
.btn.danger, button.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-dark); }

/* ---------- 9. Tables ---------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 1.5rem;
}
.table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  background: var(--surface);
}
.table th, .table td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  vertical-align: top;
}
.table th {
  background: #f1f5f9;
  font-weight: 600;
  white-space: nowrap;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafc; }

/* ---------- 10. Flash messages ---------- */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-size: 0.95rem;
}
.flash.success { background: var(--success-bg); color: var(--success-text); border-color: #86efac; }
.flash.error   { background: var(--error-bg);   color: var(--error-text);   border-color: #fca5a5; }

/* ---------- 11. Dashboard grid ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.card-link {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition),
              border-color var(--transition);
}
.card-link:hover, .card-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  text-decoration: none;
}
.card-link h3 { color: var(--primary); }
.card-link p  { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

/* ---------- 12. Badges ---------- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge.admin { background: #ede9fe; color: #6d28d9; }
.badge.user  { background: #e0f2fe; color: #0369a1; }

/* ---------- 13. Date-grouped schedule ---------- */
.date-group { margin-bottom: 2rem; }
.date-group h2 {
  font-size: 1.15rem;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.25rem;
  color: var(--primary-dark);
}

/* ---------- 14. Footer ---------- */
.footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- 15. Utility ---------- */
.actions {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

/* ==========================================================================
   NEW: Notes, required indicators, password helper styles
   ========================================================================== */

/* Info note blocks (login hint, booking form guidance, etc.) */
.note {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #f1f5f9;
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  line-height: 1.5;
}
.note a { font-weight: 500; }

/* Required field asterisk */
.required {
  color: var(--danger);
  font-weight: 700;
  margin-left: 0.15rem;
  font-size: 1.05em;
}

/* Password strength hint (optional visual, applies to password inputs) */
input[type="password"] {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Arial, sans-serif;
  letter-spacing: 0.05em;
}

/* Required inputs get subtle emphasis on the label */
.card label:has(.required) {
  font-weight: 600;
}

/* Fallback for browsers without :has() */
.card label .required {
  font-weight: 700;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .navbar { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .navbar nav { justify-content: center; gap: 0.75rem; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
@media (max-width: 480px) {
  body { font-size: 15px; }
  .container { padding: 0 0.75rem; }
  .card { padding: 1rem; }
  .navbar nav a { font-size: 0.9rem; }
  .row { gap: 0.75rem; }
  .row > label { flex: 1 1 100%; }
  .table th, .table td { padding: 0.55rem 0.6rem; font-size: 0.88rem; }
  button, .btn { width: 100%; }
  .btn.small, button.small { width: auto; }
  .actions button { width: 100%; }
  .note { font-size: 0.85rem; padding: 0.65rem 0.85rem; }
}
@media (min-width: 1280px) { .container { max-width: 1200px; } }

/* ---------- Accessibility & motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Print ---------- */
@media print {
  .navbar, .footer, button, .btn, .actions { display: none !important; }
  body { background: #fff; color: #000; }
  .table { border: 1px solid #000; min-width: 0; }
  .table th, .table td { border: 1px solid #000; }
  .note { border: 1px solid #ccc; background: #f9f9f9; }
}

/* ---------- High contrast ---------- */
@media (forced-colors: active) {
  button, .btn, input, select, textarea { border: 1px solid ButtonText; }
  a { color: LinkText; }
  .required { color: Mark; font-weight: 700; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0f172a;
    --surface:       #1e293b;
    --border:        #334155;
    --border-strong: #475569;
    --text:          #e2e8f0;
    --text-muted:    #94a3b8;
  }
  body { background: var(--bg); color: var(--text); }
  .navbar, .card, .card-link, .table, .table-wrap { background: var(--surface); }
  .table th { background: #334155; color: #f1f5f9; }
  .table tbody tr:hover { background: #253449; }
  .note { background: #1e293b; color: #cbd5e1; }
  .flash.success { background: #064e3b; color: #d1fae5; border-color: #047857; }
  .flash.error   { background: #7f1d1d; color: #fee2e2; border-color: #b91c1c; }
  input, select, textarea { background: #0f172a; color: var(--text); border-color: var(--border-strong); }
}

/* ==========================================================================
   New: Today badge, booking sections, view tabs
   ========================================================================== */

/* "Today" pill on schedules and lists */
.today-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

/* Section wrapper for My Bookings upcoming/past */
.booking-section {
  margin-bottom: 2.5rem;
}
.booking-section h2 {
  font-size: 1.15rem;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.25rem;
  color: var(--primary-dark);
  margin-bottom: 1rem;
}

/* Past bookings — muted look */
.past-table {
  opacity: 0.75;
}
.past-table th {
  background: #f8fafc;
  color: var(--text-muted);
}
.past-table td {
  color: var(--text-muted);
}

/* View tabs (Upcoming / Past / All) in admin bookings */
.tabs {
  display: flex;
  gap: 0.35rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.tabs a {
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -2px;
  transition: color var(--transition), background-color var(--transition),
              border-color var(--transition);
}
.tabs a:hover {
  color: var(--primary);
  background: #f1f5f9;
  text-decoration: none;
}
.tabs a.active {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 2px solid var(--surface);
  font-weight: 600;
}