:root {
  --sage: #9CAF88;
  --sage-dark: #7A9068;
  --sage-light: #B5C4A5;
  --sage-pale: #DDE5D6;
  --cream: #F7F5F0;
  --cream-dark: #EDE9E1;
  --wood: #C9B99A;
  --black: #1A1A1A;
  --text-primary: #2D3436;
  --text-muted: #7A8578;
  --bg: #F7F5F0;
  --bg-card: #FFFFFF;
  --bg-card-hover: #FAFAF8;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 2px 16px rgba(45, 52, 54, 0.06);
  --shadow-hover: 0 8px 32px rgba(45, 52, 54, 0.1);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.bg-pattern {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(156, 175, 136, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 100% 100%, rgba(201, 185, 154, 0.1) 0%, transparent 50%),
    var(--bg);
  z-index: -1;
}

/* Logo */
.cafe-logo {
  width: 180px;
  height: auto;
  max-height: 180px;
  margin: 0 auto 12px;
  display: block;
  border-radius: 0;
  box-shadow: none;
  animation: none;
  background: transparent;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(45, 52, 54, 0.08));
}

.cafe-logo.small {
  width: 130px;
  max-height: 130px;
}

/* ===== MENU PAGE ===== */

.menu-page { overflow-x: hidden; }

.hero {
  text-align: center;
  padding: 40px 24px 24px;
}

.hero-inner { animation: fadeDown 0.7s ease both; }

.cafe-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -0.3px;
}

.cafe-name span {
  color: var(--sage-dark);
}

.cafe-tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 6px;
  font-weight: 400;
}

.cafe-location {
  color: var(--sage-dark);
  font-size: 0.8rem;
  margin-top: 4px;
  font-weight: 500;
  opacity: 0.8;
}

.scroll-hint {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  animation: fadeIn 1s 0.4s ease both;
}

.scroll-arrow {
  width: 16px;
  height: 16px;
  border-right: 2px solid var(--sage);
  border-bottom: 2px solid var(--sage);
  transform: rotate(45deg);
  animation: bounce 1.5s infinite;
}

/* Category nav */
.category-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(247, 245, 240, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--sage-pale);
  -webkit-overflow-scrolling: touch;
}

.category-nav::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  padding: 8px 20px;
  border: 1.5px solid var(--sage-pale);
  border-radius: 50px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.cat-btn:hover {
  border-color: var(--sage-light);
  color: var(--sage-dark);
}

.cat-btn.active {
  background: var(--sage);
  color: white;
  border-color: var(--sage);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(156, 175, 136, 0.3);
}

/* Menu container */
.menu-container {
  padding: 16px 16px 60px;
  max-width: 560px;
  margin: 0 auto;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 0;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--sage-pale);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.category-section { margin-bottom: 28px; }

.category-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--sage-dark);
  margin-bottom: 14px;
  padding: 6px 14px;
  background: var(--sage-pale);
  border-radius: 50px;
  display: inline-block;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.category-title.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Product card */
.product-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(156, 175, 136, 0.12);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease, box-shadow var(--transition);
  overflow: hidden;
  min-height: 112px;
}

.product-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.product-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--sage-light);
}

.product-image-wrap {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  min-width: 88px;
  max-width: 88px;
  min-height: 88px;
  max-height: 88px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--cream-dark);
  position: relative;
}

.product-image-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.4s ease;
}

.product-card:hover .product-image-wrap img {
  transform: scale(1.04);
}

.product-image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: var(--sage-pale);
  color: var(--sage-dark);
}

.product-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.product-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--black);
  margin-bottom: 3px;
}

.product-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  margin-top: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--sage-dark);
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.menu-footer {
  text-align: center;
  padding: 24px 24px 40px;
  border-top: 1px solid var(--sage-pale);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
}

.footer-copy {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.instagram-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 50px;
  background: var(--black);
  color: white;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
}

.instagram-link:hover {
  background: var(--sage-dark);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(122, 144, 104, 0.3);
}

.instagram-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.qr-instagram { margin-bottom: 16px; }

/* ===== ADMIN PAGE ===== */

.admin-page { background: var(--cream-dark); }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 36px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  border: 1px solid var(--sage-pale);
  box-shadow: var(--shadow-hover);
}

.login-card h2 {
  font-size: 1.1rem;
  margin-bottom: 20px;
  color: var(--black);
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--sage-pale);
  background: var(--cream);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  margin-bottom: 14px;
  outline: none;
  transition: border-color var(--transition);
}

.login-card input:focus { border-color: var(--sage); }

.login-hint {
  margin-top: 10px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.error-msg {
  color: #e74c3c;
  font-size: 0.84rem;
  margin-top: 8px;
}

.admin-panel {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--sage-pale);
}

.admin-header h1 {
  font-size: 1.3rem;
  color: var(--black);
}

.admin-header p {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-primary, .btn-outline, .btn-ghost {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: var(--sage);
  color: white;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--sage-dark);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--bg-card);
  border: 1.5px solid var(--sage-pale);
  color: var(--sage-dark);
}

.btn-outline:hover {
  border-color: var(--sage);
  background: var(--sage-pale);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover { color: var(--black); }
.btn-ghost.small { padding: 6px 12px; font-size: 0.78rem; }

.btn-primary.small { padding: 7px 14px; font-size: 0.8rem; }

.btn-danger {
  background: #FEF2F2;
  color: #e74c3c;
  border: 1px solid #FECACA;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-danger:hover { background: #FEE2E2; }

.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--sage-pale);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  border-color: var(--sage);
  color: var(--sage-dark);
  background: var(--sage-pale);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.admin-form-section, .admin-list-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  border: 1px solid var(--sage-pale);
  box-shadow: var(--shadow);
}

.admin-form-section h2, .admin-list-section h2 {
  font-size: 1rem;
  color: var(--black);
  margin-bottom: 18px;
}

.badge {
  background: var(--sage);
  color: white;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 50px;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--sage-pale);
  background: var(--cream);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus { border-color: var(--sage); }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.image-upload input[type="file"] {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.image-preview {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.image-preview img {
  width: 88px;
  height: 88px;
  min-width: 88px;
  max-width: 88px;
  min-height: 88px;
  max-height: 88px;
  object-fit: cover;
  object-position: center;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sage-pale);
}

.add-category {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--sage-pale);
}

.add-category input {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--sage-pale);
  background: var(--cream);
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
}

.add-category input:focus { border-color: var(--sage); }

.admin-product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-product-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  border: 1px solid var(--sage-pale);
  transition: var(--transition);
}

.admin-product-item.inactive { opacity: 0.45; }

.admin-product-item img,
.admin-product-thumb {
  width: 52px;
  height: 52px;
  min-width: 52px;
  max-width: 52px;
  min-height: 52px;
  max-height: 52px;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
  background: var(--sage-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--sage-dark);
  overflow: hidden;
}

/* Category management */
.admin-category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--cream);
  border-radius: var(--radius-sm);
  border: 1px solid var(--sage-pale);
}

.admin-category-item.editing {
  border-color: var(--sage);
  background: var(--bg-card);
}

.category-name {
  flex: 1;
  font-size: 0.9rem;
  color: var(--black);
  font-weight: 500;
}

.category-edit-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--sage);
  background: white;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

.category-controls {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.admin-product-details { flex: 1; min-width: 0; }

.admin-product-details h3 {
  font-size: 0.9rem;
  color: var(--black);
  margin-bottom: 2px;
}

.admin-product-details p {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.admin-product-controls {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

/* ===== QR PAGE ===== */

.qr-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--bg);
}

.qr-container {
  text-align: center;
  max-width: 400px;
  width: 100%;
}

.qr-subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.qr-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  display: inline-block;
  box-shadow: var(--shadow-hover);
  margin-bottom: 14px;
  border: 1px solid var(--sage-pale);
}

.qr-image {
  width: 220px;
  height: 220px;
  display: block;
}

.qr-url {
  font-size: 0.72rem;
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: 20px;
}

.qr-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qr-print-note {
  margin-top: 28px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  border: 1px solid var(--sage-pale);
}

/* Animations */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounce {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50% { transform: rotate(45deg) translateY(5px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
  .cafe-logo { width: 140px; }
  .cafe-name { font-size: 1.4rem; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-product-item { flex-wrap: wrap; }
  .admin-product-controls { width: 100%; justify-content: flex-end; }
  .product-image-wrap { width: 76px; height: 76px; }
}

@media (min-width: 601px) {
  .qr-actions { flex-direction: row; justify-content: center; }
}

/* Admin theme settings */
.admin-settings-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  border: 1px solid var(--sage-pale);
  box-shadow: var(--shadow);
}

.admin-settings-section h2 {
  font-size: 1rem;
  color: var(--black);
  margin-bottom: 6px;
}

.settings-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.theme-switch {
  display: flex;
  gap: 10px;
}

.theme-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--sage-pale);
  background: var(--cream);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.theme-btn .theme-icon {
  font-size: 1.4rem;
}

.theme-btn:hover {
  border-color: var(--sage-light);
  color: var(--sage-dark);
}

.theme-btn.active {
  border-color: var(--sage);
  background: var(--sage-pale);
  color: var(--black);
  box-shadow: 0 2px 12px rgba(156, 175, 136, 0.25);
}
