/* ── Mobile Agenda Operatore ─────────────────────────────────────────────── */

/* Il contenitore stesso è lo scroll-container (approccio più robusto su iOS/Android).
   Il body non deve scrollare: mob-agenda occupa l'intera viewport e scrolla internamente. */
body:has(.mob-agenda) {
    overflow: hidden;
}

.mob-agenda {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 0 80px;
    font-family: 'DM Sans', sans-serif;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

/* Header */
.mob-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 16px 16px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    border-radius: 0 0 20px 20px;
    margin-bottom: 16px;
}
.mob-header-name  { display: block; font-size: 1.1rem; font-weight: 600; }
.mob-header-sub   { display: block; font-size: 0.8rem; opacity: .65; margin-top: 2px; }
.mob-header-date  { text-align: right; }
.mob-day          { display: block; font-size: 0.75rem; opacity: .65; text-transform: capitalize; }
.mob-date         { display: block; font-size: 0.85rem; font-weight: 500; }

/* States */
.mob-loading {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; padding: 60px 16px; color: #6b7280;
}
.mob-spinner {
    width: 32px; height: 32px; border: 3px solid #e5e7eb;
    border-top-color: #6366f1; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mob-empty {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; padding: 60px 16px; color: #9ca3af;
}
.mob-empty p { margin: 0; font-size: 0.9rem; }

.mob-alert          { padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin: 8px 16px; }
.mob-alert-error    { background: #fee2e2; color: #b91c1c; }
.mob-alert-sm       { margin: 8px 0 0; }

/* Day group */
.mob-day-group    { margin-bottom: 8px; }
.mob-day-header   { padding: 8px 16px 4px; }
.mob-day-label    { font-size: 0.78rem; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; }
.mob-day-label.today { color: #6366f1; }

/* Card */
.mob-card {
    margin: 4px 12px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 6px rgba(0,0,0,.08);
    overflow: hidden;
    border-left: 4px solid transparent;
}
.mob-card.card-planned    { border-left-color: #6366f1; }
.mob-card.card-inprogress { border-left-color: #f59e0b; }
.mob-card.card-done       { border-left-color: #10b981; opacity: .85; }

.mob-card-top {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px 4px;
}
.mob-card-time     { display: flex; align-items: center; gap: 6px; }
.mob-time-start    { font-size: 1rem; font-weight: 700; color: #111827; }
.mob-time-sep      { font-size: 0.8rem; color: #9ca3af; }
.mob-time-end      { font-size: 0.85rem; color: #6b7280; }

/* Badge */
.mob-badge          { font-size: 0.7rem; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.badge-planned      { background: #ede9fe; color: #6366f1; }
.badge-inprogress   { background: #fef3c7; color: #d97706; }
.badge-done         { background: #d1fae5; color: #059669; }

.mob-card-body     { padding: 6px 14px 10px; }
.mob-card-title    { font-size: 0.95rem; font-weight: 600; color: #111827; margin-bottom: 4px; }
.mob-card-client   { display: flex; align-items: center; gap: 5px; font-size: 0.8rem; color: #6b7280; }
.mob-card-note     { font-size: 0.78rem; color: #9ca3af; margin-top: 4px; font-style: italic; }

/* Footer timbratura */
.mob-card-footer   { padding: 8px 14px 12px; border-top: 1px solid #f3f4f6; }

.mob-timbrata      { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; margin-bottom: 4px; }
.mob-timbrata.in   { color: #059669; }
.mob-timbrata.out  { color: #6b7280; }
.mob-gps           { font-size: 0.7rem; color: #9ca3af; margin-left: 2px; }

.mob-actions       { margin-top: 10px; display: flex; gap: 8px; }

.mob-btn {
    flex: 1; display: flex; align-items: center; justify-content: center;
    gap: 7px; padding: 11px 16px; border: none; border-radius: 10px;
    font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: opacity .15s;
}
.mob-btn:disabled  { opacity: .55; cursor: default; }
.mob-btn.start     { background: #6366f1; color: #fff; }
.mob-btn.stop      { background: #f59e0b; color: #fff; }
.mob-btn-spinner   {
    width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite;
}

.mob-completed     { font-size: 0.82rem; color: #059669; font-weight: 600; padding: 4px 0; }

/* ── Bottom Navigation ───────────────────────────────────────────────────── */
.mob-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 62px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    z-index: 200;
    box-shadow: 0 -2px 12px rgba(0,0,0,.07);
}

.mob-nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: .02em;
    transition: color .15s;
}

.mob-nav-tab.active {
    color: #6366f1;
}

.mob-nav-tab svg {
    width: 22px;
    height: 22px;
    stroke-width: 1.8;
}

/* ── Prodotti page ───────────────────────────────────────────────────────── */
.mob-section-label {
    padding: 14px 16px 6px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
}

.mob-prod-card {
    margin: 4px 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mob-prod-info     { flex: 1; min-width: 0; }
.mob-prod-name     { font-size: 0.9rem; font-weight: 600; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mob-prod-code     { font-size: 0.72rem; color: #9ca3af; margin-top: 1px; }

.mob-qty {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.mob-qty-btn {
    width: 30px; height: 30px;
    border: none; border-radius: 8px;
    background: #f3f4f6;
    color: #374151;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .1s;
}
.mob-qty-btn:active { background: #e5e7eb; }
.mob-qty-btn.plus   { background: #ede9fe; color: #6366f1; }
.mob-qty-btn.plus:active { background: #ddd6fe; }

.mob-qty-val {
    width: 32px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
}

.mob-order-panel {
    margin: 8px 12px 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(99,102,241,.15);
    border: 1px solid #e0e7ff;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mob-order-note {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 0.88rem;
    font-family: 'DM Sans', sans-serif;
    resize: none;
    outline: none;
    box-sizing: border-box;
}
.mob-order-note:focus { border-color: #6366f1; }

.mob-btn.send { background: #6366f1; color: #fff; }

.mob-success-box {
    margin: 16px 12px;
    background: #d1fae5;
    border-radius: 12px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #065f46;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
}

/* Richiesta recente card */
.mob-req-card {
    margin: 4px 12px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mob-req-info   { flex: 1; min-width: 0; }
.mob-req-name   { font-size: 0.85rem; font-weight: 600; color: #111827; }
.mob-req-meta   { font-size: 0.72rem; color: #9ca3af; margin-top: 2px; }

.mob-req-badge  { font-size: 0.68rem; font-weight: 700; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.mob-req-badge.InAttesa   { background: #e0e7ff; color: #4338ca; }
.mob-req-badge.Approvata  { background: #d1fae5; color: #065f46; }
.mob-req-badge.Rifiutata  { background: #fee2e2; color: #991b1b; }
.mob-req-badge.Consegnata { background: #f3f4f6; color: #6b7280; }

/* ── Foto operatore ────────────────────────────────────────────────── */
.mob-foto-page { padding-bottom: 100px; }

.mob-foto-section { margin: 0 16px 20px; }

.mob-foto-cliente-attivo {
    display: flex; align-items: center; gap: 12px;
    background: #f0fdf4; border: 1px solid #86efac;
    border-radius: 12px; padding: 12px 16px;
}
.mob-foto-cliente-attivo svg { width: 20px; height: 20px; flex-shrink: 0; stroke: #16a34a; }
.mob-foto-cliente-nome { font-weight: 700; font-size: 0.95rem; }
.mob-foto-cliente-sub  { font-size: 0.72rem; color: #16a34a; margin-top: 1px; }
.mob-foto-cambia-btn {
    margin-left: auto; font-size: 12px; color: #6b7280;
    background: none; border: 1px solid #d1d5db;
    border-radius: 8px; padding: 4px 10px; cursor: pointer;
}

.mob-foto-cliente-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.mob-foto-cliente-item {
    text-align: left; padding: 12px 16px; border-radius: 10px;
    background: #f9fafb; border: 1.5px solid #e5e7eb;
    font-size: 0.9rem; cursor: pointer;
}
.mob-foto-cliente-item.selected {
    background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; font-weight: 600;
}

.mob-foto-select {
    width: 100%; padding: 10px 12px; border-radius: 10px;
    border: 1.5px solid #d1d5db; font-size: 0.9rem; background: #f9fafb;
}

.mob-btn-camera {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 18px; border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: #fff; font-size: 1.05rem; font-weight: 600;
    border: none; cursor: pointer; box-shadow: 0 4px 15px rgba(99,102,241,.3);
}
.mob-btn-camera svg { width: 24px; height: 24px; stroke: #fff; }

.mob-foto-preview-wrap {
    position: relative; border-radius: 14px; overflow: hidden;
    background: #000; margin-bottom: 12px;
}
.mob-foto-preview {
    width: 100%; max-height: 300px; object-fit: contain; display: block;
}
.mob-foto-remove-btn {
    position: absolute; top: 8px; right: 8px;
    background: rgba(0,0,0,.55); color: #fff; border: none;
    border-radius: 50%; width: 28px; height: 28px;
    font-size: 14px; cursor: pointer; line-height: 28px; text-align: center;
}
.mob-foto-upload-overlay {
    position: absolute; inset: 0;
    background: rgba(0,0,0,.55);
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 12px;
    color: #fff; font-size: 14px; font-weight: 600;
}

.mob-foto-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.mob-foto-thumb-wrap {
    position: relative; border-radius: 8px; overflow: hidden;
    aspect-ratio: 1; background: #f3f4f6; display: block;
}
.mob-foto-thumb { width: 100%; height: 100%; object-fit: cover; }
.mob-foto-thumb-desc {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,.55); color: #fff;
    font-size: 10px; padding: 3px 5px; line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
