/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; }
body { background: #f0f2f5; color: #1a1a2e; }

/* ===== Layout ===== */
#app { display: flex; flex-direction: column; height: 100%; }
#topbar {
  background: #1a5c38; color: #fff; display: flex; align-items: center;
  padding: 0 16px; height: 52px; gap: 8px; flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}
#topbar h1 { font-size: 16px; font-weight: 700; flex: 1; }
#topbar .topbar-right { display: flex; align-items: center; gap: 12px; }
#lang-toggle { background: rgba(255,255,255,.15); border: none; color: #fff; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 13px; }
#lang-toggle:hover { background: rgba(255,255,255,.25); }
#logout-btn { background: #c0392b; border: none; color: #fff; padding: 6px 14px; border-radius: 4px; cursor: pointer; }

#layout { display: flex; flex: 1; overflow: hidden; }

/* ===== Sidebar ===== */
#sidebar {
  width: 200px; background: #fff; border-right: 1px solid #e0e0e0;
  display: flex; flex-direction: column; flex-shrink: 0;
}
#sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  color: #555; text-decoration: none; border-left: 3px solid transparent;
  transition: all .15s;
}
#sidebar nav a:hover { background: #f5f5f5; color: #1a5c38; }
#sidebar nav a.active { background: #e8f5ef; color: #1a5c38; border-left-color: #1a5c38; font-weight: 600; }
#sidebar nav a .icon { font-size: 16px; width: 20px; text-align: center; }

/* ===== Main Content ===== */
#main { flex: 1; overflow-y: auto; padding: 20px; }
.page { display: none; }
.page.active { display: block; }

/* ===== Cards & Panels ===== */
.card {
  background: #fff; border-radius: 8px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: #1a5c38; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border: none; border-radius: 5px;
  cursor: pointer; font-size: 13px; font-weight: 500; transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: #1a5c38; color: #fff; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-warning { background: #f39c12; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link { background: none; color: #1a5c38; padding: 0; font-weight: normal; text-decoration: underline; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; color: #444; }
.form-control {
  width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 5px;
  font-size: 14px; transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: #1a5c38; box-shadow: 0 0 0 2px rgba(26,92,56,.15); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #f8f9fa; font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 2px solid #e0e0e0; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: #666; }
td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tr:hover td { background: #fafafa; }

/* ===== Status Badges ===== */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.badge-confirmed { background: #d4edda; color: #155724; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-cancelled { background: #f8d7da; color: #721c24; }
.badge-checked_in { background: #cce5ff; color: #004085; }
.badge-checked_out { background: #e2e3e5; color: #383d41; }
.badge-direct { background: #e8f5ef; color: #1a5c38; }
.badge-booking { background: #003580; color: #fff; }
.badge-agoda { background: #5c2d91; color: #fff; }
.badge-airbnb { background: #ff5a5f; color: #fff; }

/* ===== Calendar Grid ===== */
#calendar-grid-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#calendar-grid {
  display: grid;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
  min-width: max-content;
}
.cal-header-row, .cal-room-row {
  display: contents;
}
.cal-cell {
  border-right: 1px solid #e8e8e8;
  border-bottom: 1px solid #e8e8e8;
  padding: 0;
  min-height: 38px;
  min-width: 38px;
}
.cal-room-label {
  background: #f8f9fa;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 10;
  border-right: 2px solid #ddd;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.cal-room-label .room-code { color: #1a5c38; font-size: 13px; }
.cal-room-label .room-sub { color: #888; font-size: 11px; }
.cal-day-header {
  background: #1a5c38;
  color: #fff;
  text-align: center;
  padding: 6px 2px;
  font-size: 11px;
  min-width: 38px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.cal-day-header.today-col { background: #f39c12; }
.cal-day-num { font-weight: 700; font-size: 14px; }
.cal-day-name { font-size: 10px; opacity: .8; }

.cal-slot { width: 100%; height: 100%; min-height: 38px; cursor: pointer; }
.cal-slot.free { background: #fff; }
.cal-slot.free:hover { background: #e8f5ef; }
.cal-slot.occupied { background: #e74c3c; cursor: default; }
.cal-slot.occupied:hover { background: #c0392b; }
.cal-slot.checkin { background: linear-gradient(90deg, #fff 50%, #e74c3c 50%); }
.cal-slot.checkout { background: linear-gradient(90deg, #e74c3c 50%, #fff 50%); }
.cal-slot.today-col { border-left: 2px solid #f39c12; }
.cal-slot.occupied .booking-label {
  font-size: 10px; color: #fff; padding: 2px 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.corner-cell { background: #1a5c38; position: sticky; left: 0; z-index: 11; min-width: 120px; }

/* ===== Calendar Controls ===== */
.cal-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-controls .week-label { font-weight: 600; font-size: 15px; min-width: 200px; text-align: center; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 10px; padding: 24px;
  max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 18px; font-weight: 700; color: #1a5c38; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: #888; line-height: 1; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid #eee; }

/* ===== Login Page ===== */
#login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a5c38 0%, #27ae60 100%);
}
.login-card {
  background: #fff; border-radius: 12px; padding: 40px; width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-card h2 { text-align: center; margin-bottom: 8px; color: #1a5c38; }
.login-card p { text-align: center; color: #888; margin-bottom: 24px; font-size: 13px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 10px; font-size: 15px; margin-top: 8px; }

/* ===== Alerts ===== */
.alert { padding: 10px 14px; border-radius: 5px; margin-bottom: 12px; font-size: 13px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info { background: #cce5ff; color: #004085; border: 1px solid #b8daff; }

/* ===== OTA Pending Badge ===== */
.ota-badge {
  background: #e74c3c; color: #fff; border-radius: 10px;
  font-size: 11px; padding: 1px 6px; margin-left: 6px;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  #sidebar { display: none; }
  #main { padding: 12px; }
  .form-row { flex-direction: column; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
