/* ==========================================================================
   MONG VIEW SAPAN RESORT - ADMIN BACKOFFICE STYLES
   ========================================================================== */

:root {
  --admin-sidebar-bg: #23362c;
  --admin-sidebar-hover: #314a3d;
  --admin-primary: #8c6742;
  --admin-primary-dark: #6e4e30;
  --admin-accent: #b94038;
  --admin-bg: #faf8f5;
  --admin-card: #ffffff;
  --admin-text: #282828;
  --admin-text-muted: #6e6e6e;
  --admin-border: #e6ded1;
  --admin-radius: 10px;
}

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

body {
  font-family: 'Noto Sans Thai', sans-serif;
  background-color: var(--admin-bg);
  color: var(--admin-text);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

/* ==========================================================================
   LOGIN SCREEN
   ========================================================================== */
.login-screen-wrap {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #12281e 0%, #1e4d3a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5000;
  padding: 20px;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-logo {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  background: var(--admin-primary);
  color: #fff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--admin-primary);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 0.88rem;
  color: var(--admin-text-muted);
  margin-bottom: 28px;
}

/* ==========================================================================
   ADMIN LAYOUT (SIDEBAR & CONTENT)
   ========================================================================== */
.admin-sidebar {
  width: 260px;
  background: var(--admin-sidebar-bg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 100vh;
}

.sidebar-brand {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-menu {
  list-style: none;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-item a:hover {
  background: var(--admin-sidebar-hover);
  color: #ffffff;
}

.sidebar-item.active a {
  background: var(--admin-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100vh;
}

.admin-topbar {
  height: 70px;
  background: #ffffff;
  border-bottom: 1px solid var(--admin-border);
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-content {
  padding: 30px;
}

/* ==========================================================================
   CARDS & TABLES
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--admin-radius);
  padding: 22px;
  border: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--admin-primary);
  font-family: 'Outfit', sans-serif;
}

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

.admin-card {
  background: #ffffff;
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
  margin-bottom: 30px;
  overflow: hidden;
}

.admin-card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.admin-table th {
  background: #f8faf9;
  padding: 14px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--admin-border);
}

.admin-table td {
  padding: 16px 20px;
  font-size: 0.92rem;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #fcfdfc;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending { background: #fef3c7; color: #b45309; }
.badge-confirmed { background: #dcfce7; color: #15803d; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-completed { background: #e0f2fe; color: #0369a1; }

/* Image Manager Modal Specifics */
/* Image Manager Modal Specifics & Action Overlay */
.admin-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 20px;
  max-height: 480px;
  overflow-y: auto;
  padding: 4px;
}

.admin-img-card, .admin-image-item {
  position: relative;
  height: 140px;
  border-radius: 10px;
  overflow: hidden;
  border: 2.5px solid transparent;
  background: #18261e;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-img-card:hover, .admin-image-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.admin-img-card.cover, .admin-image-item.is-cover {
  border-color: #d97706;
}

.admin-img-card img, .admin-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.admin-img-badge, .cover-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #d97706;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  z-index: 2;
}

.admin-img-actions, .image-actions-overlay {
  position: absolute;
  inset: 0;
  background: rgba(18, 30, 24, 0.75);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 3;
}

.admin-img-card:hover .admin-img-actions,
.admin-img-card:focus-within .admin-img-actions,
.admin-img-card.active .admin-img-actions,
.admin-image-item:hover .image-actions-overlay {
  opacity: 1;
  pointer-events: auto;
}

.btn-img-action {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: #ffffff;
  color: var(--admin-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  pointer-events: auto;
}

.btn-img-action:hover {
  transform: scale(1.05);
  background: #f8f9fa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-img-action:active {
  transform: scale(0.96);
}

.btn-img-action.delete {
  background: #fee2e2;
  color: #dc2626;
}

.btn-img-action.delete:hover {
  background: #fecaca;
}

.btn-img-action.delete:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Upload Dropzone */
.dropzone {
  border: 2px dashed var(--admin-border);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafbfa;
}

.dropzone:hover {
  border-color: var(--admin-primary);
  background: #f0f6f3;
}

/* Calendar Grid */
.calendar-grid-table {
  width: 100%;
  border-collapse: collapse;
}

.calendar-cell {
  height: 70px;
  border: 1px solid var(--admin-border);
  padding: 6px;
  vertical-align: top;
  cursor: pointer;
  transition: background 0.2s ease;
}

.calendar-cell:hover {
  background: #f0f7f3;
}

.calendar-cell.booked {
  background: #eef7f2;
  border-left: 3px solid var(--admin-primary);
}

.calendar-cell.blocked {
  background: #fdf2f2;
  border-left: 3px solid #b91c1c;
}

/* ==========================================================================
   ADMIN MODALS (ROOM EDIT, ADD, IMAGE MANAGER)
   ========================================================================== */
.modal-overlay {
  position: fixed !important;
  inset: 0 !important;
  background: rgba(18, 26, 21, 0.82) !important;
  backdrop-filter: blur(6px) !important;
  z-index: 99999 !important;
  display: none !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 20px !important;
}

.modal-overlay.active {
  display: flex !important;
}

.modal-container {
  background: #ffffff !important;
  border-radius: 14px !important;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35) !important;
  position: relative !important;
  border: 1px solid var(--admin-border) !important;
  animation: adminModalScale 0.2s ease;
}

@keyframes adminModalScale {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close-btn {
  position: absolute !important;
  top: 16px !important;
  right: 16px !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 8px !important;
  background: #f3f4f6 !important;
  border: 1px solid #e5e7eb !important;
  font-size: 1.25rem !important;
  font-weight: bold;
  color: var(--admin-text) !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 1000 !important;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
  border-color: #ef4444 !important;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

/* Role Badges */
.badge-role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-role.admin {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}
.badge-role.readonly {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

/* Booking Notes Highlight Box */
.booking-notes-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid #d97706;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  color: #92400e;
  margin-top: 8px;
}

/* User Avatar Bubble */
.user-avatar-bubble {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--admin-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

/* ==========================================================================
   ADMIN MOBILE RESPONSIVE
   ========================================================================== */
@media (max-width: 900px) {
  .admin-layout {
    flex-direction: column;
  }
  .admin-sidebar {
    width: 100%;
    height: auto;
    position: static;
  }
  .sidebar-header {
    padding: 14px 18px;
  }
  .sidebar-menu {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    padding: 6px 12px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-item a {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
  }
  .admin-main {
    padding: 16px;
  }
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .admin-stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .admin-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-table {
    min-width: 650px;
  }
  .calendar-grid-table {
    min-width: 950px;
  }
}

/* ==========================================================================
   FLOATING TOAST NOTIFICATIONS (POPUP FEEDBACK)
   ========================================================================== */
.admin-toast {
  position: fixed !important;
  top: 24px !important;
  right: 24px !important;
  z-index: 2147483647 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  pointer-events: none !important;
}

.toast-item {
  min-width: 280px;
  max-width: 440px;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-item.success {
  background: #15803d;
  color: #ffffff;
  border: 1px solid #166534;
}

.toast-item.error {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #991b1b;
}

.toast-item.info {
  background: #1f2937;
  color: #ffffff;
  border: 1px solid #111827;
}

/* Print styles for Operational Report (Multi-page Flow & Strict Isolation) */
@media print {
  @page {
    size: A4 landscape;
    margin: 10mm 10mm;
  }

  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 9.5pt !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 1. HIDE ALL non-report tabs and admin UI elements */
  .admin-tab-view:not(#view-report),
  #view-dashboard,
  #view-rooms,
  #view-mappins,
  #view-map,
  #view-calendar,
  #view-bookings,
  #view-users,
  #view-settings,
  .admin-sidebar,
  .admin-topbar,
  .admin-toast,
  .admin-toast-container,
  .modal-overlay,
  .sidebar-footer {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  /* 2. Natural flow for ancestor containers to allow multi-page printing */
  #admin-layout,
  .admin-layout,
  .admin-main,
  #view-report {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
  }

  /* 3. Hide all report controls/toolbars/filter cards */
  .no-print,
  #report-top-header,
  #report-filter-card,
  #report-kpi-grid,
  #report-category-nav,
  #view-report > div:first-child,
  #view-report .admin-card:not(#printable-report-area),
  #view-report .stats-grid,
  #report-preset-today,
  #report-preset-tomorrow,
  #report-preset-week,
  #report-preset-month,
  #report-start-date,
  #report-end-date,
  .report-cat-btn,
  #btn-copy-line-summary,
  #btn-export-csv,
  #btn-print-report,
  #btn-load-report {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
  }

  /* 4. Display ONLY the printable report card */
  #printable-report-area {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    page-break-after: auto !important;
    break-after: auto !important;
  }

  .print-only-header {
    display: block !important;
    margin-bottom: 12px !important;
    border-bottom: 2px solid #1e293b !important;
    padding-bottom: 8px !important;
  }

  #printable-report-area table,
  #printable-report-area .admin-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 0 !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  #printable-report-area thead {
    display: table-header-group !important;
  }

  #printable-report-area tbody {
    display: table-row-group !important;
  }

  #printable-report-area tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: auto !important;
    break-after: auto !important;
  }

  #printable-report-area th,
  #printable-report-area td {
    border: 1px solid #94a3b8 !important;
    padding: 5px 7px !important;
    font-size: 8.5pt !important;
    color: #0f172a !important;
    vertical-align: middle !important;
  }

  #printable-report-area th {
    background: #f1f5f9 !important;
    font-weight: 700 !important;
  }
}
