/* ── Hub Customer Portal — Premium grocery-app aesthetic ── */

body.hub-customer {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 72, 58, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(245, 197, 24, 0.08) 0%, transparent 50%),
    linear-gradient(180deg, #f0f5f2 0%, #f8faf9 40%, #faf8f0 100%);
  min-height: 100dvh;
}

body.hub-customer.store-picker-mode {
  overflow: hidden;
  background: #e8f0ec;
}

/* ── Boot loader ── */
.hub-boot-loader {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background:
    radial-gradient(circle at 50% 40%, rgba(0, 72, 58, 0.12) 0%, transparent 55%),
    linear-gradient(180deg, #f0f5f2 0%, #faf8f0 100%);
}

.hub-boot-loader.hidden { display: none !important; }

.hub-boot-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hub-boot-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 72, 58, 0.3);
  animation: hubLogoPulse 2s ease-in-out infinite;
}

.hub-boot-logo svg {
  width: 40px;
  height: 40px;
  fill: var(--primary);
}

@keyframes hubLogoPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 32px rgba(0, 72, 58, 0.3); }
  50% { transform: scale(1.04); box-shadow: 0 12px 40px rgba(0, 72, 58, 0.4); }
}

.hub-boot-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.03em;
}

.hub-boot-tagline {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

.hub-boot-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 72, 58, 0.12);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: hubSpin 0.75s linear infinite;
}

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

.hub-boot-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

/* ── App shell ── */
.hub-app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hub-app-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff;
  padding: 16px 18px 20px;
  border-radius: 0 0 24px 24px;
  box-shadow: 0 6px 28px rgba(0, 72, 58, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.hub-app-header::before {
  content: "";
  position: absolute;
  top: -40%;
  left: -20%;
  width: 60%;
  height: 120%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hub-app-header::after {
  content: "";
  position: absolute;
  bottom: -30%;
  right: -10%;
  width: 50%;
  height: 80%;
  background: radial-gradient(circle, rgba(245, 197, 24, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.hub-brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.hub-brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.hub-brand-icon svg {
  width: 24px;
  height: 24px;
  fill: var(--primary);
}

.hub-brand-text h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hub-brand-text p {
  margin: 2px 0 0;
  font-size: 0.75rem;
  opacity: 0.85;
  font-weight: 500;
}

.hub-header-actions {
  position: relative;
  z-index: 1;
}

.hub-header-actions button {
  min-height: 38px;
  padding-inline: 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(8px);
  transition: background var(--transition-fast);
}

.hub-header-actions button:hover {
  background: rgba(255, 255, 255, 0.25);
}

.hub-app-body {
  flex: 1;
  padding: 16px 14px 24px;
}

/* ── Auth card ── */
.hub-auth-card {
  background: var(--card);
  border-radius: 20px;
  padding: 28px 22px 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative;
  overflow: hidden;
}

.hub-auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--primary) 50%, var(--brand-light) 100%);
}

.hub-auth-hero {
  text-align: center;
  margin-bottom: 24px;
}

.hub-auth-hero-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hub-auth-hero-icon svg {
  width: 28px;
  height: 28px;
  fill: var(--brand);
}

.hub-auth-card h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brand);
  text-align: center;
  border: none;
  padding: 0;
}

.hub-auth-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.hub-login-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.hub-login-actions button {
  width: 100%;
  min-height: 52px;
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-input);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hub-login-actions button:active:not(:disabled) {
  transform: scale(0.98);
}

.hub-btn-register {
  background: #fff !important;
  color: var(--brand) !important;
  border: 2px solid var(--brand) !important;
}

.hub-btn-register:hover {
  background: var(--brand-soft) !important;
}

.hub-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.hub-divider::before,
.hub-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Register ── */
.hub-register-phone-block {
  text-align: center;
  margin-bottom: 18px;
}

.hub-register-phone-block label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 8px;
}

.hub-register-phone-input {
  width: 100%;
  min-height: 62px;
  padding: 14px 18px;
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  direction: ltr;
  border: 2px solid var(--border);
  border-radius: var(--radius-input);
  background: var(--input-bg);
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.hub-register-phone-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft);
  background: #fff;
}

.hub-map-section {
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.hub-map-section h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hub-map-section h3 svg {
  width: 18px;
  height: 18px;
  fill: var(--primary-dark);
}

.hub-map-frame {
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--border);
}

#registerMap,
#customerMap {
  width: 100%;
  border-radius: var(--radius-card);
}

#registerMap {
  height: min(48vh, 380px);
}

#customerMap {
  height: min(62vh, 560px);
}

.hub-register-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.hub-register-actions button {
  flex: 1 1 140px;
  min-height: 50px;
  font-weight: 700;
  border-radius: var(--radius-input);
}

/* ── Map picker (fullscreen app mode) ── */
.hub-map-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #e8f0ec;
}

.hub-map-view.hidden { display: none !important; }

.hub-map-topbar {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  min-height: 44px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 12px rgba(0, 72, 58, 0.2);
  z-index: 10;
}

.hub-map-topbar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  justify-self: start;
}

.hub-map-topbar-mobile {
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  opacity: 0.95;
  justify-self: center;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hub-map-topbar .hub-header-actions {
  justify-self: end;
}

.hub-map-topbar .hub-header-actions button,
.hub-map-topbar .hub-header-actions button.secondary {
  min-height: 32px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.hub-map-topbar .hub-header-actions button:hover {
  background: rgba(255, 255, 255, 0.25);
}

@media (max-width: 480px) {
  .hub-map-topbar {
    padding: 6px 12px;
    padding-top: calc(6px + env(safe-area-inset-top, 0px));
    min-height: 38px;
  }

  .hub-map-topbar-title {
    font-size: 0.9rem;
  }

  .hub-map-topbar-mobile {
    font-size: 0.8125rem;
    max-width: 38vw;
  }

  .hub-map-topbar .hub-header-actions button {
    min-height: 28px;
    padding: 3px 10px;
    font-size: 0.7rem;
  }
}

.hub-map-canvas-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
}

.hub-map-canvas-wrap #customerMap {
  position: absolute;
  inset: 0;
  height: 100% !important;
  border-radius: 0;
}

.hub-map-float-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  z-index: 20;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 32px rgba(0, 40, 32, 0.14);
  border-top: 1px solid rgba(255, 255, 255, 0.8);
}

.hub-map-float-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.hub-store-selected-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 800;
  color: var(--brand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.hub-btn-enter-store {
  flex-shrink: 0;
  width: auto;
  min-height: 44px;
  min-width: 96px;
  padding: 8px 16px;
  font-size: 0.9375rem;
  font-weight: 800;
  border-radius: var(--radius-input);
  letter-spacing: 0;
  white-space: nowrap;
}

.hub-btn-enter-store:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.hub-map-msg {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  min-height: 0;
  line-height: 1.4;
}

.hub-map-msg:empty { display: none; }

@media (max-width: 480px) {
  .hub-map-float-panel {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .hub-map-float-row {
    gap: 8px;
    min-height: 40px;
  }

  .hub-store-selected-name {
    font-size: 0.875rem;
  }

  .hub-btn-enter-store {
    min-height: 40px;
    min-width: 84px;
    padding: 6px 12px;
    font-size: 0.8125rem;
  }
}

/* ── Store picker markers ── */
.store-picker-marker {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-family: var(--font-ar);
}

.store-picker-marker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  text-align: center;
  background: linear-gradient(165deg, #ffffff 0%, #f0fdf4 55%, #ecfdf5 100%);
  border: 2px solid var(--brand);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 72, 58, 0.18);
  min-width: 84px;
  max-width: 132px;
  padding: 5px 8px 4px;
  line-height: 1;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: var(--font-ar);
}

.store-picker-marker:hover .store-picker-marker-card {
  transform: translateY(-2px);
}

.store-picker-marker-type {
  color: var(--brand-light);
  font-family: var(--font-ar);
  font-size: 0.625rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  margin: 0 0 1px;
}

.store-picker-marker-name {
  color: var(--brand);
  font-family: var(--font-ar);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
  word-break: break-word;
}

.store-picker-marker-pointer {
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 10px solid var(--brand);
  filter: drop-shadow(0 2px 2px rgba(0, 40, 32, 0.1));
}

.store-picker-marker-active .store-picker-marker-card {
  border-color: var(--primary-dark);
  background: linear-gradient(165deg, #fffbeb 0%, #fef9c3 50%, #fde68a 100%);
  box-shadow: 0 10px 32px rgba(245, 197, 24, 0.35);
  transform: translateY(-3px) scale(1.05);
}

.store-picker-marker-active .store-picker-marker-type {
  color: var(--primary-dark);
}

.store-picker-marker-active .store-picker-marker-pointer {
  border-top-color: var(--primary-dark);
}

.hub-delivery-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  border: 3px solid #fff;
  box-shadow: 0 3px 12px rgba(0, 72, 58, 0.4);
}

@media (min-width: 520px) {
  .hub-map-view {
    position: relative;
    inset: auto;
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    min-height: 70vh;
  }

  .hub-map-float-panel {
    max-width: 420px;
    right: 16px;
    left: auto;
    bottom: 16px;
    border-radius: var(--radius-card);
  }
}
