/**
 * Customer Portal Layout — LAYOUT ONLY
 *
 * This file contains ONLY layout-specific rules for the customer portal PWA.
 * All component styling is in components/customer-portal.css.
 *
 * Rules (from CSS-ARCHITECTURE.md):
 * - No component definitions (use .btn, .card, .input from site.css)
 * - No hex codes (use semantic tokens)
 * - No typography changes (inherit from base.css)
 * - Only layout: grids, spacing, positioning, PWA-specific structure
 */


/* ===========================================
   PAGE STRUCTURE
   Nav + Content + Footer (hidden in standalone PWA)
   =========================================== */

.portal-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface-0);
}

.portal-page__nav {
  flex-shrink: 0;
  /* Spacer for fixed CorporateNav: padding (24px) + logo (48px) + padding (24px) = 96px */
  min-height: 96px;
}

@media (max-width: 639px) {
  .portal-page__nav {
    /* Mobile: 24px + 40px logo + 24px = 88px */
    min-height: 88px;
  }
}

.portal-page__content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.portal-page__footer {
  flex-shrink: 0;
}

/* Standalone PWA mode: hide nav and footer for app-like experience */
@media (display-mode: standalone) {
  .portal-page__nav,
  .portal-page__footer {
    display: none;
    min-height: 0;
  }

  .portal-page {
    padding-top: env(safe-area-inset-top);
  }
}


/* ===========================================
   AUTH SCREEN LAYOUT
   Centered card with nav/footer grounding
   =========================================== */

.auth-layout {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-6);
  background: linear-gradient(
    180deg,
    var(--surface-1) 0%,
    var(--surface-0) 100%
  );
  animation: auth-fade-in 0.3s ease-out;
}

/* Desktop: more generous whitespace */
@media (min-width: 768px) {
  .auth-layout {
    padding: var(--space-16) var(--space-8);
  }
}

@keyframes auth-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Standalone PWA: full-height centered, no nav padding */
@media (display-mode: standalone) {
  .auth-layout {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: var(--space-8); /* No nav in standalone */
  }
}


/* ===========================================
   PORTAL PAGE SHELL
   =========================================== */

.portal-layout {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface-1);
  padding-top: env(safe-area-inset-top);
}

/* Mobile: Hide portal-header (CorporateNav provides branding) */
@media (max-width: 1023px) {
  .portal-header {
    display: none;
  }
}

/* Mobile: Hide reminder section (Remind button in bottom nav) */
@media (max-width: 1023px) {
  .reminder-section {
    display: none;
  }
}

/* Standalone PWA mode */
@media (display-mode: standalone) {
  .portal-layout {
    padding-top: env(safe-area-inset-top);
  }
}

.portal-container {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface-0);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Desktop: floating card with shadow */
@media (min-width: 768px) {
  .portal-layout {
    padding: var(--space-8);
    display: flex;
    align-items: flex-start;
    justify-content: center;
  }

  .portal-container {
    min-height: auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
  }
}


/* ===========================================
   PORTAL MAIN CONTENT
   =========================================== */

.portal-main {
  flex: 1;
  padding: var(--space-6);
  padding-bottom: calc(var(--space-6) + 80px); /* Space for bottom nav */
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .portal-main {
    padding-bottom: var(--space-6);
  }
}


/* ===========================================
   BOTTOM NAVIGATION LAYOUT
   =========================================== */

.portal-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-0);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  padding: var(--space-2) 0;
  padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
  z-index: 100;
}

/* Desktop: static nav at bottom of card */
@media (min-width: 768px) {
  .portal-nav {
    position: static;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 0;
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-3) var(--space-6);
    justify-content: center;
    gap: var(--space-8);
  }
}


/* ===========================================
   WHATSAPP FAB POSITIONING
   =========================================== */

.portal-fab {
  position: fixed;
  bottom: 88px; /* Above nav */
  right: var(--space-4);
  z-index: 99;
}

@media (min-width: 768px) {
  .portal-fab {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
  }
}


/* ===========================================
   MODAL OVERLAY LAYOUT
   =========================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.modal-overlay .modal {
  transform: translateY(100%);
  transition: transform var(--transition-base);
}

.modal-overlay.is-visible .modal {
  transform: translateY(0);
}

/* Desktop: center modal */
@media (min-width: 768px) {
  .modal-overlay {
    align-items: center;
    padding: var(--space-6);
  }

  .modal-overlay .modal {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
  }

  .modal-overlay.is-visible .modal {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}


/* ===========================================
   TOAST POSITIONING
   =========================================== */

.toast-container {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast-container .toast {
  pointer-events: auto;
  animation: toast-in var(--transition-base) ease-out;
}

@keyframes toast-in {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}


/* ===========================================
   LOADING STATE LAYOUT
   =========================================== */

.portal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface-0);
  gap: var(--space-4);
  animation: loading-fade-in 0.2s ease-out;
}

@keyframes loading-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.portal-loading__text {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}


/* ===========================================
   SECTION SPACING WITHIN PORTAL
   =========================================== */

.portal-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

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

.portal-section__title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}


/* ===========================================
   BOOKING ACTIONS LAYOUT
   =========================================== */

.booking-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (min-width: 480px) {
  .booking-actions {
    flex-direction: row;
  }

  .booking-actions .btn {
    flex: 1;
  }
}


/* ===========================================
   QUICK ACTIONS GRID
   =========================================== */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (min-width: 480px) {
  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  border: none;
  cursor: pointer;
}

.quick-action:hover {
  background: var(--color-brand-primary-alpha-5);
  color: var(--color-brand-primary);
}

.quick-action svg {
  width: 24px;
  height: 24px;
}

.quick-action span {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  text-align: center;
}


/* ===========================================
   DESKTOP TWO-COLUMN LAYOUT
   Main content + sidebar at 1024px+
   =========================================== */

/* Sidebar - hidden by default, shown on desktop */
.portal-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  .portal-layout {
    padding: var(--space-8) var(--space-6);
    background: var(--surface-1);
  }

  .portal-container {
    max-width: 1120px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-8);
    background: transparent;
    box-shadow: none;
    min-height: auto;
    border-radius: 0;
  }

  .portal-header {
    display: none;
  }

  .portal-status {
    display: none;
  }

  .portal-main {
    background: var(--surface-0);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    padding-bottom: var(--space-8);
  }

  .portal-welcome {
    display: flex;
  }

  .portal-sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
  }

  .portal-nav {
    display: none;
  }

  .portal-fab {
    display: none;
  }
}

/* ===========================================
   SIDEBAR COMPONENTS
   =========================================== */

.sidebar-card {
  background: var(--surface-0);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.sidebar-card__title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-4);
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.action-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--surface-1);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  text-align: left;
}

.action-item:hover {
  background: var(--color-brand-primary-alpha-5);
  color: var(--color-brand-primary);
}

.action-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.action-item--whatsapp:hover {
  background: rgba(37, 211, 102, 0.1);
  color: #25d366;
}


/* ===========================================
   DESKTOP WELCOME SECTION
   Shown inside main card on desktop only
   =========================================== */

.portal-welcome {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-6);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.portal-welcome__info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.portal-welcome__customer-name {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.portal-welcome__franchise {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.portal-welcome__badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.portal-welcome__member {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}
