/* SelectO - Mobile-First PWA Styles */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --primary: #FF6B35;
    --primary-dark: #E55A2B;
    --secondary: #1A1A2E;
    --accent: #16213E;
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);

    --header-height: 64px;
    --bottom-safe: env(safe-area-inset-bottom, 0px);
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Screens
   ============================================ */
.screen {
    display: none;
    flex-direction: column;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* ============================================
   Loading Screen
   ============================================ */
#loading-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
}

.loading-content {
    text-align: center;
}

.loading-content .logo {
    width: 200px;
    margin-bottom: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ============================================
   Error Screen
   ============================================ */
#error-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
}

.error-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--error);
    color: var(--white);
    font-size: 3rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

/* ============================================
   Header
   ============================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    height: var(--header-height);
}

.header.simple {
    justify-content: center;
}

.header.simple h1 {
    flex: 1;
    text-align: center;
    font-size: 1.125rem;
}

.header-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.header-center {
    flex: 1;
    text-align: center;
    padding: 0 0.5rem;
}

.header-center h1 {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-badge {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ============================================
   Icon Buttons
   ============================================ */
.icon-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: background 0.2s;
    position: relative;
}

.icon-btn:hover {
    background: var(--gray-100);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

.cart-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-btn .badge:empty,
.cart-btn .badge[data-count="0"] {
    display: none;
}

/* ============================================
   Highlights Row (Stories)
   ============================================ */
.highlights-row {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.highlights-row::-webkit-scrollbar {
    display: none;
}

.highlight-item {
    flex: 0 0 auto;
    width: 80px;
    text-align: center;
    cursor: pointer;
}

.highlight-image {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    padding: 2px;
    background: var(--white);
}

.highlight-name {
    font-size: 0.7rem;
    margin-top: 0.375rem;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Categories Filter
   ============================================ */
.categories-filter {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem 1rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.categories-filter::-webkit-scrollbar {
    display: none;
}

.category-chip {
    flex: 0 0 auto;
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-full);
    background: var(--white);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.category-chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
}

/* ============================================
   Products Grid
   ============================================ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 0 1rem 2rem;
    padding-bottom: calc(2rem + var(--bottom-safe));
}

@media (min-width: 640px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 1200px;
        margin: 0 auto;
    }
}

/* ============================================
   Product Card
   ============================================ */
.product-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.product-card:active {
    transform: scale(0.98);
}

.product-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: var(--gray-100);
}

.product-info {
    padding: 0.75rem;
}

.product-name {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 600;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0,0,0,0.5);
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: hidden;
    animation: slideUp 0.3s ease;
    position: relative;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
}

/* Product Detail in Modal */
.product-detail-image {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
}

.product-detail-content {
    padding: 1.5rem;
}

.product-detail-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.product-detail-description {
    color: var(--gray-600);
    margin-bottom: 1rem;
}

.product-detail-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.modifiers-section {
    margin-bottom: 1.5rem;
}

.modifiers-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.modifier-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.modifier-item label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.modifier-price {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.quantity-btn {
    width: 44px;
    height: 44px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    font-size: 1.25rem;
    cursor: pointer;
}

.quantity-value {
    font-size: 1.25rem;
    font-weight: 600;
    min-width: 3rem;
    text-align: center;
}

/* ============================================
   Cart Sidebar
   ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    background: var(--white);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.sidebar.active {
    right: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-header h2 {
    font-size: 1.25rem;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.cart-item-image {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.cart-item-info {
    flex: 1;
}

.cart-item-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.cart-item-modifiers {
    font-size: 0.75rem;
    color: var(--gray-500);
}

.cart-item-price {
    color: var(--primary);
    font-weight: 600;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cart-item-qty-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: var(--white);
    cursor: pointer;
}

.cart-item-remove {
    color: var(--error);
    cursor: pointer;
    font-size: 0.875rem;
}

.cart-footer {
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
    padding-bottom: calc(1rem + var(--bottom-safe));
}

.cart-totals {
    margin-bottom: 1rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    color: var(--gray-600);
}

.total-final {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    border-top: 1px solid var(--gray-200);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.cart-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

/* ============================================
   Checkout Screen
   ============================================ */
.checkout-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    padding-bottom: calc(2rem + var(--bottom-safe));
}

.checkout-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
}

.checkout-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--gray-700);
}

.fulfillment-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fulfillment-option {
    display: block;
    cursor: pointer;
}

.fulfillment-option input {
    display: none;
}

.option-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.fulfillment-option input:checked + .option-content {
    border-color: var(--primary);
    background: rgba(255,107,53,0.05);
}

.option-icon {
    font-size: 1.5rem;
}

.option-label {
    font-weight: 600;
}

.option-desc {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-left: auto;
}

.checkout-section textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
}

.checkout-total {
    background: var(--primary);
    color: var(--white);
}

.checkout-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 700;
}

/* ============================================
   Confirmation Screen
   ============================================ */
.confirmation-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success);
    color: var(--white);
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.confirmation-content h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

#order-number {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.timeline {
    width: 100%;
    max-width: 300px;
    margin: 2rem 0;
}

.timeline-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--gray-300);
}

.timeline-dot.active {
    background: var(--success);
}

.timeline-text {
    font-size: 0.875rem;
}

/* ============================================
   Overlay
   ============================================ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    display: none;
}

.overlay.active {
    display: block;
}

/* ============================================
   Utilities
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}
