/* =====================================================
   Portal Trabajador - Mobile First / Senior Friendly
   ===================================================== */

:root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #faf8f3;
    color: #2d2419;
    font-size: 18px;
    line-height: 1.5;
    padding-bottom: calc(90px + var(--safe-bottom));
}

/* Header */
.mobile-header {
    background: linear-gradient(135deg, #2d2419 0%, #1a1a1a 100%);
    color: white;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.header-logo {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid rgba(201, 162, 39, 0.4);
}

.mobile-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gold);
    margin: 0;
    line-height: 1.2;
}

.mobile-header p {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
    margin: 0.25rem 0 0;
}

/* Banner aiuto */
.help-banner {
    background: #fef3c7;
    border-bottom: 2px solid #f59e0b;
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    color: #92400e;
    font-weight: 500;
}

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

/* Ricerca */
.mobile-search {
    padding: 1rem;
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 88px;
    z-index: 40;
}

.mobile-search input {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid var(--gray-300);
    border-radius: 1rem;
    font-size: 1.1rem;
    background: var(--gray-100);
    transition: all 0.2s;
}

.mobile-search input:focus {
    outline: none;
    border-color: var(--gold);
    background: white;
    box-shadow: 0 0 0 4px rgba(201, 162, 39, 0.15);
}

/* Container prodotti */
.products-container {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.products-list-mobile {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Card prodotto mobile */
.product-card-mobile {
    background: white;
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 2px solid transparent;
    transition: all 0.2s;
}

.product-card-mobile.in-cart {
    border-color: var(--gold);
    box-shadow: 0 4px 16px rgba(201, 162, 39, 0.2);
}

.product-card-mobile.out-of-stock {
    opacity: 0.7;
    background: var(--gray-100);
}

.product-card-mobile.out-of-stock .product-image-mobile {
    filter: grayscale(0.6);
}

.product-image-mobile {
    position: relative;
    height: 200px;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    overflow: hidden;
}

.product-image-mobile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image-placeholder-mobile {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.product-stock-badge-mobile {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.95);
    border-radius: 9999px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--gray-800);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.product-stock-badge-mobile.low {
    background: #fee2e2;
    color: #991b1b;
}

.product-stock-badge-mobile.out {
    background: #e5e7eb;
    color: #374151;
    font-weight: 700;
}

.product-info-mobile {
    padding: 1.25rem;
}

.product-category-mobile {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.375rem;
    background: rgba(201, 162, 39, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
}

.product-name-mobile {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0 0 0.5rem;
    line-height: 1.3;
}

.product-desc-mobile {
    font-size: 1rem;
    color: var(--gray-600);
    margin: 0 0 1rem;
    line-height: 1.4;
}

/* Bottone Aggiungi */
.btn-add-mobile {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--gold) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 1rem;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(201, 162, 39, 0.3);
    min-height: 56px;
}

.btn-add-mobile:active {
    transform: scale(0.98);
}

/* Controlli quantità */
.quantity-controls-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.qty-btn-mobile {
    width: 56px;
    height: 56px;
    border: 3px solid var(--gold);
    background: white;
    border-radius: 1rem;
    color: var(--gray-800);
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
}

.qty-btn-mobile:active {
    background: var(--gold);
    color: white;
}

.qty-btn-mobile:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.qty-btn-mobile.small {
    width: 44px;
    height: 44px;
    font-size: 1.25rem;
    border-width: 2px;
}

.qty-display-mobile {
    min-width: 60px;
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
}

.added-label {
    text-align: center;
    color: var(--success);
    font-weight: 700;
    font-size: 1rem;
}

/* Barra carrello fissa */
.cart-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 3px solid var(--gold);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 100;
    padding-bottom: calc(1rem + var(--safe-bottom));
    cursor: pointer;
}

.cart-bar-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.cart-bar-icon {
    font-size: 1.75rem;
}

.cart-bar-count {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gray-800);
}

.cart-bar-btn {
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--gold) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(201, 162, 39, 0.3);
    min-height: 52px;
}

.cart-bar.has-items .cart-bar-btn {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Modali */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
}

.modal-pro {
    background: white;
    border-radius: 1.5rem 1.5rem 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.3);
}

.modal-fullscreen {
    max-height: 95vh;
    border-radius: 1.5rem 1.5rem 0 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 2px solid var(--gray-200);
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.modal-header h3 {
    font-size: 1.35rem;
    color: var(--gray-800);
    margin: 0;
}

.btn-close {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--gray-100);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Riassunto carrello */
.cart-summary-body {
    padding: 1.25rem;
}

.cart-summary-items {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    margin-bottom: 1.25rem;
    max-height: 40vh;
    overflow-y: auto;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem;
    background: var(--gray-50);
    border-radius: 1rem;
    border: 1px solid var(--gray-200);
}

.summary-item-img {
    width: 60px;
    height: 60px;
    border-radius: 0.75rem;
    object-fit: cover;
    background: var(--gray-200);
    flex-shrink: 0;
}

.summary-item-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.summary-item-info {
    flex: 1;
    min-width: 0;
}

.summary-item-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gray-800);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-item-qty {
    font-size: 0.95rem;
    color: var(--gray-600);
}

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

.summary-item-count {
    min-width: 32px;
    text-align: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.cart-summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-top: 2px solid var(--gray-200);
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.cart-summary-total strong {
    font-size: 1.5rem;
    color: var(--primary);
}

.cart-summary-observations {
    margin-bottom: 1.25rem;
}

.cart-summary-observations label {
    display: block;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.cart-summary-observations textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--gray-300);
    border-radius: 1rem;
    font-size: 1.05rem;
    resize: vertical;
    min-height: 90px;
}

.btn-submit-order {
    width: 100%;
    padding: 1.1rem;
    background: linear-gradient(135deg, var(--gold) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(201, 162, 39, 0.35);
    min-height: 60px;
}

.btn-submit-order:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-arrow {
    font-size: 1.5rem;
}

/* Modal codice */
.code-modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 50vh;
}

.code-instructions {
    text-align: center;
    margin-bottom: 2rem;
}

.code-instructions p {
    font-size: 1.25rem;
    color: var(--gray-700);
    margin: 0;
}

.code-input-wrapper {
    width: 100%;
    max-width: 320px;
    margin-bottom: 1.5rem;
}

.code-input {
    width: 100%;
    padding: 1.25rem;
    border: 3px solid var(--gray-300);
    border-radius: 1rem;
    font-size: 2.5rem;
    text-align: center;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--gray-800);
    background: var(--gray-50);
    transition: all 0.2s;
}

.code-input:focus {
    outline: none;
    border-color: var(--gold);
    background: white;
    box-shadow: 0 0 0 6px rgba(201, 162, 39, 0.15);
}

.code-remember {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    color: var(--gray-700);
}

.code-remember input[type="checkbox"] {
    width: 28px;
    height: 28px;
    accent-color: var(--gold);
    cursor: pointer;
}

.code-remember label {
    cursor: pointer;
    margin: 0;
    font-weight: 500;
}

.error-message {
    color: var(--danger);
    text-align: center;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
    min-height: 1.5rem;
}

/* Schermata successo */
.success-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #faf8f3 0%, #f5f2eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
}

.success-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.success-icon {
    width: 120px;
    height: 120px;
    background: var(--success);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    margin: 0 auto 1.5rem;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    animation: scaleIn 0.4s ease;
}

@keyframes scaleIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.success-content h2 {
    font-size: 2rem;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

.success-content p {
    font-size: 1.25rem;
    color: var(--gray-600);
    margin-bottom: 2rem;
    line-height: 1.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    z-index: 1000;
    animation: slideUp 0.3s ease;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 500;
    max-width: 90%;
    min-width: 250px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
}

.empty-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.hidden {
    display: none !important;
}

/* Tablet e desktop: layout a griglia */
@media (min-width: 640px) {
    .products-list-mobile {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
}

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