:root {
  --primary: #553928;
  /* Deep Mocha - Richer & darker than generic brown */
  --primary-dark: #3E2723;
  --accent: #C67C4E;
  /* Caramel/Bronze */
  --bg-color: #F8F5F2;
  /* Soft Oat Milk - Warm & Cozy, not stark white */
  --card-bg: #FFFFFF;

  --text-main: #2D2420;
  /* Very Dark Espresso */
  --text-muted: #887B75;
  /* Warm Grey */

  --shadow-color: 85, 57, 40;
  /* RGB for Deep Mocha */

  --shadow-sm: 0 1px 3px rgba(var(--shadow-color), 0.1), 0 1px 2px rgba(var(--shadow-color), 0.15);
  --shadow-md: 0 4px 6px -1px rgba(var(--shadow-color), 0.08), 0 2px 4px -1px rgba(var(--shadow-color), 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(var(--shadow-color), 0.1), 0 4px 6px -2px rgba(var(--shadow-color), 0.05);

  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-pill: 9999px;

  --font-en: "Outfit", sans-serif;
  --font-ar: "Cairo", sans-serif;
}

body.dark-mode {
  --primary: #D2691E;
  /* Chocolate - Lighter for dark mode */
  --primary-dark: #8B4513;
  /* SaddleBrown */
  --accent: #FFA07A;
  /* Light Salmon/Gold */

  --bg-color: #1A0F0A;
  /* Very Dark Coffee */
  --card-bg: #2C1810;
  /* Dark Coffee Bean */

  --text-main: #FFF8E7;
  /* Cream */
  --text-muted: #D7CCC8;
  /* Light Grey-ish Brown */

  --shadow-color: 0, 0, 0;
  /* Black shadows for dark mode look better */

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-en);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  transition: all 0.3s ease;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
}

html[dir="rtl"] {
  font-family: var(--font-ar);
}

/* Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.main-header {
  background-color: var(--card-bg);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 1rem 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  min-width: 0;
  flex-shrink: 1;
}

.logo i {
  color: var(--primary);
}

.logo h1 {
  font-size: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.site-logo-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: contain;
}

.btn-lang {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary-dark);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.btn-lang:hover {
  background-color: var(--primary);
  color: white;
}

/* Categories */
.category-nav-wrapper {
  background: var(--card-bg);
  border-bottom: 1px solid #e2e8f0;
  padding: 1rem 0;
  margin-bottom: 2rem;
}

.category-nav {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  /* For scrollbar space if needed */
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  background: var(--card-bg);
  border: 1px solid #e2e8f0;
  padding: 0.6rem 1.4rem;
  border-radius: 14px;
  /* More modern soft-square radius */
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: inherit;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  user-select: none;
}


.cat-btn.active {
  background: linear-gradient(135deg,
      var(--primary) 0%,
      var(--primary-dark) 100%);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 8px 15px -3px rgba(var(--shadow-color), 0.4);
}

.cat-btn:hover:not(.active) {
  background-color: #f8fafc;
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Indicators for active state */
.cat-btn.active::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 3px;
  background: var(--primary);
  border-radius: 10px;
}

.cat-admin-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

[dir="rtl"] .cat-admin-actions {
  margin-left: 0;
  margin-right: 0.5rem;
}

.cat-action-btn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.8rem;
  transition: all 0.2s;
  background: rgba(255, 255, 255, 0.2);
}

.cat-action-btn.edit:hover {
  background-color: #2ecc71;
  color: white;
}

.cat-action-btn.delete:hover {
  background-color: #e74c3c;
  color: white;
}

.cat-btn.admin-cat {
  padding-right: 0.75rem;
}

[dir="rtl"] .cat-btn.admin-cat {
  padding-right: 1.5rem;
  padding-left: 0.75rem;
}

/* Menu Grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  padding-bottom: 4rem;
}

/* Card */
.menu-card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid #f1f5f9;

  /* Initial state for scroll animation */
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out,
    box-shadow 0.3s ease;
}

/* Visible state when scrolled into view */
.menu-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.menu-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.card-image-wrapper {
  position: relative;
  padding-top: 75%;
  /* 4:3 Aspect Ratio */
  background-color: #f3f4f6;
  overflow: hidden;
}

.card-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.menu-card:hover .card-image {
  transform: scale(1.05);
}

.card-content {
  padding: 1.5rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  gap: 1rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.card-price {
  font-weight: 700;
  color: #5D2906;
  font-size: 1.1rem;
  background: #FFE4C4;
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  direction: ltr !important;
  /* Forces [Number] then [Currency] correctly */
}

.price-value {
  letter-spacing: 0.5px;
  font-family: var(--font-en);
  /* Numbers always look better in English font */
}

.price-currency {
  font-size: 0.85em;
  font-weight: 700;
  font-family: var(--font-ar);
}

.card-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

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

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

/* Desktop Visibility Logic (Default) */
.mobile-only {
  display: none !important;
}

/* Individual admin buttons logic */
#add-item-btn,
#add-category-btn,
#settings-btn,
#logout-btn {
  display: none;
}

/* Show only when logged in */
body.logged-in #add-item-btn,
body.logged-in #add-category-btn,
body.logged-in #settings-btn,
body.logged-in #logout-btn {
  display: inline-flex;
}

/* Theme/Lang always on desktop */
#theme-toggle,
#lang-switch {
  display: inline-flex;
}

/* Intermediate screens / Landscape mobile / Tablets */
@media (max-width: 1024px) {
  .btn-text {
    display: none;
  }

  .btn-primary {
    padding: 0.55rem;
    gap: 0;
    min-width: 40px;
    justify-content: center;
    border-radius: 50%;
    /* Make them circular like other icons */
    width: 40px;
    height: 40px;
  }

  .header-actions {
    gap: 0.5rem;
  }

  .logo h1 {
    font-size: 1.1rem;
  }

  .site-logo-img {
    width: 60px;
    height: 60px;
  }
}

@media (max-width: 850px) {
  .logo h1 {
    display: none;
    /* Hide site name on small landscape to save space */
  }

  #item-counter .counter-label {
    display: none;
    /* Only show the number and icon */
  }

  .item-counter {
    padding: 0.4rem 0.6rem;
    gap: 0.3rem;
  }
}

/* Responsive Overrides */
@media (max-width: 640px) {
  .container {
    padding: 0 1rem;
  }

  .menu-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding-bottom: 6rem;
  }

  .card-content {
    padding: 0.75rem;
  }

  .card-title {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
  }

  .card-header {
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
  }

  .card-price {
    font-size: 0.85rem;
    padding: 0.15rem 0.5rem;
    align-self: flex-start;
  }

  .card-desc {
    font-size: 0.8rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .btn-card-action {
    padding: 0.4rem;
    font-size: 0.8rem;
  }

  /* Adjust Header for mobile - Professional Optimized */
  .header-content {
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0 0.5rem;
    height: 60px;
    width: 100%;
    overflow: hidden;
  }

  .logo {
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    max-width: 70%;
    /* Prevent logo from taking too much space */
  }

  .logo h1 {
    font-size: 0.9rem;
    /* Smaller for mobile */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
  }

  /* On extremely narrow screens, hide the site name to keep it clean */
  @media (max-width: 350px) {
    .logo h1 {
      display: none;
    }
  }

  .header-actions {
    gap: 0.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }

  /* Mobile Visibility: Show ":" and hide everything else */
  #add-item-btn,
  #add-category-btn,
  #settings-btn,
  #logout-btn,
  #theme-toggle,
  #lang-switch {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
    background: var(--primary) !important;
    /* Make it a solid colorful button so it's impossible to miss */
    color: white !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    box-shadow: 0 4px 10px rgba(var(--shadow-color), 0.3) !important;
  }
}

/* Mobile Menu Styles */
.mobile-menu {
  position: absolute;
  top: 100%;
  right: 1.5rem;
  width: 240px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px) saturate(160%);
  -webkit-backdrop-filter: blur(15px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  transform-origin: top right;
  transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  opacity: 1;
  transform: translateY(10px);
}

body.dark-mode .mobile-menu {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(255, 255, 255, 0.1);
}

.mobile-menu.hidden {
  opacity: 0;
  transform: translateY(0) scale(0.95);
  pointer-events: none;
}

.mobile-admin-actions {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
}

.mobile-menu-item {
  display: flex !important;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

[dir="rtl"] .mobile-menu-item {
  text-align: right;
}

.mobile-menu-item:hover {
  background: rgba(139, 69, 19, 0.1);
  color: var(--primary-dark);
}

.mobile-menu-item i {
  width: 24px;
  font-size: 1.1rem;
  color: var(--primary);
}

.mobile-menu-item.logout {
  color: #ef4444;
}

.mobile-menu-item.logout i {
  color: #ef4444;
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}


.btn-primary {
  background: linear-gradient(135deg,
      var(--primary) 0%,
      var(--primary-dark) 100%);
  color: white;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-lg);
  min-height: 40px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(var(--shadow-color), 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 16px rgba(var(--shadow-color), 0.4);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.btn-icon:hover {
  background-color: #e2e8f0;
  color: var(--primary);
}

body.dark-mode .btn-icon:hover {
  background-color: #334155;
  color: var(--primary);
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.modal-content {
  background: var(--card-bg);
  width: 90%;
  max-width: 500px;
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  max-height: 90vh;
  overflow-y: auto;
}

.modal.hidden .modal-content {
  transform: scale(0.9);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 1rem;
}

.modal-header h2 {
  color: var(--primary-dark);
  font-size: 1.5rem;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  color: #ef4444;
  transform: rotate(90deg);
}

/* Form Styles */
form#add-item-form {
  padding: 2rem;
}

/* Professional Form Layout */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
  }
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
}

.form-row .form-group {
  margin-bottom: 0;
}

label {
  display: block;
  margin-bottom: 0.6rem;
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  background: #ffffff;
  color: var(--text-main);
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  resize: none;
  scroll-margin-top: 120px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(var(--shadow-color), 0.15);
  background: #fff;
}


input.error,
select.error,
textarea.error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15) !important;
}

/* Dark Mode Input Styles */
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
  background: var(--card-bg);
  color: var(--text-main);
  border-color: #475569;
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
  background: var(--card-bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(94, 234, 212, 0.15);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

body.dark-mode select option {
  background: var(--card-bg);
  color: var(--text-main);
}

/* Single Image Action Button & Menu */
.image-selector-wrapper {
  position: relative;
}

.btn-image-action {
  width: 100%;
  padding: 12px 20px;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 14px;
  color: var(--text-main);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-image-action:hover {
  border-color: var(--primary);
  background: #f0fdfa;
  transform: translateY(-1px);
}

/* Dark Mode Image Button */
body.dark-mode .btn-image-action {
  background: #1e293b;
  border-color: #475569;
  color: var(--text-main);
}

body.dark-mode .btn-image-action:hover {
  background: #334155;
  border-color: var(--primary);
}

.image-options-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-radius: 20px;
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  z-index: 100;
  padding: 10px;
  opacity: 1;
  transform: translateY(0) scale(1);
  transform-origin: top;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

body.dark-mode .image-options-menu {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
}

.image-options-menu.hidden {
  opacity: 0;
  transform: translateY(-15px) scale(0.92);
  pointer-events: none;
}

.image-option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  width: 100%;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.image-option-item:hover {
  background: #f1f5f9;
  color: var(--primary-dark);
}

.image-option-item i {
  font-size: 1.25rem;
  color: var(--primary);
  width: 24px;
  text-align: center;
}

.btn-submit {
  width: 100%;
  background: linear-gradient(135deg,
      var(--primary) 0%,
      var(--primary-dark) 100%);
  color: white;
  border: none;
  padding: 1.1rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  margin-top: 1.5rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 15px -3px rgba(var(--shadow-color), 0.3);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgba(var(--shadow-color), 0.4);
}

/* Card Actions */
.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.btn-card-action {
  flex: 1;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  font-family: inherit;
}

.btn-edit {
  background-color: #f8fafc;
  color: var(--text-muted);
  border: 1px solid #e2e8f0;
}

.btn-edit:hover {
  background-color: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-delete {
  background-color: #fef2f2;
  color: #ef4444;
  border: 1px solid #fecaca;
}

.btn-delete:hover {
  background-color: #ef4444;
  color: white;
  border-color: #ef4444;
}

/* Professional Camera & Preview System */
.camera-interface {
  margin-top: 15px;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-controls-v2 {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  z-index: 10;
}

.cam-btn-primary {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.cam-btn-primary:active {
  transform: scale(0.9);
}

.cam-btn-inner {
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 50%;
}

.cam-btn-secondary {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border: none;
  cursor: pointer;
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.cam-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.4);
}

.preview-container {
  margin-top: 15px;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  height: 180px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}

#image-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Professional look for varied aspect ratios */
  background: #000;
}

.preview-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
}

.btn-remove-preview {
  width: 36px;
  height: 36px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.2s;
}

.btn-remove-preview:hover {
  background: #dc2626;
  transform: scale(1.05);
}

body.dark-mode .preview-container {
  border-color: #334155;
  background: #0f172a;
}

body.dark-mode .upload-v5-choice {
  background: #0f172a;
  border-color: #334155;
  color: #fff;
}

body.dark-mode .v5-text strong {
  color: #fff;
}

.hidden {
  display: none !important;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background-color: var(--bg-color);
}

.login-body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg,
      rgba(45, 212, 191, 0.1) 0%,
      rgba(20, 184, 166, 0.1) 100%);
  z-index: -1;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.login-logo {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.login-card h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.login-form {
  text-align: left;
}

.input-wrapper {
  position: relative;
}

.input-wrapper i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.login-form input {
  padding-left: 3rem !important;
}

[dir="rtl"] .input-wrapper i {
  left: auto;
  right: 1rem;
}

[dir="rtl"] .login-form input {
  padding-left: 1rem !important;
  padding-right: 3rem !important;
  text-align: right;
}

.btn-login {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-login:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(var(--shadow-color), 0.3);
}

#login-error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  display: none;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

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

/* Safety: Always hide admin buttons for non-logged in users */
#add-item-btn,
#add-category-btn,
#logout-btn {
  display: none;
}

/* Category Delete Button */
.cat-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-radius: 50%;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 5px;
}

[dir="rtl"] .cat-delete-btn {
  margin-left: 0;
  margin-right: 5px;
}

.cat-delete-btn:hover {
  background: #ef4444 !important;
  color: white !important;
  transform: scale(1.1);
}

.cat-btn.active .cat-delete-btn {
  background: rgba(255, 255, 255, 0.25);
  color: white;
}

.cat-btn.active .cat-delete-btn:hover {
  background: white !important;
  color: #ef4444 !important;
}

body.dark-mode .cat-btn:not(.active) .cat-delete-btn {
  background: rgba(239, 68, 68, 0.25);
}

/* Professional Confirm Modal */
.confirm-modal-content {
  text-align: center;
  max-width: 400px;
  padding: 2.5rem;
}

.confirm-icon {
  font-size: 4rem;
  color: #facc15;
  margin-bottom: 1.5rem;
  animation: heartBeat 1.5s ease-in-out infinite;
}

@keyframes heartBeat {
  0% {
    transform: scale(1);
  }

  14% {
    transform: scale(1.1);
  }

  28% {
    transform: scale(1);
  }

  42% {
    transform: scale(1.1);
  }

  70% {
    transform: scale(1);
  }
}

.confirm-modal-content h2 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.confirm-modal-content p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-muted);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-secondary:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-danger {
  background: #ef4444;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
  box-shadow: 0 6px 8px -1px rgba(239, 68, 68, 0.5);
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

[dir="rtl"] .toast-container {
  right: auto;
  left: 2rem;
}

.toast {
  background: var(--card-bg);
  color: var(--text-main);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  border-left: 4px solid var(--primary);
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[dir="rtl"] .toast {
  border-left: none;
  border-right: 4px solid var(--primary);
  animation: slideInLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.toast i {
  font-size: 1.25rem;
}

.toast.error i {
  color: #ef4444;
}

.toast.success i {
  color: #10b981;
}

/* Mobile: Move toasts to top to avoid keyboard */
@media (max-width: 768px) {
  .toast-container {
    top: 1rem;
    bottom: auto;
    right: 1rem;
    left: 1rem;
    align-items: stretch;
  }

  .toast {
    min-width: auto;
    width: 100%;
    animation: slideInDown 0.3s ease-out;
  }

  @keyframes slideInDown {
    from {
      transform: translateY(-100%);
      opacity: 0;
    }

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

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

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

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }

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

/* Settings Premium UI Extra */
#settings-form .form-row {
  background: rgba(var(--shadow-color), 0.03);
  padding: 1.5rem;
  border-radius: 18px;
  border: 1px solid rgba(var(--shadow-color), 0.1);
  margin-bottom: 2rem;
}

body.dark-mode #settings-form .form-row {
  background: rgba(var(--shadow-color), 0.05);
  border-color: rgba(var(--shadow-color), 0.15);
}

.preview-container {
  margin-top: 1.5rem;
  width: 140px;
  height: 140px;
  margin-inline: auto;
  position: relative;
  background: white;
  z-index: 10;
  /* Added padding to prevent button clipping */
  padding: 5px;
}

.preview-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
  border: 3px solid var(--primary);
  box-shadow: 0 8px 25px rgba(var(--shadow-color), 0.2);
}

/* Specific adjustment for logo preview to use contain if needed, or keep cover for consistency */
#logo-preview-container img {
  object-fit: contain;
}

.preview-overlay {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 20;
}

.btn-remove-preview {
  background: #ff4757;
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-remove-preview:hover {
  transform: scale(1.15) rotate(15deg);
  background: #ff6b81;
  box-shadow: 0 6px 16px rgba(255, 71, 87, 0.5);
}

.toast.fade-out {
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.3s ease;
}

/* ===================================
   Item Counter (Admin Only)
   =================================== */
.item-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg,
      var(--primary) 0%,
      var(--primary-dark) 100%);
  color: white;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-pill);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(var(--shadow-color), 0.3);
  transition: all 0.3s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.item-counter.hidden {
  display: none;
}

.item-counter i {
  font-size: 1.1rem;
}

#item-count {
  font-size: 1.25rem;
  font-family: var(--font-en);
  letter-spacing: 0.5px;
  min-width: 24px;
  text-align: center;
}

.counter-label {

  font-size: 0.85rem;
  opacity: 0.9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-logo-img {
  width: 180px;
  height: 180px;
  object-fit: contain;
}


@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

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

/* Responsive Item Counter */
@media (max-width: 768px) {
  .item-counter {
    padding: 0.4rem 0.75rem;
    gap: 0.4rem;
  }

  #item-count {
    font-size: 1rem;
    min-width: 20px;
  }

  .counter-label {
    font-size: 0.75rem;
  }

  .item-counter i {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  .counter-label {
    display: none;
  }

  .item-counter {
    padding: 0.4rem 0.6rem;
    min-width: 60px;
    justify-content: center;
  }

  .logo h1 {
    display: none !important;
  }
}

/* ===================================
   Scroll to Top Button
   =================================== */
.scroll-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg,
      var(--primary) 0%,
      var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 8px 20px rgba(var(--shadow-color), 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  opacity: 1;
  transform: scale(1);
}

.scroll-to-top.hidden {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.scroll-to-top:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 12px 28px rgba(var(--shadow-color), 0.5);
}

.scroll-to-top:active {
  transform: translateY(-3px) scale(1.05);
}

.scroll-to-top i {
  animation: bounceUp 2s infinite;
}

@keyframes bounceUp {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}

/* Responsive Scroll Button */
@media (max-width: 768px) {
  .scroll-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .scroll-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
}

/* RTL Support */
[dir="rtl"] .scroll-to-top {
  right: auto;
  left: 2rem;
}

@media (max-width: 768px) {
  [dir="rtl"] .scroll-to-top {
    left: 1.5rem;
  }
}

@media (max-width: 480px) {
  [dir="rtl"] .scroll-to-top {
    left: 1rem;
  }
}