/* =============================================
   Café da Manhã — Vila Pitangueira
   Design System: Clean Pastel (matching Guia Digital)
   ============================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Playfair+Display:wght@500;600;700&display=swap');

/* ---- Design Tokens ---- */
:root {
  --primary: #42553f;
  --primary-light: #5a7355;
  --primary-pastel: #e8ede7;
  --primary-soft: #d1dbd0;
  --primary-muted: #7a8f76;

  --accent: #a86a47;
  --accent-light: #c4896a;
  --accent-pastel: #f2e6dd;
  --accent-soft: #e5cdbf;

  --bg: #fafaf8;
  --bg-white: #ffffff;
  --text: #2d2d2d;
  --text-secondary: #6b6b6b;
  --text-light: #999999;
  --border: #e8e8e5;
  --border-light: #f0f0ed;

  --success: #22c55e;
  --success-pastel: #dcfce7;
  --warning: #f59e0b;
  --danger: #ef4444;

  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 480px;
}

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

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img {
  max-width: 100%;
  display: block;
}

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

/* ---- Hero Header ---- */
.hero {
  position: relative;
  background: var(--bg-white);
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.hero-logo {
  width: 100px;
  height: auto;
  margin: 0 auto 0.8rem;
  display: block;
}

.hero-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-pastel);
  padding: 0.35rem 1rem;
  border-radius: 20px;
  margin-bottom: 0.6rem;
}

.hero-greeting {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 300;
  letter-spacing: 0.02em;
  margin-top: 0.5rem;
}

/* ---- Language Selector ---- */
.language-selector {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 0;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
}

.lang-btn {
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.5;
  transition: all var(--transition);
  background: none;
  border: 2px solid transparent;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.lang-btn:hover {
  opacity: 0.8;
  background: var(--primary-pastel);
}

.lang-btn.active {
  opacity: 1;
  background: var(--primary-pastel);
  border-color: var(--primary-soft);
}

/* ---- Main Container ---- */
.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.2rem 1rem 6rem;
}

/* ---- Loading ---- */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  gap: 1rem;
}

.loading p {
  color: var(--text-light);
  font-size: 0.85rem;
  font-weight: 400;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ---- Selection Card (Apartment & Time) ---- */
.selection-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1rem;
  animation: fadeUp 0.4s ease both;
}

.selection-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.selection-icon {
  font-size: 1.2rem;
}

.select-group {
  margin-bottom: 0.8rem;
}

.select-group:last-child {
  margin-bottom: 0;
}

.select-group label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.select-group select {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.select-group select:focus {
  outline: none;
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-pastel);
}

/* ---- Category Cards ---- */
.category-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  overflow: hidden;
  transition: all var(--transition);
  animation: fadeUp 0.4s ease both;
}

.category-card:hover {
  border-color: var(--primary-soft);
}

.category-card.active {
  border-color: var(--primary-soft);
  box-shadow: var(--shadow-sm);
}

.category-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.2rem;
  cursor: pointer;
  gap: 0.8rem;
  transition: background var(--transition);
  user-select: none;
  -webkit-user-select: none;
}

.category-header:hover {
  background: var(--primary-pastel);
}

.category-card.active .category-header {
  background: var(--primary-pastel);
  border-bottom: 1px solid var(--border-light);
}

.category-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.category-name {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.category-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--bg-white);
  background: var(--primary);
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--transition);
}

.category-count.visible {
  opacity: 1;
  transform: scale(1);
}

.category-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-light);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.category-card.active .category-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

.category-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-card.active .category-body {
  max-height: 2000px;
}

.category-items {
  padding: 0.6rem 0.8rem;
}

/* ---- Item Rows ---- */
.item-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
  -webkit-user-select: none;
}

.item-row:hover {
  background: var(--primary-pastel);
}

.item-row.selected {
  background: var(--primary-pastel);
}

.item-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  background: var(--bg-white);
}

.item-row.selected .item-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}

.item-checkbox svg {
  width: 14px;
  height: 14px;
  color: white;
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--transition);
}

.item-row.selected .item-checkbox svg {
  opacity: 1;
  transform: scale(1);
}

.item-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.item-name {
  flex: 1;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.item-row.selected .item-name {
  color: var(--text);
  font-weight: 500;
}

/* ---- Observation Card ---- */
.observation-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-top: 0.6rem;
  margin-bottom: 1rem;
  animation: fadeUp 0.4s ease both;
}

.observation-card h3 {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.obs-icon {
  font-size: 1.1rem;
}

.observation-card textarea {
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  resize: none;
  transition: border-color var(--transition);
  line-height: 1.5;
}

.observation-card textarea:focus {
  outline: none;
  border-color: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-pastel);
}

.observation-card textarea::placeholder {
  color: var(--text-light);
}

/* ---- Order Button ---- */
.btn-order {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--bg-white);
  background: var(--accent);
  border: none;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}

.btn-order:hover:not(:disabled) {
  background: var(--accent-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-order:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-order:active:not(:disabled) {
  transform: translateY(0);
}

.order-count {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255,255,255,0.25);
  min-width: 24px;
  height: 24px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: var(--max-width);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.modal-header h2 {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body {
  padding: 1.2rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 0.8rem;
  flex-shrink: 0;
}

/* Summary styles */
.summary-section {
  margin-bottom: 1rem;
}

.summary-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-light);
  margin-bottom: 0.3rem;
}

.summary-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--primary);
}

.summary-category {
  margin-bottom: 0.8rem;
}

.summary-category-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.summary-items {
  padding-left: 1.5rem;
}

.summary-item {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.15rem 0;
}

.summary-obs {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--accent-pastel);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent-soft);
}

.summary-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 0.8rem 0;
}

/* Modal buttons */
.btn-back {
  flex: 1;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-back:hover {
  background: var(--border);
}

.btn-confirm {
  flex: 2;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg-white);
  background: #25d366;
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-confirm:hover {
  background: #20bd5a;
  box-shadow: var(--shadow-sm);
}

/* ---- Success Overlay ---- */
.success-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.success-card {
  text-align: center;
  animation: scaleIn 0.5s ease;
  max-width: 320px;
}

.success-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.success-card h2 {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.6rem;
}

.success-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.btn-new-order {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bg-white);
  background: var(--primary);
  border: none;
  padding: 0.85rem 2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-new-order:hover {
  background: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--bg-white);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 3000;
  transition: transform 0.3s ease;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: calc(var(--max-width) - 2rem);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

/* ---- Footer ---- */
.footer {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  color: var(--text-light);
  font-size: 0.78rem;
}

.footer strong {
  color: var(--primary);
  font-weight: 600;
}

/* ---- Responsive ---- */
@media (min-width: 481px) {
  .modal {
    border-radius: var(--radius-xl);
    max-height: 80vh;
    margin-bottom: 2rem;
  }

  .modal-overlay {
    align-items: center;
  }
}
