/* =============================================
   SUPER PISOS PANAMÁ – Cart Styles
   ============================================= */
@import 'variables.css';

/* ── NAV ICONS ──────────────────────────────── */
.nav-icons {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: var(--space-3);
}

.nav-icon-btn {
    position: relative;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    cursor: pointer;
    font-size: 1.15rem;
    text-decoration: none;
    transition: all var(--transition-fast);
    backdrop-filter: blur(4px);
}

.nav-icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--color-white);
}

.navbar.scrolled .nav-icon-btn {
    color: var(--color-secondary);
    background: var(--color-accent);
}

.navbar.scrolled .nav-icon-btn:hover {
    background: var(--color-primary);
    color: var(--color-white);
}

/* ── CART BADGE ──────────────────────────────── */
.cart-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--color-primary);
    color: white;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform var(--transition-bounce);
}

.cart-badge--hidden {
    transform: scale(0);
}

/* ── CART TOAST ─────────────────────────────── */
#cartToast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-secondary);
    color: white;
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition-base);
    white-space: nowrap;
}

#cartToast.cart-toast--show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── CART DRAWER ─────────────────────────────── */
.cart-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.50);
    z-index: 800;
    opacity: 0;
    transition: opacity var(--transition-base);
    backdrop-filter: blur(2px);
}

.cart-drawer-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 420px;
    max-width: 100vw;
    background: var(--color-white);
    z-index: 801;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    transform: translateX(100%);
    transition: transform var(--transition-slow);
}

#cartDrawer:not(.cart-drawer--open) .cart-drawer-backdrop {
    pointer-events: none;
}

#cartDrawer.cart-drawer--open .cart-drawer-backdrop {
    opacity: 1;
}

#cartDrawer.cart-drawer--open .cart-drawer-panel {
    transform: translateX(0);
}

.cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    background: var(--gradient-blue);
    color: white;
}

.cart-drawer-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: white;
}

.cart-drawer-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background var(--transition-fast);
}

.cart-drawer-close:hover {
    background: rgba(255, 255, 255, 0.30);
}

.cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-5);
}

.cart-drawer-footer {
    border-top: 1px solid var(--color-border);
    padding: var(--space-5) var(--space-6);
    background: var(--color-accent);
}

/* Product detail modal (integrates with existing site CSS) */
#productDetailModal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#productDetailModal.active {
  display: flex;
}
#productDetailModal .pc-overlay {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
}
#productDetailModal .pc-content {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: min(1000px, 92vw);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 16px;
}
#productDetailModal .pc-close {
  position: absolute; top: 8px; right: 12px;
  background: #fff; border: 1px solid #ccc; border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
}
#productDetailModal .pc-image img {
  width: 100%; height: auto; border-radius: 6px;
}
@media (max-width: 800px) {
  #productDetailModal .pc-content { grid-template-columns: 1fr; }
}
.pc-detail-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pc-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #f0f0f0; font-size: 12px; }

/* Make compact the catalog's Add to Cart button and stack buttons vertically */
.product-card-footer.product-controls { display: flex; flex-direction: column; gap: 8px; width: 100%; }

/* Keep price and unit inline even inside product-controls */
.product-card-footer.product-controls .product-card-price {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    gap: 3px;
}

/* Ensure inner divs in catalog.js use spans for proper inline display */
.product-card-price span.amount,
.product-card-price span.unit {
    display: inline;
}

/* Add to Cart button: compact, full width, orange styling on border/text, transparent bg */
.add-to-cart-btn {
  width: 100%;
  display: block;
  min-height: 40px;
  font-size: 13px;
  border-radius: 6px;            /* same radius vibe as Cotizar */
  border: 2px solid #f5821f;     /* orange border */
  color: #f5821f;                /* orange text */
  background: transparent;
}

/* Cotizar button full width in layout */
.cotizar-btn {
  width: 100%;
  display: block;
  margin-left: 0; /* ensure full width without left offset */
}

/* Utility to hide elements when needed (used for WhatsApp FAB) */
.hidden { display: none !important; }

/* ── CART EMPTY ─────────────────────────────── */
.cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    padding: var(--space-16) var(--space-8);
    text-align: center;
}

.cart-empty-icon {
    font-size: 4rem;
    opacity: 0.4;
}

.cart-empty p {
    color: var(--color-text-muted);
    font-size: var(--font-size-md);
}

/* ── CART ITEM ──────────────────────────────── */
.cart-item {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    gap: var(--space-3);
    align-items: start;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--color-border);
}

.cart-item:last-child { border-bottom: none; }

.cart-item-img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.cart-item-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin-bottom: var(--space-1);
    line-height: 1.3;
}

.cart-item-cat {
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    text-transform: uppercase;
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.04em;
    margin-bottom: var(--space-2);
}

.cart-item-price {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-secondary);
}

.cart-item-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
}

.cart-qty-btn {
    width: 28px;
    height: 28px;
    background: var(--color-accent);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-secondary);
    transition: all var(--transition-fast);
}

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

.cart-qty-num {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    min-width: 24px;
    text-align: center;
}

.cart-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    padding: 2px;
}

.cart-remove-btn:hover { opacity: 1; }

/* ── CART SUMMARY ───────────────────────────── */
.cart-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}

.cart-summary-total {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    border-top: 2px solid var(--color-border);
    padding-top: var(--space-3);
    margin-top: var(--space-2);
    margin-bottom: 0;
}

/* ── CART PAGE ──────────────────────────────── */
.cart-page-hero {
    background: var(--gradient-blue);
    padding: 120px 0 48px;
    color: white;
    text-align: center;
}

.cart-page-hero h1 { color: white; margin-bottom: var(--space-2); }
.cart-page-hero p  { color: rgba(255,255,255,0.8); }

.cart-page-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--space-8);
    align-items: start;
    padding: var(--space-12) 0;
}

@media (max-width: 900px) {
    .cart-page-layout { grid-template-columns: 1fr; }
}

.cart-table {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.cart-table-header {
    display: grid;
    grid-template-columns: 80px 1fr 140px 100px 48px;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: var(--color-accent);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.cart-table-row {
    display: grid;
    grid-template-columns: 80px 1fr 140px 100px 48px;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition-fast);
}

.cart-table-row:last-child { border-bottom: none; }
.cart-table-row:hover { background: var(--color-accent); }

.cart-table-img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.cart-table-name {
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    font-size: var(--font-size-sm);
}

.cart-table-sub {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

.cart-qty-input {
    width: 80px;
    padding: var(--space-2) var(--space-3);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    text-align: center;
    font-family: inherit;
    color: var(--color-text);
}

.cart-qty-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(255,127,0,0.12);
}

.cart-line-total {
    font-weight: var(--font-weight-bold);
    color: var(--color-secondary);
}

.cart-clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.cart-clear-btn:hover { opacity: 1; color: var(--color-error); }

/* ── ORDER SUMMARY CARD ─────────────────────── */
.order-summary-card {
    background: var(--color-white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    padding: var(--space-6);
    position: sticky;
    top: 100px;
}

.order-summary-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}

.order-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    padding: var(--space-2) 0;
}

.order-summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-black);
    color: var(--color-text);
    border-top: 2px solid var(--color-border);
    padding-top: var(--space-4);
    margin-top: var(--space-2);
}

.order-summary-total span:last-child { color: var(--color-primary); }

@media (max-width: 680px) {
    .cart-table-header,
    .cart-table-row {
        grid-template-columns: 60px 1fr 80px;
    }

    .cart-table-header > *:nth-child(4),
    .cart-table-header > *:nth-child(5),
    .cart-table-row > *:nth-child(4),
    .cart-table-row > *:nth-child(5) {
        display: none;
    }
}

@media (max-width: 767px) {
  .cart-drawer-panel {
    width: 100vw;
    left: 0;
    right: auto;
    height: 100dvh;
    z-index: 9999;
    transform: translateX(100%);
  }

  #cartDrawer.cart-drawer--open .cart-drawer-panel {
    transform: translateX(0);
  }

  .cart-drawer-backdrop {
    z-index: 9998;
    backdrop-filter: none;
  }

  .cart-drawer-close { height: 44px; width: 44px; }
}
