/* Root Variables */
:root {
  --primary: #3b82f6;
  --text: #1f2937;
  --text-muted: #6b7280;
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: rgba(0, 0, 0, 0.06);
  --success: #10b981;
  --warning: #f59e0b;
  --destructive: #ef4444;
  --blue-100: #dbeafe;
  --blue-600: #2563eb;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --gray-400: #9ca3af;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.app-shell__sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.app-shell__sidebar nav {
  display: grid;
  gap: 10px;
}

.app-shell__sidebar a {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s ease;
}

.app-shell__sidebar a.active,
.app-shell__sidebar a:hover {
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
}

.app-shell__main {
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 24px;
}

.topbar-left {
  flex: 1;
}

.topbar-left h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-name {
  font-size: 0.95rem;
  font-weight: 500;
}

.logout-btn {
  padding: 8px 16px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  border: none;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.logout-btn:hover {
  background: rgba(59, 130, 246, 0.2);
}

.app-shell__content {
  padding: 32px;
  overflow-y: auto;
  flex: 1;
}

/* Cards & Sections */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.card-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  margin: 0;
}

.card-body {
  margin-top: 16px;
}

/* Grid Layouts */
.page-grid {
  display: grid;
  gap: 24px;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table thead {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  font-size: 0.875rem;
}

table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

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

table tbody tr:hover {
  background: var(--bg);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) {
  background: var(--blue-600);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.05);
}

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

.btn-success:hover:not(:disabled) {
  background: var(--emerald-600);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge-reserved {
  background: var(--blue-100);
  color: var(--blue-600);
}

.badge-inhouse {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-500);
}

.badge-checkedout {
  background: rgba(156, 163, 175, 0.1);
  color: var(--gray-400);
}

.badge-cancelled {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive);
}

.badge-clean {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-500);
}

.badge-dirty {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.badge-occupied {
  background: rgba(16, 185, 129, 0.1);
  color: var(--emerald-500);
}

.badge-outoforder {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive);
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.875rem;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, #1e3a8a 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-header p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form button {
  margin-top: 8px;
}

.demo-hint {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Timeline View */
.timeline-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.timeline-header,
.timeline-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}

.timeline-header {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.8rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.timeline-labels {
  flex-shrink: 0;
  width: 152px;
  min-width: 152px;
  padding: 12px;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  background: var(--surface);
  position: sticky;
  left: 0;
  z-index: 5;
}

.room-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-label strong {
  font-size: 0.95rem;
}

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

.timeline-dates {
  display: flex;
  flex: 1;
  position: relative;
}

.date-column {
  flex-shrink: 0;
  width: 60px;
  min-width: 60px;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.date-column.today {
  background: #fef3c7;
}

.date-day {
  text-align: center;
}

.timeline-body {
  position: relative;
}

.reservation-list{
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.reservation-item {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.reservation-bar {
  position: absolute;
  top: 6px;
  height: 40px;
  padding: 0 8px;
  border-radius: 6px;
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
}

.reservation-bar:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.res-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reservation-bar.status-reserved {
  background: #3b82f6;
}

.reservation-bar.status-inhouse {
  background: #10b981;
}

.reservation-bar.status-checkedout {
  background: #9ca3af;
}

.reservation-bar.status-cancelled {
  background: #ef4444;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

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

/* Rooms Grid */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.room-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.room-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.room-number {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.room-floor {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.room-status {
  margin-bottom: 8px;
}

.room-card.status-clean {
  border-color: var(--emerald-500);
  background: rgba(16, 185, 129, 0.02);
}

.room-card.status-dirty {
  border-color: var(--warning);
  background: rgba(245, 158, 11, 0.02);
}

.room-card.status-occupied {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.02);
}

.room-card.status-outoforder {
  border-color: var(--destructive);
  background: rgba(239, 68, 68, 0.02);
}

/* Utilities */
.text-muted {
  color: var(--text-muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.actions {
  display: flex;
  gap: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-shell__sidebar {
    display: none;
  }

  .topbar {
    padding: 16px 20px;
  }

  .app-shell__content {
    padding: 16px;
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .rooms-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  table {
    font-size: 0.8rem;
  }

  table th,
  table td {
    padding: 8px 4px;
  }
}


.admin-user-form {
  display: grid;
  grid-template-columns: 1.1fr 2fr 1.1fr 1fr auto;
  gap: 16px;
  align-items: end;
}

.admin-submit-group {
  margin-bottom: 16px;
}

.users-table td {
  vertical-align: middle;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.user-actions form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.form-input-sm {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: white;
}

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

.btn-danger:hover {
  background: #dc2626;
}

.badge-role-admin {
  background: #dbeafe;
  color: #2563eb;
}

.badge-role-staff {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.badge-role-housekeeper {
  background: #fef3c7;
  color: #d97706;
}

.badge-active {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.badge-disabled {
  background: rgba(156, 163, 175, 0.12);
  color: #6b7280;
}

@media (max-width: 900px) {
  .admin-user-form {
    grid-template-columns: 1fr;
  }

  .user-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}

.export-form {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr auto auto;
  gap: 16px;
  align-items: end;
}

.export-button-group {
  margin-bottom: 16px;
}

.export-preview-table {
  max-height: 520px;
  overflow: auto;
}

.export-preview-table table {
  min-width: 900px;
}

.export-preview-table th {
  white-space: nowrap;
}

.export-preview-table td {
  white-space: nowrap;
  font-size: 0.875rem;
}

@media (max-width: 900px) {
  .export-form {
    grid-template-columns: 1fr;
  }
}
