/* ============================================
   PagoRistoApp — Custom Design System
   Stile: Colorato / Food Delivery / Mobile-first
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --primary: #FF6B35;
  --primary-dark: #E55A2B;
  --primary-light: #FF8F65;
  --secondary: #FFEAA7;
  --secondary-dark: #F0D78C;
  --accent: #00B894;
  --accent-dark: #00A381;
  --danger: #E74C3C;
  --danger-light: #FDEDEC;
  --bg: #FFF9F5;
  --surface: #FFFFFF;
  --text: #2D3436;
  --text-secondary: #636E72;
  --text-light: #B2BEC3;
  --border: #F0E6DE;
  --shadow-sm: 0 2px 8px rgba(255,107,53,0.08);
  --shadow-md: 0 4px 16px rgba(255,107,53,0.12);
  --shadow-lg: 0 8px 32px rgba(255,107,53,0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 50px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  overflow: hidden;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}

h4 {
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}

h6 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

p {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

/* --- Main Container --- */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* --- Sections (Pages) --- */
section[id^="pagina-"] {
  scrollbar-width: none;
  height: calc(100% - 90px);
  overflow-y: auto;
  display: none;
  padding-top: 8px;
  padding-bottom: 80px;
  animation: pageIn 0.4s ease-out;
}

section[id^="pagina-"]::-webkit-scrollbar {
  display: none;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- App Header --- */
.app-header {
  text-align: center;
  padding: 12px 0 8px;
}

.app-header img {
  width: 56px;
  height: 56px;
  margin-bottom: 4px;
}

.app-header .app-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

/* --- Buttons --- */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  padding: 14px 24px;
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: var(--shadow-sm);
  min-height: 48px;
  text-align: center;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

button:hover, .btn:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: var(--shadow-md);
}

button:active, .btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: var(--shadow-sm);
}

button.secondary, .btn-secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: none;
}

button.secondary:hover, .btn-secondary:hover {
  background: rgba(255, 107, 53, 0.08);
  box-shadow: none;
}

button.secondary:active, .btn-secondary:active {
  background: rgba(255, 107, 53, 0.15);
}

button.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  box-shadow: none;
}

button.ghost:hover {
  color: var(--primary);
  background: rgba(255, 107, 53, 0.05);
  box-shadow: none;
}

button.btn-success {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

button.btn-icon {
  font-size: 1.4rem;
  padding: 12px;
  width: auto;
  min-width: 48px;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  transition: all var(--transition);
  border: 1px solid var(--border);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-choice {
  cursor: pointer;
  text-align: center;
  padding: 24px 20px;
}

.card-choice:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.card-choice:active {
  transform: translateY(0);
}

.card-choice .card-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.card-choice .card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.card-choice .card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* --- Dish Card (table replacement) --- */
.dish-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  animation: cardIn 0.3s ease-out both;
}

.dish-card .dish-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.dish-card .dish-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  flex: 1;
  margin-right: 8px;
}

.dish-card .dish-ingredients {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 8px;
}

.dish-card .dish-price {
  display: inline-flex;
  align-items: center;
  background: var(--secondary);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.dish-card .dish-pay {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: right;
  margin-bottom: 8px;
}

.dish-card .dish-pay strong {
  color: var(--primary);
  font-size: 0.95rem;
}

/* --- Pill Button Group (for dish selection) --- */
.pill-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill-group button {
  flex: 1;
  min-width: 0;
  font-size: 0.72rem;
  padding: 8px 4px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  box-shadow: none;
  min-height: 36px;
  line-height: 1.2;
}

.pill-group button:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: none;
  box-shadow: none;
}

.pill-group button.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: var(--primary);
}

.pill-group button.active-other {
  background: var(--secondary);
  color: var(--text);
  border-color: var(--secondary-dark);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Stagger animation for dish cards */
.dish-card:nth-child(1) { animation-delay: 0.03s; }
.dish-card:nth-child(2) { animation-delay: 0.06s; }
.dish-card:nth-child(3) { animation-delay: 0.09s; }
.dish-card:nth-child(4) { animation-delay: 0.12s; }
.dish-card:nth-child(5) { animation-delay: 0.15s; }
.dish-card:nth-child(6) { animation-delay: 0.18s; }
.dish-card:nth-child(7) { animation-delay: 0.21s; }
.dish-card:nth-child(8) { animation-delay: 0.24s; }
.dish-card:nth-child(9) { animation-delay: 0.27s; }
.dish-card:nth-child(10) { animation-delay: 0.3s; }

/* --- Tables (for recap) --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

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

table tr:hover {
  background: rgba(255, 107, 53, 0.03);
}

table td {
  padding: 10px 4px;
  vertical-align: top;
}

table .striped tr:nth-child(even) {
  background: rgba(255, 234, 167, 0.15);
}

/* --- Badge / Price tag --- */
mark, .badge {
  background: var(--secondary);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  display: inline-block;
  margin-left: 6px;
}

/* --- Status messages --- */
.status-success {
  background: linear-gradient(135deg, rgba(0,184,148,0.1), rgba(0,184,148,0.05));
  border: 1px solid rgba(0,184,148,0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.status-success h4 {
  color: var(--accent);
  margin: 0;
}

.status-success .status-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

.status-warning {
  background: linear-gradient(135deg, rgba(231,76,60,0.1), rgba(231,76,60,0.05));
  border: 1px solid rgba(231,76,60,0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.status-warning h4 {
  color: var(--danger);
  margin: 0;
}

.status-warning .status-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  display: block;
}

/* --- Totale sticky bottom --- */
.sticky-bottom {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 80%, transparent);
  padding: 16px 0 8px;
  margin-top: 8px;
}

.total-display {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-md);
  text-align: center;
  margin-bottom: 12px;
  border: 2px solid var(--primary);
}

.total-display .total-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.total-display .total-amount {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
}

/* --- People grid (coperti) --- */
.people-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.people-grid button {
  padding: 16px 12px;
  grid-column: 1 / -1;
  font-size: 1.1rem;
  border-radius: var(--radius-lg);
}

.people-grid button.special {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.people-grid button.special.secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

/* --- Language Selector --- */
.language-selector {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
  background: var(--surface);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  padding: 4px 8px;
  border: 1px solid var(--border);
}

.language-selector select {
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  outline: none;
  padding: 2px 4px;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

/* --- Dialog / Modal --- */
dialog {
  margin: auto;
  border: none;
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 360px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease-out;
  background: var(--surface);
}

dialog::backdrop {
  background: rgba(45, 52, 54, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

dialog .pm-title {
  text-align: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
  color: var(--text);
}

dialog .pm-message {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

dialog .pm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

dialog .pm-actions button,
dialog .pm-primary {
  flex: 1;
  min-width: 60px;
  font-size: 0.9rem;
  padding: 10px 16px;
}

/* --- Footer --- */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  padding: 6px;
  font-size: 0.65rem;
  color: var(--text-light);
  background: linear-gradient(to top, var(--bg), transparent);
  pointer-events: none;
}

footer a {
  color: var(--text-light);
  pointer-events: auto;
}

footer a:hover {
  color: var(--primary);
}

/* --- Page-specific: Section centering --- */
.page-center {
  text-align: center;
  padding-top: 20px;
}

.page-center h2 {
  margin-bottom: 8px;
}

.page-center p {
  margin-bottom: 20px;
}

/* --- Spacing utilities --- */
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-sm { margin-bottom: 8px; }
.mb-md { margin-bottom: 16px; }
.mb-lg { margin-bottom: 24px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 12px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.flex-col { display: flex; flex-direction: column; }

/* --- Payment buttons with icons --- */
.payment-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px 24px;
  font-size: 1.05rem;
  margin-bottom: 10px;
}

.payment-btn .pay-icon {
  font-size: 1.4rem;
}

/* --- Recap list --- */
.recap-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.recap-item:last-child {
  border-bottom: none;
}

.recap-item .recap-name {
  flex: 1;
  font-size: 0.9rem;
}

.recap-item .recap-detail {
  font-size: 0.75rem;
  color: var(--text-light);
}

.recap-item .recap-price {
  font-weight: 700;
  color: var(--text);
  font-size: 0.9rem;
  white-space: nowrap;
  margin-left: 12px;
}

/* --- Notyf overrides for new style --- */
.notyf__toast {
  border-radius: var(--radius-md) !important;
  font-family: var(--font) !important;
}

/* --- Button group override (from Pico) --- */
[role="group"] {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- Misc --- */
.overflow-auto {
  overflow: auto;
}

/* --- Loading pulse --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* --- Responsive fine-tuning --- */
@media (max-width: 380px) {
  .pill-group button {
    font-size: 0.65rem;
    padding: 7px 2px;
  }

  .people-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

@media (min-width: 481px) {
  .container {
    padding: 0 24px;
  }
}
