/* ==========================================================================
   PRAWEENA PROPERTY 2025 - MOBILE FIRST CORE (REWRITTEN)
   ========================================================================== */

/* 1. RESET & VARIABLES */
:root {
  --primary: #d4af37;
  /* Metallic Gold */
  --primary-dark: #b8860b;
  /* Dark Gold */
  --text-main: #2b2a28;
  --text-light: #6b645d;
  --bg-body: #FDFBF7;
  --bg-card: #ffffff;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --font-main: 'Plus Jakarta Sans', 'Sarabun', sans-serif;
  --font-heading: 'Playfair Display', serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  max-width: 100%;
  /* Safe limit (was 100vw) */
  min-width: 0;
  /* Flexbox safety */
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  /* Base size */
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  background: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  width: 100%;
  min-width: 320px;
  overflow-x: hidden !important;
  position: relative;
  word-break: break-word;
  /* Prevent long text overflow */
  overflow-wrap: anywhere;
}

/* 2. TYPOGRAPHY (Mobile First) */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  line-height: 1.3;
  margin-bottom: 0.75em;
  font-weight: 700;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

p {
  margin-bottom: 1rem;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* 3. LAYOUT (Mobile Default: Stacked) */
.container,
.rl-container {
  width: 100% !important;
  max-width: 1200px;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Grids & Flex defaults to Column on Mobile */
.grid,
.detail-layout,
.row {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* 4. COMPONENTS */
.card,
.detail-card,
.filter-bar,
.stats-grid {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  width: 100%;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: 50px;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: var(--primary);
  color: #fff;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* Badge & Status */
.badge,
.status-badge {
  display: inline-flex;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  background: #eee;
  color: #555;
  white-space: nowrap;
}

.bg-success,
.status-active {
  background: #d1fae5;
  color: #065f46;
}

.bg-warning,
.status-pending {
  background: #fef3c7;
  color: #92400e;
}

.bg-danger,
.status-inactive {
  background: #fee2e2;
  color: #991b1b;
}

.bg-info {
  background: #dbeafe;
  color: #1e40af;
}

/* Tabs */
.tabs-container {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Forms */
.form-control,
.filter-input input,
.filter-select select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* Tables (Enhanced) */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
}

th {
  font-weight: 600;
  color: var(--text-light);
  background: #f9fafb;
  white-space: nowrap;
}

/* Flex Utilities for Admin Header */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.page-header-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Navigation (Mobile First) */
.nav-links,
.nav-actions,
.rl-nav-links,
.rl-nav-actions {
  display: none !important;
  /* Hide Desktop Menu on Mobile */
}

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

/* Admin: Comparison Pair (Mobile First) */
.comparison-pair {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* 5. SPECIFIC PAGES FIXES */
.detail-page {
  padding-top: 80px;
  /* Space for fixed nav */
  padding-bottom: 40px;
}

/* Slider / Gallery */
.image-gallery,
.gallery-container {
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
}

.slider-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

.leaflet-container {
  width: 100% !important;
  max-width: 100% !important;
  overflow: hidden;
  z-index: 1;
  /* Keep map below overlays */
}

.leaflet-control-attribution {
  display: none !important;
  /* Hide attribution to prevent width overflow */
}

.detail-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.rl-comparison-container {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

/* 6. TABLET & DESKTOP OVERRIDES (Progressive Enhancement) */
@media (min-width: 768px) {
  body {
    font-size: 17px;
  }

  .grid-2,
  .row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }

  .slider-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
  }

  .comparison-pair {
    flex-direction: row;
    align-items: flex-start;
  }
}

@media (min-width: 1024px) {
  h1 {
    font-size: 2.5rem;
  }

  h2 {
    font-size: 2rem;
  }

  .detail-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    /* Main content | Sidebar */
    align-items: start;
  }

  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (min-width: 900px) {

  .nav-links,
  .nav-actions,
  .rl-nav-links,
  .rl-nav-actions {
    display: flex !important;
    gap: 2rem;
    align-items: center;
  }
}

/* 7. ADMIN & UTILITIES */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.d-none {
  display: none !important;
}

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

.w-100 {
  width: 100% !important;
}

/* Scroll to Top Button */
#scroll-to-top {
  position: fixed;
  bottom: 90px;
  /* Above Add Button */
  right: auto;
  left: 24px;
  width: 40px;
  height: 40px;
  background: white;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

#scroll-to-top.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#scroll-to-top:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(243, 115, 53, 0.3);
}

@media (max-width: 640px) {
  #scroll-to-top {
    bottom: 80px;
    right: auto;
    left: 20px;
    width: 36px;
    height: 36px;
  }
}

/* 8. TOAST NOTIFICATIONS */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  /* Allow clicking through container */
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  background: white;
  color: var(--text-main);
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  min-width: 300px;
  max-width: 400px;
  pointer-events: auto;
  /* Enable clicks on toast */
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.3s ease;
  border-left: 4px solid var(--primary);
  opacity: 1;
  transform: translateX(0);
}

.toast.hide {
  animation: toastFadeOut 0.3s forwards;
}

.toast-content {
  flex-grow: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

.toast-close {
  cursor: pointer;
  opacity: 0.5;
  font-size: 1.25rem;
  line-height: 1;
  padding: 4px;
}

.toast-close:hover {
  opacity: 1;
}

/* Toast Variants */
.toast-success {
  border-left-color: #10b981;
}

.toast-success .toast-icon {
  color: #10b981;
}

.toast-error {
  border-left-color: #ef4444;
}

.toast-error .toast-icon {
  color: #ef4444;
}

.toast-warning {
  border-left-color: #f59e0b;
}

.toast-warning .toast-icon {
  color: #f59e0b;
}

.toast-info {
  border-left-color: var(--primary);
}

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

/* Animations */
@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

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

@keyframes toastFadeOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

@media (max-width: 640px) {
  #toast-container {
    bottom: 20px;
    left: 20px;
    right: 20px;
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: 100%;
  }
}
