/* =========================================================
   Abu Khaled Sweets — Account Page
   Rebuilt to share the same design system as the rest of the
   storefront (base.css tokens): warm bakery palette, soft
   cream hero banners, gold accents, refined card elevation.
   ========================================================= */

:root {
  --primary: var(--brand, #b05024);
  --primary-strong: var(--brand-strong, #833a17);
  --primary-gradient: linear-gradient(135deg, var(--brand, #b05024), var(--brand-strong, #833a17));
  --secondary: var(--accent, #bf2f42);
}

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  background: radial-gradient(circle at 85% -10%, #fff2dc 0, var(--bg, #f6f1eb) 36%, #f3ece4 100%);
  font-family: "Cairo", "Segoe UI", Tahoma, sans-serif;
  color: var(--text, #2a1f18);
  margin: 0;
}

/* ---------- Hero (matches the soft cream banner used on
   about / offers / cart / checkout for a unified identity) ---------- */
.hero {
  background: linear-gradient(145deg, #fff4e6, #f5e5d4 56%, #f0e5d8);
  border-bottom: 1px solid var(--line, #eadfce);
  padding: 38px 20px 34px;
  text-align: center;
}
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  color: var(--primary-strong);
  letter-spacing: 0.01em;
}
.hero p {
  margin: 10px auto 0;
  max-width: 480px;
  color: var(--muted, #7a695b);
  font-size: 15px;
}

/* ---------- Layout ---------- */
.page-wrap { max-width: 1180px; margin: 0 auto; padding: 30px 20px 60px; }
.layout { display: flex; flex-wrap: wrap; gap: 26px; align-items: flex-start; }

.card {
  background: var(--surface, #fffdfb);
  border: 1px solid var(--line, #eadfce);
  border-radius: var(--radius-lg, 18px);
  box-shadow: var(--shadow-sm, 0 4px 12px rgba(74, 41, 21, 0.08));
}

/* ---------- Sidebar ---------- */
.sidebar {
  flex: 1 1 300px;
  position: sticky;
  top: 26px;
  text-align: center;
  padding: 30px 24px;
}

.user-box { margin-bottom: 26px; }

.avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--primary-gradient);
  padding: 3px;
  box-shadow: var(--shadow-md, 0 10px 22px rgba(77, 46, 24, 0.16));
  position: relative;
}
.avatar img,
.avatar .avatar-letter {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface, #fff);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
}
.avatar img[hidden], .avatar .avatar-letter[hidden] { display: none !important; }

.user-box h3 { margin: 0; font-size: 1.25rem; color: var(--text); font-weight: 800; }
.user-box p { color: var(--muted); font-size: 0.9rem; margin-top: 4px; font-weight: 500; }

/* ---------- Tab navigation ---------- */
.tab-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 22px;
  padding: 8px;
  background: var(--surface-soft, #f9efe3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 12px);
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 13px 18px;
  border-radius: 10px;
  cursor: pointer;
  text-align: right;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.tab-btn:hover { background: var(--surface); color: var(--primary-strong); }
.tab-btn.active {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ---------- Buttons (aligned with global .btn system) ---------- */
.logout-btn {
  width: 100%;
  background: #fbeceb;
  color: var(--danger, #bf2f42);
  border: none;
  padding: 14px;
  border-radius: var(--radius-md, 12px);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.logout-btn:hover { background: var(--danger, #bf2f42); color: #fff; box-shadow: var(--shadow-md); }

.primary-btn {
  background: var(--primary-gradient);
  color: #fff;
  border: none;
  padding: 13px 24px;
  border-radius: var(--radius-md, 12px);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.outline-btn {
  background: var(--surface);
  color: var(--primary-strong);
  border: 1.5px solid var(--gold, #d6b07a);
  padding: 11px 22px;
  border-radius: var(--radius-md, 12px);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.outline-btn:hover { background: var(--surface-soft); border-color: var(--primary); }
.outline-btn.danger { color: var(--danger, #bf2f42); border-color: rgba(191, 47, 66, 0.35); }
.outline-btn.danger:hover { border-color: var(--danger, #bf2f42); background: #fbeceb; }

/* ---------- Content area ---------- */
.content-area { flex: 1 1 640px; min-width: 0; }

.tab-panel { display: none; animation: acctFadeUp 0.4s ease forwards; }
.tab-panel.active { display: block; }
@keyframes acctFadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.content-area > .card { padding: 28px 30px; margin-bottom: 0; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.panel-head h2 { margin: 0; color: var(--primary-strong); font-size: 1.4rem; font-weight: 800; }

/* ---------- Profile form ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 6px; }
.form-grid label { display: block; margin-bottom: 8px; color: var(--muted); font-weight: 700; font-size: 0.9rem; }

.form-grid input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md, 12px);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface-soft);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-sizing: border-box;
  font-weight: 500;
  color: var(--text);
}
.form-grid input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px rgba(176, 80, 36, 0.12); outline: none; }
.form-grid input:disabled { background: var(--surface-soft); color: var(--muted); cursor: not-allowed; }

.actions { display: flex; gap: 12px; margin-top: 22px; }

/* ---------- Avatar upload ---------- */
.upload-group {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--surface-soft);
  padding: 18px;
  border-radius: var(--radius-md, 12px);
  border: 1.5px dashed var(--gold, #d6b07a);
  transition: border-color 0.2s ease;
}
.upload-group:hover { border-color: var(--primary); }
.upload-text { flex: 1; }
.upload-text label { color: var(--primary-strong); margin-bottom: 4px; font-size: 1rem; }
.upload-text p { font-size: 0.85rem; color: var(--muted); margin: 0; }
#uploadStatus { font-size: 0.82rem; color: var(--success, #4a9166); display: block; margin-top: 6px; font-weight: 700; }
#imageInput { display: none; }
.upload-btn { cursor: pointer; display: inline-flex; border-radius: 30px; padding: 11px 22px; white-space: nowrap; }
.upload-group[hidden] { display: none !important; }

/* ---------- Loading / empty states ---------- */
.acct-loading, .acct-empty, .acct-error {
  text-align: center;
  padding: 46px 16px;
  color: var(--muted);
  font-weight: 600;
}
.acct-empty .icon, .acct-loading .icon { font-size: 34px; display: block; margin-bottom: 10px; }
.acct-error { color: var(--danger, #bf2f42); }

/* ---------- Orders ---------- */
.order-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 12px);
  padding: 20px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.order-card:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: var(--shadow-md); }

.order-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.order-info strong { font-size: 1.05rem; color: var(--primary-strong); display: block; margin-bottom: 4px; }
.order-meta { color: var(--muted); font-size: 0.85rem; font-weight: 500; }

.order-price-status { text-align: left; flex-shrink: 0; }

.status {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}
.status.completed, .status.delivered { background: #e2f3e8; color: var(--success, #4a9166); }
.status.pending, .status.processing, .status.confirmed { background: #fbeed9; color: var(--warning, #c9852f); }
.status.cancelled { background: #fbeced; color: var(--danger, #bf2f42); }

.order-total { margin-top: 8px; font-size: 1.05rem; font-weight: 800; color: var(--primary-strong); }

.order-items-preview { display: flex; gap: 12px; align-items: center; }
.order-images { display: flex; }
.order-images img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 9px;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  margin-inline-start: -12px;
  background: var(--surface-soft);
}
.order-images img:first-child { margin-inline-start: 0; }
.order-items-names {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Addresses ---------- */
.address-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--primary);
  border-radius: var(--radius-md, 12px);
  padding: 20px;
  margin-bottom: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.address-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.address-card .panel-head { border: none; padding: 0; margin-bottom: 12px; }
.address-card .panel-head strong { font-size: 1.05rem; color: var(--primary-strong); }
.address-details p { margin: 6px 0; color: var(--muted); font-size: 0.95rem; }
.address-details strong { color: var(--text); }
.coords {
  font-size: 0.82rem !important;
  color: var(--success, #4a9166) !important;
  font-family: monospace;
  background: #eef7f1;
  padding: 4px 10px;
  border-radius: 8px;
  display: inline-block;
}
.address-actions { margin-top: 16px; display: flex; gap: 10px; }

/* ---------- Favorites ---------- */
.favorites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }

.fav-card {
  background: var(--surface);
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  border: 1px solid var(--line);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.fav-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-md); border-color: var(--gold); }
.fav-card img { width: 100%; height: 140px; object-fit: cover; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.fav-box { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; text-align: center; }
.fav-box h4 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
  font-weight: 700;
  height: 2.5em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.fav-price { color: var(--secondary); font-weight: 800; font-size: 1.05rem; }
.fav-price small { font-weight: 600; font-size: 0.75rem; color: var(--muted); }

/* ---------- Address map modal (kept, retinted to the brand palette) ---------- */
.map-control-search {
  margin-top: 10px; margin-left: 10px; border: 1px solid transparent; border-radius: 12px;
  box-sizing: border-box; box-shadow: var(--shadow-sm); font-size: 15px; height: 45px; outline: none;
  padding: 0 15px; width: 250px; background-color: #fff; font-family: inherit; z-index: 1000;
}
.map-control-btn {
  background-color: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm);
  cursor: pointer; margin-bottom: 25px; text-align: center; padding: 10px 18px; font-weight: 800;
  color: var(--primary-strong); font-family: inherit; margin-right: 10px; z-index: 1000; transition: 0.2s;
}
.map-control-btn:hover { background: var(--surface-soft); transform: scale(1.03); }
@media (max-width: 600px) { .map-control-search { width: 180px; font-size: 13px; } }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(42, 31, 24, 0.55); z-index: 9999;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px);
}
.modal-overlay[hidden] { display: none !important; }
.pac-container { z-index: 10000 !important; border-radius: 12px; margin-top: 5px; box-shadow: var(--shadow-md); border: 1px solid var(--line); font-family: inherit; }

/* 📱 Responsive */
@media (max-width: 900px) {
  .page-wrap { padding: 20px 15px 44px; }
  .layout { flex-direction: column; gap: 18px; }
  .sidebar, .content-area { flex: 1 1 100%; width: 100%; }
  .sidebar { position: static; padding: 24px 18px; }
  .content-area > .card { padding: 22px 18px; }
  .hero { padding: 30px 18px 26px; }

  .tab-nav {
    flex-direction: row;
    overflow-x: auto;
    padding: 8px;
    gap: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 10px 18px;
    text-align: center;
    font-size: 0.9rem;
    border-radius: 30px;
  }

  .form-grid { grid-template-columns: 1fr; gap: 16px; }
  .panel-head { flex-direction: column; gap: 12px; text-align: center; align-items: stretch; }
  .panel-head h2 { text-align: center; }
  .actions { flex-direction: column; }
  .actions button { width: 100%; }
  .upload-group { flex-direction: column; text-align: center; }

  .order-head { flex-direction: column; gap: 12px; }
  .order-price-status { text-align: right; display: flex; justify-content: space-between; align-items: center; }
  .order-total { margin-top: 0; }
  .order-items-preview { flex-direction: column; align-items: stretch; text-align: right; }

  .favorites-grid { grid-template-columns: repeat(2, 1fr); }
}
