/* =========================================================================
   ADMIN.CSS — Premium QR Menu Admin Panel
   Reuses the design tokens from style.css; adds admin-specific layout.
   ========================================================================= */
:root {
  --color-primary: #E53935;
  --color-bg: #FFF8F2;
  --color-surface: #FFFFFF;
  --color-text: #222222;
  --color-text-secondary: #777777;
  --color-border: #EFE7E1;
  --color-success: #2E7D32;
  --color-error: #C62828;
  --shadow-soft: 0 4px 20px rgba(34, 34, 34, 0.06);
  --shadow-medium: 0 8px 30px rgba(34, 34, 34, 0.10);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --font-display: 'Poppins', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-display);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.admin-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 90px; }

/* ---- Top bar ---- */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 248, 242, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-topbar h1 { font-size: 16px; font-weight: 700; margin: 0; }
.admin-topbar .back-btn { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--color-text-secondary); }

/* ---- Bottom nav ---- */
.admin-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  box-shadow: 0 -4px 20px rgba(34,34,34,0.06);
}

.admin-nav a {
  flex: 1;
  text-align: center;
  padding: 10px 4px 8px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.admin-nav a.active { color: var(--color-primary); }
.admin-nav a .material-symbols-rounded { display: block; font-size: 22px; margin-bottom: 2px; }

/* ---- Cards / sections ---- */
.admin-content { padding: 16px; }

.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  margin-bottom: 14px;
}

.card h2 { font-size: 14px; margin: 0 0 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  text-align: center;
}

.stat-card .value { font-size: 22px; font-weight: 700; color: var(--color-primary); }
.stat-card .label { font-size: 11px; color: var(--color-text-secondary); margin-top: 4px; }

/* ---- Form fields ---- */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--color-text-secondary); display: block; margin-bottom: 6px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 13.5px;
  background: var(--color-bg);
  outline: none;
}

.form-textarea { resize: vertical; min-height: 70px; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--color-primary); }

.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}
.switch-row:last-child { border-bottom: none; }

.switch { position: relative; width: 44px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: var(--color-border);
  border-radius: var(--radius-pill); transition: 0.2s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: var(--shadow-soft);
}
.switch input:checked + .slider { background: var(--color-primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm); padding: 12px 18px;
  font-size: 13.5px; font-weight: 700; cursor: pointer; width: 100%;
}
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 8px 20px rgba(229,57,53,0.28); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-danger { background: #FDECEA; color: var(--color-error); }
.btn-sm { width: auto; padding: 8px 14px; font-size: 12px; }

.fab {
  position: fixed;
  bottom: 84px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  box-shadow: 0 10px 24px rgba(229,57,53,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}
.fab .material-symbols-rounded { font-size: 26px; }

/* ---- List items (menu/category rows) ---- */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: 10px;
  margin-bottom: 10px;
}
.list-item img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--color-border); }
.list-item .info { flex: 1; min-width: 0; }
.list-item .name { font-size: 13.5px; font-weight: 600; }
.list-item .meta { font-size: 11.5px; color: var(--color-text-secondary); margin-top: 2px; }
.list-item .actions { display: flex; gap: 6px; }
.icon-action {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--color-border);
  background: var(--color-bg); display: flex; align-items: center; justify-content: center;
}
.icon-action .material-symbols-rounded { font-size: 17px; }

/* ---- Modal (used for add/edit forms) ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(34,34,34,0.5); z-index: 40;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.visible { display: flex; }
.modal-box {
  background: var(--color-surface); width: 100%; max-width: 480px; max-height: 90vh;
  overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px;
}

/* ---- Misc ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.login-card { background: var(--color-surface); border-radius: var(--radius-md); box-shadow: var(--shadow-medium); padding: 30px 24px; width: 100%; max-width: 360px; }
.login-card h1 { font-size: 18px; text-align: center; margin: 0 0 4px; }
.login-card p { text-align: center; color: var(--color-text-secondary); font-size: 12.5px; margin: 0 0 22px; }
.error-banner { background: #FDECEA; color: var(--color-error); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 14px; }
.empty-hint { text-align: center; color: var(--color-text-secondary); font-size: 13px; padding: 40px 0; }
.image-picker { display: flex; align-items: center; gap: 12px; }
.image-picker img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--color-bg); border: 1px solid var(--color-border); }

/* =========================================================================
   DESKTOP LAYOUT (>= 900px)
   Mobile stays exactly as it was above — everything here only kicks in on
   wider screens, converting the bottom tab bar into a persistent left
   sidebar and giving pages room to breathe instead of a centered phone-
   width column with empty space either side.
   ========================================================================= */
@media (min-width: 900px) {
  .admin-shell {
    max-width: 1100px;
    margin: 0 0 0 232px; /* clears the sidebar's width, no auto-centering at this size */
    padding-bottom: 40px; /* no bottom nav to clear anymore */
  }

  /* ---- Sidebar (was: bottom tab bar) ---- */
  .admin-nav {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 232px;
    max-width: 232px;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    padding: 28px 12px;
    border-top: none;
    border-right: 1px solid var(--color-border);
    box-shadow: none;
    overflow-y: auto;
  }
  .admin-nav::before {
    content: '';
    display: block;
    height: 36px;
  }
  .admin-nav a {
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
  }
  .admin-nav a:hover { background: var(--color-bg); }
  .admin-nav a.active { background: #FDECEA; }
  .admin-nav a .material-symbols-rounded { margin-bottom: 0; font-size: 20px; }

  /* ---- More breathing room / more columns where it makes sense ---- */
  .admin-topbar { padding: 18px 28px; }
  .admin-content { padding: 24px 28px; }
  .card { padding: 20px 22px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }

  /* Stacked mobile lists become a responsive grid on desktop. Each of
     these IDs is only ever used as the single list container on its own
     page (menu/categories/tables/contacts), so this is safe to target
     directly without a wrapper class. */
  #menuList, #categoryList, #tableList, #contactList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
    align-content: start;
  }
  #menuList .list-item, #categoryList .list-item,
  #tableList .table-card, #contactList .contact-row {
    margin-bottom: 0;
  }
  /* Empty-state / loading messages shouldn't stretch into a grid cell. */
  #menuList .empty-hint, #categoryList .empty-hint,
  #tableList .empty-hint, #contactList .empty-hint {
    grid-column: 1 / -1;
  }

  /* ---- Modals become centered dialogs instead of bottom sheets ---- */
  .modal-overlay { align-items: center; }
  .modal-box {
    border-radius: 20px;
    max-width: 460px;
    max-height: 85vh;
  }

  /* ---- Floating action button no longer needs to clear a bottom bar ---- */
  .fab { bottom: 28px; right: 32px; }
}

