/**
 * components.css - Reusable UI Components: Buttons, Cards, Modals, Forms, Slots, Toasts, Login
 */

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.25;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-success {
  background-color: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover:not(:disabled) {
  background-color: var(--success-hover);
  border-color: var(--success-hover);
}

.btn-outline-primary {
  background-color: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover:not(:disabled) {
  background-color: var(--primary-light);
}

.btn-outline-secondary {
  background-color: transparent;
  color: var(--secondary);
  border-color: var(--border-color);
}
.btn-outline-secondary:hover:not(:disabled) {
  background-color: var(--secondary-light);
  border-color: var(--secondary);
}
.btn-outline-secondary.active {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-outline-danger {
  background-color: transparent;
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-outline-danger:hover:not(:disabled) {
  background-color: var(--danger);
  color: white;
}

.btn-outline-warning {
  background-color: transparent;
  color: var(--warning);
  border-color: var(--warning-border);
}
.btn-outline-warning:hover:not(:disabled) {
  background-color: var(--warning-light);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ==========================================
   BADGES & CHIPS
   ========================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.025em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-admin {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.badge-user {
  background-color: #e0f2fe;
  color: #075985;
  border: 1px solid #bae6fd;
}

.badge-primary {
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-secondary {
  background-color: var(--secondary-light);
  color: var(--secondary);
  border: 1px solid var(--border-color);
}

.badge-warning {
  background-color: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-success {
  background-color: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-active {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-cancelled {
  background-color: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.day-chip {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
}
.day-chip.active {
  background-color: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.day-chip.inactive {
  background-color: #f1f5f9;
  color: #94a3b8;
  text-decoration: line-through;
  opacity: 0.6;
}

.loc-tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  margin: 0.1rem;
  background-color: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 600;
}

/* ==========================================
   FRONT PAGE: LOGIN VIEW
   ========================================== */
.login-front-page {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  max-width: 480px;
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.login-card-header {
  padding: 2rem 2rem 1.25rem 2rem;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.login-logo-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.login-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.login-card-body {
  padding: 2rem;
}

.login-security-notice {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--bg-surface);
  border-left: 3px solid var(--secondary);
  padding: 0.65rem 0.85rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.login-security-notice .notice-icon {
  font-size: 1rem;
  line-height: 1.2;
}

.login-demo-section {
  margin-top: 1.75rem;
  border-top: 1px dashed var(--border-color);
  padding-top: 1.25rem;
}

.login-demo-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}

.demo-account-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.demo-account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.demo-account-item:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.demo-account-item .account-role {
  font-size: 0.75rem;
  font-weight: 700;
}

.demo-account-item .account-details {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ==========================================
   FORMS & INPUTS
   ========================================== */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-helper {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: white;
  color: var(--text-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-input-lg {
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.col-half {
  flex: 1;
}

.password-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-wrapper .form-input {
  padding-right: 2.75rem;
}

.btn-toggle-pwd {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* Day selector & Location Checkboxes */
.days-checkbox-grid, .locations-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.day-checkbox-label, .loc-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.65rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

.day-checkbox-label:hover, .loc-checkbox-label:hover {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.preset-buttons-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
  margin-bottom: 0.5rem;
}

/* ==========================================
   ALERTS & NOTICES
   ========================================== */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

.alert-warning {
  background-color: var(--warning-light);
  border: 1px solid var(--warning-border);
  color: #92400e;
}

.alert-danger {
  background-color: var(--danger-light);
  border: 1px solid var(--danger-border);
  color: #b91c1c;
}

.alert-info {
  background-color: var(--info-light);
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.alert-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.notice-info {
  background: var(--bg-surface);
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

/* Daily Limit Banner */
.daily-limit-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #92400e;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
}

.daily-limit-banner .limit-icon {
  font-size: 1.3rem;
}

/* ==========================================
   BOOKING VIEW & AREA CARDS
   ========================================== */
.booking-view-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.booking-filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 1.25rem;
  background: var(--bg-card);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  align-items: start;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.date-picker-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.quick-date-buttons {
  display: flex;
  gap: 0.35rem;
}

.location-summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.loc-summary-title {
  font-size: 0.9rem;
  color: var(--primary);
}

.loc-summary-slots {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.slot-pill {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}
.slot-pill.am {
  background: var(--slot-am-bg);
  color: var(--slot-am);
}
.slot-pill.pm {
  background: var(--slot-pm-bg);
  color: var(--slot-pm);
}

.areas-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.date-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.areas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.area-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.area-card-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.area-card-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.area-card-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Slots Inside Area Card */
.slots-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.slot-box {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-surface);
  transition: all var(--transition-fast);
}

.slot-box.slot-available {
  border-color: var(--success-border);
  background: #f0fdf4;
}

.slot-box.slot-booked {
  border-color: #fecaca;
  background: #fff1f2;
}

.slot-box.slot-past {
  opacity: 0.65;
  background: #f8fafc;
}

.slot-box.slot-limit-reached {
  opacity: 0.75;
  background: #fafafa;
  border-color: var(--border-color);
}

.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.slot-name-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
}

.slot-name-badge.am {
  background: var(--slot-am-bg);
  color: var(--slot-am);
}

.slot-name-badge.pm {
  background: var(--slot-pm-bg);
  color: var(--slot-pm);
}

.slot-hours {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.slot-status-info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.green { background-color: var(--success); }
.status-dot.red { background-color: var(--danger); }
.status-dot.gray { background-color: var(--text-dim); }

.booking-reserver-text {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================
   TABLES & LISTS
   ========================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

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

.data-table th {
  background: var(--bg-surface);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: var(--bg-surface);
}

.data-table tr.row-cancelled td {
  opacity: 0.55;
}

/* ==========================================
   ADMIN CARDS & METRICS
   ========================================== */
.admin-view-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.locations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-card-actions {
  display: flex;
  gap: 0.35rem;
}

.admin-card-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.admin-card-meta-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
}

.days-chips-row {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.admin-card-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.user-stats-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  flex: 1;
  min-width: 180px;
  box-shadow: var(--shadow-sm);
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================
   MODALS
   ========================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast);
}

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

.modal-dialog {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transform: translateY(20px) scale(0.98);
  transition: transform var(--transition-normal);
}

.modal-backdrop.active .modal-dialog {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

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

.modal-body {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-surface);
}

.modal-actions-spaced {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
}

.first-time-welcome-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.first-time-welcome-banner .welcome-icon {
  font-size: 2rem;
  line-height: 1;
}

.first-time-welcome-banner h4 {
  color: #065f46;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.first-time-welcome-banner p {
  color: #047857;
  font-size: 0.825rem;
}

.returning-user-box {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
}

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.confirm-booking-box {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.confirm-row .label {
  color: var(--text-muted);
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================= */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 300px;
  max-width: 440px;
  background: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-info { border-left-color: var(--info); }

.toast-icon {
  font-weight: 700;
  font-size: 1.1rem;
}
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-body {
  flex: 1;
}

.toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 1.25rem;
  line-height: 1;
}

.animate-slide-in {
  animation: slideInRight 0.25s ease-out forwards;
}

.toast-fade-out {
  opacity: 0;
  transform: translateY(10px);
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==========================================
   EMPTY STATES
   ========================================== */
.empty-state-card {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.75rem;
  margin-bottom: 0.25rem;
}
