/* GestionalePW.Mobile — Tema Persico Mobile-First */

/* ── Font Neo Sans Pro ─────────────────────────────────────────────────── */
@font-face { font-family: 'Neo Sans Pro'; src: url('/fonts/NeoSansPro-Light.otf') format('opentype'); font-weight: 300; }
@font-face { font-family: 'Neo Sans Pro'; src: url('/fonts/NeoSansPro-Regular.otf') format('opentype'); font-weight: 400; }
@font-face { font-family: 'Neo Sans Pro'; src: url('/fonts/NeoSansPro-Bold.otf') format('opentype'); font-weight: 700; }

/* ── Design Tokens ─────────────────────────────────────────────────────── */
:root {
    --pw-primary: #D61019;
    --pw-primary-light: #f8d7d9;
    --pw-dark: #1D1D1B;
    --pw-secondary: #4A4A4A;
    --pw-muted: #6F6F6F;
    --pw-light: #F5F5F5;
    --pw-white: #FFFFFF;
    --pw-border: #E7E7E7;
    --pw-success: #198754;
    --pw-warning: #ffc107;
    --pw-danger: #dc3545;
    --pw-info: #0dcaf0;
    --pw-radius: 8px;
    --pw-radius-lg: 12px;
    --pw-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --pw-shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --pw-font: 'Neo Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset & 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(--pw-font);
    font-weight: 400;
    color: var(--pw-dark);
    background: var(--pw-light);
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ── App Shell ─────────────────────────────────────────────────────────── */
.app-header {
    background: var(--pw-white);
    border-bottom: 3px solid var(--pw-primary);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--pw-shadow);
}

.app-header .logo {
    height: 28px;
}

.app-header .user-info {
    font-size: 0.8125rem;
    color: var(--pw-muted);
}

.app-header .btn-back {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--pw-primary);
    padding: 4px 8px;
    cursor: pointer;
}

.app-content {
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 80px;
}

/* ── Pages (SPA routing) ───────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80dvh;
    padding: 24px;
}

.login-card {
    background: var(--pw-white);
    border-radius: var(--pw-radius-lg);
    box-shadow: var(--pw-shadow-lg);
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-card .logo {
    height: 40px;
    margin-bottom: 24px;
}

.login-card h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--pw-dark);
}

/* ── Form Controls ─────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--pw-secondary);
    margin-bottom: 4px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--pw-border);
    border-radius: var(--pw-radius);
    font-family: var(--pw-font);
    font-size: 1rem;
    color: var(--pw-dark);
    background: var(--pw-white);
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--pw-primary);
    box-shadow: 0 0 0 3px var(--pw-primary-light);
}

.form-input::placeholder {
    color: var(--pw-muted);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--pw-radius);
    font-family: var(--pw-font);
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    -webkit-user-select: none;
    user-select: none;
}

.btn-primary {
    background: var(--pw-primary);
    color: var(--pw-white);
    width: 100%;
}

.btn-primary:active { background: #b30e15; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.btn-outline {
    background: var(--pw-white);
    color: var(--pw-primary);
    border: 1.5px solid var(--pw-primary);
}

.btn-outline:active { background: var(--pw-primary-light); }

.btn-success {
    background: var(--pw-success);
    color: var(--pw-white);
    width: 100%;
}

.btn-success:active { background: #146c43; }

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 16px 24px;
    font-size: 1.125rem;
    border-radius: var(--pw-radius-lg);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--pw-white);
    border-radius: var(--pw-radius);
    box-shadow: var(--pw-shadow);
    margin-bottom: 12px;
    overflow: hidden;
}

.card-header {
    background: var(--pw-light);
    border-bottom: 2px solid var(--pw-primary);
    padding: 10px 14px;
    font-weight: 700;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 14px;
}

/* ── Lista componenti (checklist) ──────────────────────────────────────── */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--pw-border);
    cursor: pointer;
    transition: background 0.1s;
}

.checklist-item:active { background: var(--pw-light); }
.checklist-item:last-child { border-bottom: none; }

.checklist-progress {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--pw-white);
    background: var(--pw-muted);
    border-radius: 999px;
    padding: 2px 10px;
    min-width: 50px;
    text-align: center;
    flex-shrink: 0;
}

.checklist-progress.complete { background: var(--pw-success); }
.checklist-progress.partial { background: var(--pw-warning); color: var(--pw-dark); }

.checklist-name {
    flex: 1;
    font-size: 0.9375rem;
}

.checklist-name small {
    display: block;
    color: var(--pw-muted);
    font-size: 0.75rem;
    font-weight: 300;
}

.checklist-chevron {
    color: var(--pw-muted);
    font-size: 1.25rem;
}

/* ── Section Headers (posizioni/singoli) ──────────────────────────────── */
.section-header {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--pw-muted);
    padding: 4px 2px 6px;
    border-bottom: 2px solid var(--pw-primary);
    margin-bottom: 8px;
}

/* ── Progress Bar ──────────────────────────────────────────────────────── */
.progress-bar-container {
    background: var(--pw-border);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--pw-success);
    border-radius: 999px;
    transition: width 0.3s;
}

/* ── Scan Page ─────────────────────────────────────────────────────────── */
.scan-preview {
    width: 100%;
    border-radius: var(--pw-radius);
    margin: 12px 0;
    max-height: 300px;
    object-fit: contain;
    background: #000;
}

.ocr-result {
    background: var(--pw-light);
    border: 1px solid var(--pw-border);
    border-radius: var(--pw-radius);
    padding: 14px;
    margin: 12px 0;
}

.ocr-result label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--pw-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ocr-result .value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--pw-dark);
    margin-top: 2px;
}

/* ── Badge ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success { background: #d1e7dd; color: #0f5132; }
.badge-warning { background: #fff3cd; color: #664d03; }
.badge-danger { background: #f8d7da; color: #842029; }
.badge-info { background: #cff4fc; color: #055160; }

/* ── Alert ──────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 14px;
    border-radius: var(--pw-radius);
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.alert-error { background: #f8d7da; color: #842029; border: 1px solid #f5c2c7; }
.alert-success { background: #d1e7dd; color: #0f5132; border: 1px solid #badbcc; }
.alert-info { background: #cff4fc; color: #055160; border: 1px solid #b6effb; }

/* ── Empty State ───────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--pw-muted);
}

.empty-state .icon { font-size: 3rem; opacity: 0.3; margin-bottom: 12px; }

/* ── Camera button ─────────────────────────────────────────────────────── */
.btn-camera {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 32px;
    border: 2px dashed var(--pw-border);
    border-radius: var(--pw-radius-lg);
    background: var(--pw-white);
    cursor: pointer;
    transition: all 0.15s;
    color: var(--pw-muted);
    font-family: var(--pw-font);
}

.btn-camera:active { border-color: var(--pw-primary); color: var(--pw-primary); }
.btn-camera .camera-icon { font-size: 2.5rem; margin-bottom: 8px; }
.btn-camera span { font-size: 0.875rem; font-weight: 700; }

/* ── Spinner ───────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-dark {
    border-color: rgba(0,0,0,0.1);
    border-top-color: var(--pw-primary);
}

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

/* ── Utility ───────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--pw-muted); }
.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ── Safe area for notch/bottom bar ────────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .app-content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
}
