/**
 * SharkBurgerDeliveryApp - Estilos CSS
 * 
 * Diseño mobile-first, limpio y profesional
 * Optimizado para uso en dispositivos móviles por domiciliarios
 */

/* ============================================
   VARIABLES CSS - PALETA DE COLORES PERSONALIZADA
   ============================================ */
:root {
    /* Colores principales */
    --color-primary: #5A9EAF;
    --color-primary-hover: #4a8a9a;
    --color-secondary: #A67658;
    --color-secondary-hover: #95674c;
    
    /* Colores de estado */
    --color-success: #4caf50;
    --color-error: #f44336;
    --color-error-dark: #c62828;
    --color-warning: #f8a046;
    
    /* Colores de pager (Busca-Personas) */
    --color-pager-yellow: #FFD700;
    --color-pager-blue: #0066CC;
    --color-pager-occupied-bg: #ffebee;
    --color-pager-occupied-border: #c62828;
    
    /* Colores de texto */
    --color-text-primary: #1C1C1C;
    --color-text-secondary-1: #333333;
    --color-text-secondary-2: #666666;
    --color-text-secondary-3: #888888;
    --color-text-secondary-4: #999999;
    --color-text-white: #FFFFFF;
    
    /* Colores de fondo */
    --color-bg-1: #f0f0f0;
    --color-bg-2: #f5f5f5;
    --color-bg-3: #f8f8f8;
    --color-bg-4: #f9f9f9;
    --color-bg-primary: #f5f5f5;
    --color-bg-secondary: #f8f8f8;
    --color-bg-card: #FFFFFF;
    --color-bg-card-hover: #f9f9f9;
    
    /* Colores de bordes */
    --border-color-1: #dddddd;
    --border-color-2: #e0e0e0;
    --border-color-3: #eeeeee;
    --border-color: #e0e0e0;
    
    /* Estados con fondos */
    --color-success-bg: rgba(76, 175, 80, 0.1);
    --color-warning-bg: rgba(248, 160, 70, 0.1);
    --color-error-bg: rgba(244, 67, 54, 0.1);
    
    /* Sombras */
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-button: 0 4px 12px rgba(90, 158, 175, 0.3);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    
    /* Bordes y radios */
    --border-radius: 16px;
    --border-radius-sm: 10px;
    
    /* Tipografía */
    --font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-family-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    /* Espaciado */
    --spacing-xs: 6px;
    --spacing-sm: 12px;
    --spacing-md: 18px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Transiciones */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   RESET Y BASE
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    
    /* Fondo con patrón sutil */
    background-image: 
        radial-gradient(ellipse at top, rgba(90, 158, 175, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(166, 118, 88, 0.02) 0%, transparent 40%);
    background-attachment: fixed;
}

/* ============================================
   HEADER
   ============================================ */
.header {
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md) var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0; /* Previene overflow */
    gap: var(--spacing-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: var(--shadow-button);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logo-text span {
    color: var(--color-primary);
}

.order-count {
    background: var(--color-primary);
    color: var(--color-text-white);
    font-size: 0.85rem;
    font-weight: 700;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 20px;
    min-width: 32px;
    text-align: center;
}

/* ============================================
   CONTENEDOR PRINCIPAL
   ============================================ */
.main-container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    padding-bottom: 100px;
    width: 100%;
    min-width: 0; /* Previene overflow en pantallas pequeñas */
}

/* ============================================
   ESTADOS VACÍOS Y CARGA
   ============================================ */
.loading-state,
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    text-align: center;
    min-height: 300px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color-3);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-lg);
}

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

.state-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.8;
}

.state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text-primary);
}

.state-message {
    color: var(--color-text-secondary-2);
    font-size: 0.95rem;
}

.error-state .state-icon {
    color: var(--color-error);
}

.retry-btn {
    margin-top: var(--spacing-lg);
    background: var(--color-primary);
    color: var(--color-text-white);
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.retry-btn:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
}

/* ============================================
   LISTA DE ÓRDENES
   ============================================ */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* ============================================
   TARJETA DE ORDEN
   ============================================ */
.order-card {
    background: var(--color-bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    transition: all var(--transition-normal);
    animation: slideIn 0.4s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}

.order-card:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-hover);
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animación escalonada para las tarjetas */
.order-card:nth-child(1) { animation-delay: 0.05s; }
.order-card:nth-child(2) { animation-delay: 0.1s; }
.order-card:nth-child(3) { animation-delay: 0.15s; }
.order-card:nth-child(4) { animation-delay: 0.2s; }
.order-card:nth-child(5) { animation-delay: 0.25s; }
.order-card:nth-child(6) { animation-delay: 0.3s; }
.order-card:nth-child(7) { animation-delay: 0.35s; }
.order-card:nth-child(8) { animation-delay: 0.4s; }

/* Animación de salida */
.order-card.removing {
    animation: slideOut 0.4s ease forwards;
}

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(100%);
        height: 0;
        padding: 0;
        margin: 0;
        border: 0;
    }
}

/* ============================================
   HEADER DE LA TARJETA
   ============================================ */
.order-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.order-id {
    font-family: var(--font-family-mono);
    font-size: 0.8rem;
    color: var(--color-text-secondary-3);
    background: var(--color-bg-2);
    padding: 4px 10px;
    border-radius: 6px;
}

.order-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.order-status.pending {
    color: var(--color-warning);
}

.order-status.delivered {
    color: var(--color-success);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.pending .status-dot {
    background: var(--color-warning);
}

.delivered .status-dot {
    background: var(--color-success);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   INFORMACIÓN DEL CLIENTE
   ============================================ */
.customer-name {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text-primary);
    letter-spacing: -0.01em;
}

/* ============================================
   DETALLES DE LA ORDEN
   ============================================ */
.order-details {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.detail-icon {
    width: 36px;
    height: 36px;
    background: var(--color-bg-2);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.detail-content {
    flex: 1;
    min-width: 0;
}

.detail-label {
    font-size: 0.75rem;
    color: var(--color-text-secondary-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--color-text-primary);
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.detail-value.highlight {
    color: var(--color-primary);
    font-weight: 600;
}

/* Resumen del pedido - estilo especial */
.order-summary-box {
    background: var(--color-success-bg);
    border: 1px solid var(--color-success);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    margin-top: var(--spacing-xs);
}

.order-summary-box .detail-value {
    font-size: 1rem;
    line-height: 1.5;
}

/* ============================================
   MÉTODO DE PAGO
   ============================================ */
.payment-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.payment-badge.cash {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.payment-badge.card,
.payment-badge.transfer {
    background: var(--color-pager-blue);
    background: rgba(0, 102, 204, 0.1);
    color: var(--color-pager-blue);
}

.payment-badge.other {
    background: var(--color-bg-2);
    color: var(--color-text-secondary-2);
}

/* ============================================
   BOTÓN DE LLAMADA
   ============================================ */
.phone-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.phone-link:hover {
    color: var(--color-primary-hover);
}

.phone-link::after {
    content: '📞';
    font-size: 0.9rem;
}

/* ============================================
   BOTÓN ENTREGAR
   ============================================ */
.deliver-btn {
    width: 100%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    color: var(--color-text-white);
    border: none;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius-sm);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow-button);
    position: relative;
    overflow: hidden;
    min-height: 48px; /* Tamaño mínimo táctil (estándar iOS/Android) */
    touch-action: manipulation; /* Mejora respuesta táctil */
    -webkit-tap-highlight-color: rgba(90, 158, 175, 0.2);
}

.deliver-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.deliver-btn:hover::before {
    left: 100%;
}

.deliver-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(90, 158, 175, 0.4);
}

.deliver-btn:active {
    transform: translateY(0);
}

.deliver-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.deliver-btn.loading {
    pointer-events: none;
}

.deliver-btn.loading .btn-text {
    opacity: 0;
}

.deliver-btn.loading::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid transparent;
    border-top-color: var(--color-text-white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-icon {
    font-size: 1.3rem;
}

/* ============================================
   TOAST / NOTIFICACIONES
   ============================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 32px);
    max-width: 400px;
    padding: 0 var(--spacing-md);
    box-sizing: border-box;
}

.toast {
    background: var(--color-bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: toastIn 0.3s ease;
}

.toast.success {
    border-color: var(--color-success);
    background: linear-gradient(135deg, var(--color-bg-card), var(--color-success-bg));
}

.toast.error {
    border-color: var(--color-error);
    background: linear-gradient(135deg, var(--color-bg-card), var(--color-error-bg));
}

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

.toast-message {
    flex: 1;
    font-size: 0.95rem;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast.hiding {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* ============================================
   RESPONSIVE - PANTALLAS MUY PEQUEÑAS (< 360px)
   ============================================ */
@media (max-width: 359px) {
    html {
        font-size: 14px;
    }
    
    .header {
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .logo-text {
        font-size: 1.1rem;
    }
    
    .main-container {
        padding: var(--spacing-md);
        padding-bottom: 100px;
    }
    
    .order-card {
        padding: var(--spacing-md);
    }
    
    .customer-name {
        font-size: 1.2rem;
    }
    
    .deliver-btn {
        font-size: 1rem;
        padding: var(--spacing-sm) var(--spacing-md);
        min-height: 48px;
    }
    
    .detail-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .detail-value {
        font-size: 0.9rem;
    }
}

/* ============================================
   RESPONSIVE - PANTALLAS PEQUEÑAS (360px - 374px)
   ============================================ */
@media (min-width: 360px) and (max-width: 374px) {
    .header {
        padding: var(--spacing-md);
    }
    
    .main-container {
        padding: var(--spacing-md) var(--spacing-lg);
    }
}

/* ============================================
   RESPONSIVE - PANTALLAS MEDIANAS (375px - 414px)
   ============================================ */
@media (min-width: 375px) and (max-width: 414px) {
    .main-container {
        padding: var(--spacing-lg);
    }
}

/* ============================================
   RESPONSIVE - PANTALLAS GRANDES MÓVILES (> 414px)
   ============================================ */
@media (min-width: 415px) and (max-width: 599px) {
    .main-container {
        padding: var(--spacing-xl) var(--spacing-lg);
    }
    
    .order-card {
        padding: var(--spacing-xl);
    }
}

/* ============================================
   RESPONSIVE - TABLETS (600px+)
   ============================================ */
@media (min-width: 600px) {
    .main-container {
        padding: var(--spacing-xl);
    }
    
    .order-card {
        padding: var(--spacing-xl);
    }
    
    .customer-name {
        font-size: 1.5rem;
    }
}

/* ============================================
   MODO OSCURO FORZADO (iOS/Android)
   ============================================ */
@media (prefers-color-scheme: dark) {
    body {
        color-scheme: dark;
    }
}

/* ============================================
   SAFE AREA PARA NOTCH/HOME INDICATOR
   ============================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .main-container {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
    
    .toast-container {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible para navegación por teclado */
.deliver-btn:focus-visible,
.retry-btn:focus-visible,
.phone-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ============================================
   IMPORTACIÓN DE FUENTES (Google Fonts)
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

