/* ============================================================
   LE DIMORE ITALIANE - Global Styles & Responsive Utilities
   ============================================================ */

/* Base Reset */
*, *::before, *::after { box-sizing: border-box; }

/* Smooth scroll */
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

/* Typography */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ============================================================
   Responsive Images & Media
   ============================================================ */
img, video, canvas, svg { max-width: 100%; display: block; }
img { height: auto; }

/* ============================================================
   Public Template Responsive Helpers
   ============================================================ */

/* Sticky navbar for public pages */
#pub-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  transition: background .25s ease;
}

/* Public page content below sticky nav */
.pub-page-content { padding-top: 60px; }

/* Hero full-height fix for mobile notch */
.pub-hero {
  min-height: 300px;
}
@media (min-width: 768px) {
  .pub-hero { min-height: 420px; }
}

/* Gallery responsive grid */
.gallery-grid-masonry {
  column-count: 2;
  column-gap: .75rem;
}
@media (min-width: 768px) {
  .gallery-grid-masonry { column-count: 3; }
}
.gallery-grid-masonry img {
  break-inside: avoid;
  margin-bottom: .75rem;
  width: 100%;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .2s, transform .2s;
}
.gallery-grid-masonry img:hover { opacity: .9; transform: scale(1.01); }

/* Rooms grid */
.rooms-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 640px) { .rooms-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .rooms-grid { grid-template-columns: repeat(3, 1fr); } }

/* Contact sidebar: sticky on desktop, normal on mobile */
@media (min-width: 1024px) {
  .contact-sidebar-sticky { position: sticky; top: 80px; }
}

/* Horizontal scroll for quick-nav on mobile */
.pub-quick-nav {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: .75rem 1rem;
}
.pub-quick-nav::-webkit-scrollbar { display: none; }
.pub-quick-nav a {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   Dashboard & Admin Responsive
   ============================================================ */
.dashboard-sidebar {
  position: fixed;
  left: -260px;
  top: 0; bottom: 0;
  width: 260px;
  background: white;
  z-index: 100;
  transition: left .25s ease;
  overflow-y: auto;
  box-shadow: 4px 0 20px rgba(0,0,0,.08);
}
.dashboard-sidebar.open { left: 0; }
.dashboard-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 99;
}
.dashboard-sidebar-overlay.visible { display: block; }

@media (min-width: 1024px) {
  .dashboard-sidebar {
    position: sticky;
    left: 0;
    top: 0;
    height: 100vh;
    box-shadow: none;
    border-right: 1px solid #f3f4f6;
  }
  .dashboard-sidebar.open { left: 0; }
  .dashboard-sidebar-overlay { display: none !important; }
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-input {
  border: 1.5px solid #e5e7eb;
  border-radius: .5rem;
  padding: .5rem .875rem;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
  font-size: .9rem;
  background: white;
  color: #111827;
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: #8B6914;
  box-shadow: 0 0 0 3px rgba(139,105,20,.1);
}

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

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  cursor: pointer;
  font-weight: 600;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary { background: #8B6914; color: #fff; padding: .625rem 1.5rem; border-radius: .5rem; }
.btn-primary:hover, .btn-primary:focus-visible { background: #6d5210; }
.btn-secondary { background: #fff; color: #374151; padding: .625rem 1.5rem; border-radius: .5rem; border: 1.5px solid #e5e7eb; }
.btn-secondary:hover { border-color: #8B6914; color: #8B6914; }
.btn-danger { background: #ef4444; color: #fff; padding: .5rem 1rem; border-radius: .5rem; }
.btn-danger:hover { background: #dc2626; }

/* Touch target minimum size */
button, a, [role="button"] { min-height: 40px; }
@media (pointer: coarse) {
  button, a, [role="button"] { min-height: 44px; }
}

/* ============================================================
   Cards & Layout
   ============================================================ */
.card-hover {
  transition: transform .25s ease, box-shadow .25s ease;
}
.card-hover:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(139,105,20,.12);
}

/* ============================================================
   Modals - bottom sheet on mobile, centered on desktop
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }
}

.modal-box {
  background: #fff;
  border-radius: 1.25rem 1.25rem 0 0;
  padding: 1.5rem 1.5rem max(1.5rem, env(safe-area-inset-bottom));
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) {
  .modal-box {
    border-radius: .75rem;
    max-width: 640px;
    max-height: 85vh;
    padding: 2rem;
  }
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast {
  position: fixed;
  bottom: max(1.5rem, calc(1rem + env(safe-area-inset-bottom)));
  right: 1rem;
  left: 1rem;
  max-width: 400px;
  margin: 0 auto;
  z-index: 9999;
  padding: .875rem 1.25rem;
  border-radius: .75rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: slideUp .3s ease;
}
@media (min-width: 640px) { .toast { left: auto; right: 1.5rem; } }
@keyframes slideUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }

/* ============================================================
   Navigation
   ============================================================ */
.nav-link {
  color: #374151;
  text-decoration: none;
  font-weight: 500;
  padding: .4rem .5rem;
  transition: color .2s;
  cursor: pointer;
  border-radius: .375rem;
}
.nav-link:hover { color: #8B6914; }

/* Mobile menu - gestito tramite classe Tailwind 'hidden' */
#mobile-menu { transition: opacity .2s ease; }

/* ============================================================
   Loading & Spinners
   ============================================================ */
.loading-spinner { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: .5rem;
}
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ============================================================
   PWA Install Banner
   ============================================================ */
#pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  z-index: 8888;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  padding: .875rem 1rem max(0.875rem, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  animation: slideUp .3s ease;
}

/* ============================================================
   Scrollbar personalizzata
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #f3f4f6; }
::-webkit-scrollbar-thumb { background: #c4912b; border-radius: 3px; }

/* ============================================================
   Page transitions
   ============================================================ */
#app { animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity:.8; } to { opacity:1; } }

/* ============================================================
   Responsive Tables (for admin)
   ============================================================ */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ============================================================
   Grid utilities
   ============================================================ */
.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1.25rem;
}

/* ============================================================
   Stars rating
   ============================================================ */
.stars { color: #f59e0b; letter-spacing: .05em; }

/* ============================================================
   Badge
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 9999px;
  font-size: .75rem; font-weight: 500;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-gray   { background: #f3f4f6; color: #374151; }

/* ============================================================
   Builder specific
   ============================================================ */
.builder-panel {
  width: 100%;
  max-width: 420px;
}
@media (min-width: 1024px) {
  .builder-panel { min-height: 100vh; overflow-y: auto; }
}

/* ============================================================
   Details/Summary accordion
   ============================================================ */
details summary { list-style: none; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
details[open] summary { margin-bottom: .5rem; }

/* ============================================================
   Contact sidebar sticky (desktop only)
   ============================================================ */
@media (min-width: 1024px) {
  .contact-sidebar-sticky {
    position: sticky;
    top: 80px;
  }
}

/* ============================================================
   Public page: fix padding-top per nav fixed fullscreen
   ============================================================ */
.pub-fullscreen-page { padding-top: 0; }

/* ============================================================
   Split hero responsive
   ============================================================ */
@media (min-width: 768px) {
  .split-hero-grid {
    grid-template-columns: 1fr 1fr !important;
    min-height: 520px !important;
  }
  .split-hero-photo { min-height: 520px !important; }
}

/* ============================================================
   Mobile-first: pubbar labels
   ============================================================ */
@media (max-width: 640px) {
  .pubbar-back-lbl, .pubbar-call-lbl, .pubbar-wa-lbl { display: none !important; }
  .pub-nav-back-label { display: none !important; }
}

/* ============================================================
   Public rooms grid responsive
   ============================================================ */
.pub-rooms-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 640px) {
  .pub-rooms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .pub-rooms-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

/* ============================================================
   Fix: Lightbox overflow
   ============================================================ */
body.lightbox-open { overflow: hidden; }

/* ============================================================
   Responsive typography scale for public pages
   ============================================================ */
@media (max-width: 480px) {
  .pub-heading { font-size: clamp(1.1rem, 4vw, 1.5rem); }
  .pub-btn { padding: .5rem .9rem; font-size: .8rem; }
  .pub-card { border-radius: 8px !important; }
}

/* ============================================================
   PWA install banner - improved
   ============================================================ */
#pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 8888;
  background: #fff;
  border-top: 3px solid #8B6914;
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 24px rgba(0,0,0,.12);
}
.pwa-banner-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}
@media (max-width: 480px) {
  .pwa-banner-inner { gap: .5rem; }
}
