/* =============================================
   PEDIDOS PERSONALIZADOS - TIENDA
   Sabor & Aroma - Estilos CSS
   ============================================= */

:root {
    --orange: #E85D04;
    --orange-light: #FAA307;
    --orange-soft: #FFF4E6;
    --orange-glow: rgba(232, 93, 4, 0.15);
    --brown: #2D1B0E;
    --brown-light: #6B4423;
    --beige: #F5F0EB;
    --beige-dark: #E8DDD4;
    --gray: #6B7280;
    --gray-light: #E5E7EB;
    --white: #FFFFFF;
    --danger: #EF4444;
    --success: #10B981;
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
body { font-family: 'Outfit', sans-serif; background: var(--white); color: var(--brown); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
#root { min-height: 100vh; min-height: -webkit-fill-available; }
.app { min-height: 100vh; background: var(--white); }

/* Header */
.header {
    background: linear-gradient(135deg, var(--brown) 0%, #1a0f08 100%);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { width: 90px; height: 60px; border-radius: 12px; object-fit: contain; background: #ffffff00; padding: 4px; }
.header-titles { display: flex; flex-direction: column; }
.header h1 { color: var(--white); font-size: 1.1rem; font-weight: 700; line-height: 1.2; }
.header-sub { color: var(--orange-light); font-size: 0.75rem; font-weight: 500; }
.header-btn { background: rgba(255,255,255,0.1); border: none; padding: 10px; border-radius: 12px; color: var(--white); cursor: pointer; position: relative; }
.cart-badge { position: absolute; top: -4px; right: -4px; background: var(--orange); color: white; font-size: 0.7rem; font-weight: 700; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }

/* Page Header */
.page-header {
    background: var(--white);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--gray-light);
    position: sticky;
    top: 0;
    z-index: 100;
}
.page-header h1 { font-size: 1.15rem; font-weight: 700; }
.btn-back { background: none; border: none; padding: 8px; cursor: pointer; font-size: 1.2rem; }

/* Hero */
.hero {
    background: linear-gradient(135deg, var(--orange-soft) 0%, var(--beige) 100%);
    padding: 28px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 180px;
    height: 180px;
    background: var(--orange-light);
    opacity: 0.1;
    border-radius: 50%;
}
.hero h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 6px; }
.hero p { color: var(--brown-light); font-size: 0.95rem; }

/* Products Grid */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 14px; padding: 18px; }
.product-tile {
    background: var(--white);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    border: 2px solid var(--gray-light);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}
.product-tile:active { transform: scale(0.97); border-color: var(--orange); }
.product-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--orange), var(--orange-light));
    opacity: 0;
    transition: opacity 0.2s;
}
.product-tile:active::before { opacity: 1; }
.product-emoji { font-size: 2.8rem; margin-bottom: 10px; display: block; }
.product-img { width: 70px; height: 70px; object-fit: cover; border-radius: 12px; margin-bottom: 10px; }
.product-tile h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; line-height: 1.3; }
.product-tile .price { font-size: 1.15rem; font-weight: 700; color: var(--orange); }
.product-tile .size { font-size: 0.75rem; color: var(--gray); margin-top: 4px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 22px;
    border-radius: var(--radius);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform 0.15s;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--orange) 0%, #d54d00 100%); color: var(--white); box-shadow: 0 4px 15px var(--orange-glow); }
.btn-secondary { background: var(--beige); color: var(--brown); }
.btn-success { background: linear-gradient(135deg, var(--success) 0%, #059669 100%); color: var(--white); }
.btn-full { width: 100%; }
.btn-sm { padding: 10px 16px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0); display: flex; align-items: flex-end; justify-content: center; z-index: 1000; animation: fadeInBg 0.3s ease forwards; }
@keyframes fadeInBg { to { background: rgba(0,0,0,0.6); } }
.modal { background: var(--white); border-radius: 20px 20px 0 0; width: 100%; max-width: 500px; max-height: 92vh; overflow-y: auto; animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; transform: translateY(100%); }
@keyframes slideUp { to { transform: translateY(0); opacity: 1; } }

.product-modal-header {
    background: linear-gradient(135deg, var(--orange-soft) 0%, var(--beige) 100%);
    padding: 22px 20px;
    text-align: center;
    position: relative;
}
.close-btn { position: absolute; top: 14px; right: 14px; background: var(--white); border: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; }
.product-modal-header .emoji { font-size: 3rem; display: block; margin-bottom: 8px; }
.product-modal-header .modal-img { width: 80px; height: 80px; object-fit: cover; border-radius: 16px; margin-bottom: 8px; }
.product-modal-header h2 { font-size: 1.4rem; font-weight: 700; }
.product-modal-header .base-price { color: var(--orange); font-weight: 600; margin-top: 4px; }
.product-modal-body { padding: 18px; }

.option-section { margin-bottom: 22px; }
.option-section h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.option-section h4 span { color: var(--gray); font-weight: 400; font-size: 0.8rem; }
.option-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.option-btn {
    padding: 11px 16px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    background: var(--white);
    font-family: 'Outfit';
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    flex: 1 1 calc(50% - 4px);
    min-width: calc(50% - 4px);
    text-align: center;
}
.option-btn:active { border-color: var(--orange-light); }
.option-btn.selected { border-color: var(--orange); background: var(--orange-soft); color: var(--orange); font-weight: 600; }
.option-btn .extra { display: block; font-size: 0.7rem; color: var(--gray); margin-top: 2px; }
.option-btn.selected .extra { color: var(--orange); }
.option-btn.disabled { opacity: 0.4; pointer-events: none; }

.quantity-control {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--beige);
    padding: 8px;
    border-radius: var(--radius);
    width: fit-content;
}
.qty-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    touch-action: manipulation;
}
.qty-btn:active { background: var(--orange-soft); }
.qty { font-size: 1.3rem; font-weight: 700; min-width: 40px; text-align: center; }

.live-price {
    background: linear-gradient(135deg, var(--brown) 0%, #1a0f08 100%);
    color: var(--white);
    padding: 18px;
    margin: 0 -18px -18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.live-price .label { font-size: 0.85rem; opacity: 0.8; }
.live-price .total { font-size: 1.6rem; font-weight: 800; }
.live-price .btn { flex: 1; min-width: 140px; }

/* Cart */
.cart-empty { text-align: center; padding: 50px 20px; color: var(--gray); }
.cart-empty p { margin: 12px 0 20px; }
.cart-items { padding: 18px; }
.cart-item {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
}
.cart-item-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.cart-item-name { font-weight: 600; font-size: 1rem; }
.cart-item-price { font-weight: 700; color: var(--orange); font-size: 1.05rem; }
.cart-item-details { font-size: 0.8rem; color: var(--gray); line-height: 1.5; }
.cart-item-qty { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--gray-light); }
.cart-item-qty .qty-btn { width: 34px; height: 34px; font-size: 1rem; }
.cart-item-qty .qty { font-size: 1rem; min-width: 30px; }
.btn-icon { background: var(--beige); border: none; padding: 8px; border-radius: 8px; cursor: pointer; }
.btn-icon-danger:active { background: #FEE2E2; }

.cart-summary {
    background: var(--beige);
    padding: 18px;
    border-top: 2px solid var(--beige-dark);
}
.cart-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 0.95rem; }
.cart-row.total { font-size: 1.25rem; font-weight: 700; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--beige-dark); }

/* Checkout */
.checkout { padding: 18px; padding-bottom: 140px; }
.checkout-section { margin-bottom: 28px; }
.checkout-section h3 { font-size: 1rem; font-weight: 700; margin-bottom: 14px; }

.delivery-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.delivery-option {
    padding: 18px 14px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.delivery-option:active, .delivery-option.selected { border-color: var(--orange); }
.delivery-option.selected { background: var(--orange-soft); }
.delivery-option .icon { font-size: 1.8rem; margin-bottom: 6px; display: block; }
.delivery-option span { font-weight: 600; font-size: 0.9rem; }

.payment-options { display: flex; flex-direction: column; gap: 8px; }
.payment-option {
    padding: 14px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}
.payment-option:active, .payment-option.selected { border-color: var(--orange); }
.payment-option.selected { background: var(--orange-soft); }
.payment-option .icon { font-size: 1.4rem; }
.payment-option span { font-weight: 500; font-size: 0.95rem; }

.gift-toggle {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--beige);
    border-radius: var(--radius);
    cursor: pointer;
}
.gift-icon { font-size: 1.8rem; }
.gift-info { flex: 1; }
.gift-info strong { display: block; font-size: 0.95rem; margin-bottom: 2px; }
.gift-info span { font-size: 0.8rem; color: var(--gray); }
.toggle-switch {
    width: 50px;
    height: 28px;
    background: var(--gray-light);
    border-radius: 14px;
    position: relative;
    transition: background 0.2s;
}
.toggle-switch.on { background: var(--orange); }
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: var(--white);
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-switch.on::after { transform: translateX(22px); }

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.9rem; }
.field input, .field textarea {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius);
    font-family: 'Outfit';
    font-size: 16px;
    transition: border-color 0.2s;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--orange); }
.field.error input, .field.error textarea { border-color: var(--danger); }
.field .error-msg { color: var(--danger); font-size: 0.8rem; margin-top: 4px; }
.input-row { display: flex; gap: 10px; }
.input-row > * { flex: 1; }

.checkout-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 14px 18px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--gray-light);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}
.checkout-total { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.checkout-total span { font-size: 0.85rem; color: var(--gray); }
.checkout-total strong { font-size: 1.4rem; font-weight: 800; color: var(--orange); }

/* Success */
.success-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--orange-soft) 0%, var(--white) 100%);
}
.success-icon {
    width: 80px;
    height: 80px;
    background: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 24px;
    animation: pop 0.5s ease;
}
@keyframes pop { 0% { transform: scale(0); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
.success-screen h2 { font-size: 1.6rem; margin-bottom: 14px; }
.success-screen > p { color: var(--gray); line-height: 1.7; margin-bottom: 20px; max-width: 300px; }
.success-note {
    background: var(--beige);
    padding: 18px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    line-height: 1.8;
    text-align: left;
    max-width: 320px;
    margin-bottom: 24px;
}

/* Loading & Error */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; color: var(--gray); }
.spinner { width: 40px; height: 40px; border: 3px solid var(--gray-light); border-top-color: var(--orange); border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
    background: #FEF2F2;
    border: 1px solid #FECACA;
    color: var(--danger);
    padding: 12px 16px;
    margin: 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}
.error-banner button {
    margin-left: auto;
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
}

/* Selector de Fecha y Hora */
.checkout-section select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-light);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}
.checkout-section select:focus {
    outline: none;
    border-color: var(--orange);
}
.checkout-section select:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.fecha-hora-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .fecha-hora-row {
        grid-template-columns: 1fr;
    }
}

.fecha-confirmada {
    margin-top: 14px;
    padding: 12px 16px;
    background: #ECFDF5;
    border: 1px solid #86EFAC;
    border-radius: var(--radius-sm);
    color: #166534;
    font-weight: 500;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 380px) {
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 14px; }
    .product-tile { padding: 14px 10px; }
    .product-emoji { font-size: 2.2rem; }
    .product-tile h3 { font-size: 0.85rem; }
    .option-btn { padding: 10px 12px; font-size: 0.8rem; }
    .delivery-options { grid-template-columns: 1fr; }
    .input-row { flex-direction: column; }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .checkout-footer, .live-price { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
}