/* ============================================
   Front Desk Mido — Master Stylesheet
   ============================================ */

/* 1. Reset & Base
   -------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Override Pico defaults */
:where(input, select, textarea) {
  font-family: inherit;
}

/* 2. Design Tokens
   -------------------------------------------- */
:root {
  --bg: hsl(220 20% 97%);
  --card: hsl(0 0% 100%);
  --muted: hsl(220 15% 93%);

  --fg: hsl(220 25% 10%);
  --fg-muted: hsl(220 10% 45%);

  --primary: hsl(225 75% 55%);
  --primary-fg: hsl(0 0% 100%);
  --primary-hover: hsl(225 75% 48%);

  --destructive: hsl(0 72% 51%);
  --destructive-hover: hsl(0 72% 44%);
  --success: hsl(152 60% 42%);
  --warning: hsl(38 92% 50%);

  --border: hsl(220 13% 87%);
  --input-bg: hsl(220 20% 96%);
  --ring: hsl(225 75% 55%);

  --weekend: hsl(45 100% 96%);

  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --shadow-sm: 0 1px 2px hsl(0 0% 0% / .05);
  --shadow-md: 0 4px 12px hsl(0 0% 0% / .08);
  --shadow-lg: 0 8px 30px hsl(0 0% 0% / .12);
  --shadow-modal: 0 16px 48px hsl(0 0% 0% / .2);

  --t-fast: 150ms ease;
  --t-normal: 250ms ease;
  --t-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
}

/* 3. Typography
   -------------------------------------------- */
h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--fg);
}

h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--fg);
}

h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--fg);
}

.text-xs {
  font-size: var(--text-xs);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-muted {
  color: var(--fg-muted);
}

.text-mono {
  font-family: 'SF Mono', 'Consolas', monospace;
}

/* 4. Layout
   -------------------------------------------- */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-xs {
  gap: 4px;
}

.gap-sm {
  gap: 8px;
}

.gap-md {
  gap: 12px;
}

.gap-lg {
  gap: 16px;
}

.gap-xl {
  gap: 24px;
}

.flex-1 {
  flex: 1;
}

.hidden {
  display: none !important;
}

/* 5. Components
   -------------------------------------------- */

/* -- Buttons -- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--t-fast);
  background: var(--card);
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:hover {
  background: var(--muted);
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

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

.btn-destructive {
  background: var(--destructive);
  color: white;
  border-color: var(--destructive);
}

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
}

.btn-outline:hover {
  background: var(--muted);
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--fg-muted);
}

.btn-ghost:hover {
  color: var(--fg);
  background: var(--muted);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: var(--text-xs);
}

.btn-lg {
  height: 44px;
  padding: 0 24px;
  font-size: var(--text-base);
  font-weight: 600;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 36px;
  padding: 0;
}

.btn-icon.btn-sm {
  width: 32px;
}

/* -- Inputs -- */
.input,
.select,
.textarea {
  width: 100%;
  height: 40px;
  padding: 8px 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-family: inherit;
  color: var(--fg);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px hsl(225 75% 55% / .2);
}

.input::placeholder {
  color: var(--fg-muted);
}

.textarea {
  height: auto;
  min-height: 80px;
  resize: vertical;
}

.select {
  cursor: pointer;
  appearance: none;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--fg);
}

.form-group label .required {
  color: var(--destructive);
}

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

/* -- Cards -- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

/* 6. Header
   -------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 72px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}

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

.app-header__logo {
  width: 40px;
  height: 40px;
  background: var(--primary);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.app-header__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}

.app-header__subtitle {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header__search {
  width: 256px;
}

.app-header__search .input {
  height: 36px;
}

/* 7. Legend Bar
   -------------------------------------------- */
.legend-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--fg);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 8. Search Filter Panel
   -------------------------------------------- */
.filter-panel {
  margin: 0 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-panel .input {
  max-width: 280px;
  height: 36px;
}

.filter-panel .btn {
  height: 36px;
}

/* 9. Gantt Navigation
   -------------------------------------------- */
.gantt-nav {
  margin: 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.gantt-nav__left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gantt-nav__date-btn {
  min-width: 192px;
  justify-content: center;
  font-weight: 500;
}

.gantt-nav__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 10. Gantt Chart
   -------------------------------------------- */
.gantt-container {
  margin: 0 16px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.gantt-scroll {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}

.gantt-grid {
  display: grid;
  min-width: fit-content;
}

.gantt-header-row {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

.gantt-room-header {
  width: 160px;
  min-width: 160px;
  padding: 8px 12px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg);
  border-right: 2px solid var(--border);
  display: flex;
  align-items: center;
}

.gantt-date-cell {
  width: 96px;
  min-width: 96px;
  padding: 6px 4px;
  text-align: center;
  border-right: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--fg);
}

.gantt-date-cell__day {
  font-weight: 600;
  font-size: var(--text-sm);
}

.gantt-date-cell__weekday {
  color: var(--fg-muted);
}

.gantt-date-cell--weekend {
  background: var(--weekend);
}

.gantt-date-cell--today {
  background: hsl(225 75% 55% / .08);
  border-bottom: 2px solid var(--primary);
}

.gantt-row {
  display: flex;
  position: relative;
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}

.gantt-row:hover {
  background: hsl(220 20% 97% / .5);
}

.gantt-room-cell {
  width: 160px;
  min-width: 160px;
  padding: 8px 12px;
  border-right: 2px solid var(--border);
  background: var(--card);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: sticky;
  left: 0;
  z-index: 10;
}

.gantt-room-cell__name {
  font-size: var(--text-sm);
  font-weight: 500;
}

.gantt-room-cell__type {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.gantt-dates-area {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 56px;
}

.gantt-day-col {
  width: 96px;
  min-width: 96px;
  border-right: 1px solid hsl(220 13% 87% / .5);
}

.gantt-day-col--weekend {
  background: var(--weekend);
}

/* Reservation bars */
.gantt-bar {
  position: absolute;
  top: 8px;
  height: 40px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: white;
  cursor: pointer;
  z-index: 5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}

.gantt-bar:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  z-index: 6;
}

.gantt-bar__delete {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  background: rgba(0, 0, 0, .3);
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--t-fast);
}

.gantt-bar:hover .gantt-bar__delete {
  opacity: 1;
}

/* -- Reservation bar colors -- */
.bar-blue {
  background: #3b82f6;
}

.bar-red {
  background: #ef4444;
}

.bar-green {
  background: #10b981;
}

.bar-amber {
  background: #f59e0b;
  color: #1a1a1a;
}

.bar-purple {
  background: #8b5cf6;
}

.bar-pink {
  background: #ec4899;
}

.bar-cyan {
  background: #06b6d4;
}

.bar-indigo {
  background: #6366f1;
}

.bar-teal {
  background: #14b8a6;
}

.bar-orange {
  background: #f97316;
}

/* 11. Gantt Hover Popup
   -------------------------------------------- */
.gantt-popup {
  position: absolute;
  z-index: 50;
  width: 256px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 14px;
  pointer-events: none;
}

.gantt-popup__number {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--primary);
}

.gantt-popup__row {
  font-size: var(--text-xs);
  color: var(--fg);
  margin-top: 4px;
}

.gantt-popup__row span {
  color: var(--fg-muted);
}

.gantt-popup__notes {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

/* 12. Modals
   -------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 200ms ease;
}

.modal-card {
  background: var(--card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  padding: 24px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card--sm {
  max-width: 400px;
}

.modal-card--md {
  max-width: 448px;
}

.modal-card--lg {
  max-width: 672px;
}

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

.modal-header h2 {
  margin: 0;
}

.modal-footer {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* Confirm dialog */
.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.confirm-icon--warning {
  background: hsl(38 92% 50% / .12);
  color: var(--warning);
}

.confirm-icon--destructive {
  background: hsl(0 72% 51% / .12);
  color: var(--destructive);
}

.confirm-icon--info {
  background: hsl(225 75% 55% / .12);
  color: var(--primary);
}

/* Color picker */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--r-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast);
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: var(--fg);
  transform: scale(1.1);
}

/* 13. Toasts
   -------------------------------------------- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  max-width: 360px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  animation: slideInRight 300ms ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast--success {
  background: var(--success);
}

.toast--error {
  background: var(--destructive);
}

.toast--info {
  background: var(--primary);
}

/* 14. Login Page
   -------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, hsl(225 75% 55% / .08) 0%, var(--bg) 50%, hsl(225 75% 55% / .04) 100%);
}

.login-card {
  max-width: 400px;
  width: 90%;
  background: var(--card);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  text-align: center;
}

.login-card__logo {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: white;
}

.login-card__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: 4px;
}

.login-card__subtitle {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-bottom: 28px;
}

.login-card form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card .btn-primary {
  height: 44px;
  font-size: var(--text-base);
  margin-top: 8px;
}

.login-card__footer {
  text-align: center;
  margin-top: 20px;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.login-card__footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.login-card__footer a:hover {
  text-decoration: underline;
}

.login-error {
  background: hsl(0 72% 51% / .08);
  border-left: 3px solid var(--destructive);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: var(--text-sm);
  color: var(--destructive);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 15. Room Management
   -------------------------------------------- */
.room-add-card {
  background: var(--muted);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.room-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 80px auto;
  gap: 12px;
  align-items: end;
}

.room-list {
  max-height: 384px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}

.room-item:hover {
  background: var(--muted);
}

.room-item__info-name {
  font-weight: 500;
  font-size: var(--text-sm);
}

.room-item__info-meta {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

.room-item__actions {
  display: flex;
  gap: 4px;
}

/* 16. Reservation Detail Popup
   -------------------------------------------- */
.detail-header {
  padding: 16px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  color: white;
  font-weight: 700;
  font-size: var(--text-lg);
}

.detail-body {
  padding: 16px;
}

.detail-field {
  margin-bottom: 12px;
}

.detail-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-weight: 600;
}

.detail-value {
  font-size: var(--text-sm);
  color: var(--fg);
  margin-top: 2px;
}

/* 17. Export Buttons
   -------------------------------------------- */
.export-group {
  display: flex;
  gap: 8px;
}

/* 18. Animations
   -------------------------------------------- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-bottom-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* 19. NProgress overrides
   -------------------------------------------- */
#nprogress .bar {
  background: var(--primary);
  height: 3px;
}

#nprogress .peg {
  box-shadow: 0 0 10px var(--primary), 0 0 5px var(--primary);
}

/* 20. Responsive
   -------------------------------------------- */
@media (max-width: 1023px) {
  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .app-header__search {
    width: 100%;
    order: 10;
  }
}

@media (max-width: 767px) {
  .app-header__actions .btn span.btn-label {
    display: none;
  }

  .gantt-room-cell,
  .gantt-room-header {
    width: 120px;
    min-width: 120px;
  }

  .gantt-date-cell,
  .gantt-day-col {
    width: 72px;
    min-width: 72px;
  }

  .modal-card {
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .filter-panel {
    flex-direction: column;
  }

  .filter-panel .input {
    max-width: 100%;
  }

  .room-add-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}