/* ===================================================
   WC Gestione Resi – Frontend CSS v1.1.0
   =================================================== */

/* Wrapper generale */
.wgr-wrapper {
    max-width: 860px;
}

/* Header con titolo + bottone */
.wgr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e0e0e0;
}

.wgr-header h2 {
    margin: 0;
    font-size: 1.4rem;
}

/* Back link */
.wgr-back {
    font-size: .9rem;
    color: #666;
    text-decoration: none;
}
.wgr-back:hover { color: #333; }

/* Bottoni */
.wgr-btn-nuovo {
    background: #2c3e50 !important;
    color: #fff !important;
    border-color: #2c3e50 !important;
    font-size: .85rem !important;
}
.wgr-btn-nuovo:hover {
    background: #1a252f !important;
    color: #fff !important;
}
.wgr-btn-small {
    font-size: .8rem !important;
    padding: 4px 10px !important;
}
.wgr-btn-submit {
    margin-top: 8px;
    width: 100%;
    max-width: 280px;
    padding: 12px 0 !important;
    font-size: 1rem !important;
}

/* Empty state */
.wgr-empty {
    background: #f9f9f9;
    border: 1px dashed #ccc;
    border-radius: 6px;
    padding: 32px;
    text-align: center;
    color: #666;
}

/* Tabella lista resi */
.wgr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}
.wgr-table th {
    background: #f4f4f4;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}
.wgr-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}
.wgr-table tr:hover td { background: #fafafa; }

/* Badge stato */
.wgr-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.wgr-badge-lg {
    font-size: .88rem;
    padding: 5px 14px;
}

.wgr-stato-in_attesa  { background: #fff3cd; color: #856404; }
.wgr-stato-approvato  { background: #d1e7dd; color: #0a3622; }
.wgr-stato-rifiutato  { background: #f8d7da; color: #58151c; }
.wgr-stato-spedito    { background: #cfe2ff; color: #084298; }
.wgr-stato-ricevuto   { background: #d1e7dd; color: #0a3622; }
.wgr-stato-rimborsato { background: #c3e6cb; color: #155724; }
.wgr-stato-chiuso     { background: #e2e3e5; color: #41464b; }

/* Info box */
.wgr-info-box {
    background: #f0f7ff;
    border-left: 4px solid #2c6fad;
    padding: 12px 16px;
    border-radius: 0 4px 4px 0;
    margin-bottom: 24px;
    font-size: .9rem;
    line-height: 1.6;
}

/* Form */
.wgr-form {
    max-width: 640px;
}
.wgr-campo {
    margin-bottom: 20px;
}
.wgr-campo label {
    display: block;
    margin-bottom: 6px;
    font-size: .92rem;
}
.wgr-select,
.wgr-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: .92rem;
    font-family: inherit;
    background: #fff;
    transition: border-color .2s;
    box-sizing: border-box;
}
.wgr-select:focus,
.wgr-textarea:focus {
    border-color: #2c6fad;
    outline: none;
    box-shadow: 0 0 0 2px rgba(44,111,173,.15);
}
.wgr-textarea { resize: vertical; }

.wgr-campo-check label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: .88rem;
    line-height: 1.5;
}
.wgr-campo-check input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
}

/* Errori */
.wgr-errori { margin-bottom: 20px; }

/* Dettaglio pratica */
.wgr-dettaglio {}
.wgr-stato-box {
    margin-bottom: 20px;
    font-size: 1rem;
}
.wgr-dettaglio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    margin-bottom: 20px;
}
.wgr-dettaglio-table th {
    width: 30%;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    background: #f7f7f7;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}
.wgr-dettaglio-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    line-height: 1.6;
}

/* Nota admin */
.wgr-nota-admin {
    background: #f0f7ff;
    border-left: 4px solid #2271b1;
    padding: 14px 16px;
    border-radius: 0 4px 4px 0;
    margin: 20px 0;
    font-size: .9rem;
    line-height: 1.7;
}

/* Istruzioni stato */
.wgr-istruzioni {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 14px 16px;
    margin-top: 20px;
    font-size: .9rem;
}

/* Responsive */
@media (max-width: 600px) {
    .wgr-header { flex-direction: column; align-items: flex-start; }
    .wgr-table th:nth-child(3),
    .wgr-table td:nth-child(3) { display: none; }
    .wgr-dettaglio-table th,
    .wgr-dettaglio-table td { display: block; width: 100%; }
    .wgr-dettaglio-table th { background: #f0f0f0; }
}

/* ── Allegati ────────────────────────────────────────────────────── */
.wgr-facoltativo {
    font-weight: normal;
    color: #888;
    font-size: .85em;
}

.wgr-file-input {
    display: block;
    margin-top: 6px;
    font-size: .9rem;
    width: 100%;
}

.wgr-field-hint {
    margin: 5px 0 0;
    font-size: .82rem;
    color: #888;
    line-height: 1.5;
}

/* Preview allegati (JS-enhanced) */
.wgr-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}
.wgr-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f7f7f7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    color: #666;
    text-align: center;
}
.wgr-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Allegati nel dettaglio */
.wgr-allegati-box {
    background: #f7f7f7;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 14px 16px;
    margin: 16px 0;
}
.wgr-allegati-list {
    margin: 8px 0 0;
    padding-left: 20px;
}
.wgr-allegati-list li {
    margin-bottom: 6px;
    font-size: .9rem;
}
.wgr-allegati-list a {
    color: #2c6fad;
    text-decoration: none;
}
.wgr-allegati-list a:hover { text-decoration: underline; }

/* ── Selezione prodotti ──────────────────────────────────────────── */
.wgr-prodotti-lista {
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.wgr-prodotto-row {
    padding: 12px 14px;
    border-bottom: 1px solid #eee;
    background: #fff;
    transition: background .15s;
}
.wgr-prodotto-row:last-child { border-bottom: none; }
.wgr-prodotto-row:hover      { background: #fafafa; }

.wgr-prod-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin: 0;
    font-weight: normal;
}
.wgr-prod-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #2c6fad;
}

.wgr-prod-img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid #eee;
}
.wgr-prod-img-placeholder {
    background: #f0f0f0;
}

.wgr-prod-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.4;
}
.wgr-prod-info strong {
    font-size: .92rem;
}
.wgr-prod-info small {
    font-size: .78rem;
    color: #888;
}

.wgr-prod-qty {
    margin: 10px 0 4px 30px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.wgr-prod-qty label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .88rem;
    font-weight: normal;
    margin: 0;
}
.wgr-qty-input {
    width: 70px;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: .9rem;
    text-align: center;
}

.wgr-loading {
    padding: 14px;
    color: #888;
    font-size: .9rem;
}
.wgr-error-inline {
    color: #b00;
    font-size: .88rem;
    margin: 8px 0 4px;
}

@media (max-width: 480px) {
    .wgr-prod-img { width: 40px; height: 40px; }
    .wgr-prod-qty { margin-left: 10px; }
}

/* ── Box spese ───────────────────────────────────────────────────── */
.wgr-spese-box {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: 0 6px 6px 0;
    font-size: .9rem;
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Verde - venditore */
.wgr-spese-venditore {
    background: #d1fae5;
    border-left: 3px solid #10b981;
    color: #065f46;
}
/* Ambra - cliente */
.wgr-spese-cliente {
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    color: #78350f;
}
/* Grigio - concordare */
.wgr-spese-concordare {
    background: #f3f4f6;
    border-left: 3px solid #9ca3af;
    color: #374151;
}

/* Badge spese nel dettaglio pratica */
.wgr-spese-badge {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 8px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.wgr-spese-venditore.wgr-spese-badge  { background: #d1fae5; color: #065f46; }
.wgr-spese-cliente.wgr-spese-badge    { background: #fef3c7; color: #78350f; }
.wgr-spese-concordare.wgr-spese-badge { background: #f3f4f6; color: #374151; }

/* ── Pulsante reso nella pagina ordine ───────────────────────────── */
.wgr-reso-da-ordine {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}
.wgr-reso-da-ordine h2 {
    font-size: 1.1rem;
    margin-bottom: 8px;
}
.wgr-btn-reso-ordine {
    display: inline-block;
    margin-top: 8px;
    background: #2c3e50 !important;
    color: #fff !important;
    border-color: #2c3e50 !important;
    font-size: .9rem !important;
}
.wgr-btn-reso-ordine:hover {
    background: #1a252f !important;
    color: #fff !important;
}

/* ── Modale conferma (art. 54-bis — doppia conferma) ─────────────── */
.wgr-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 16px;
}

.wgr-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    padding: 32px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.wgr-modal h3 {
    margin: 0 0 8px;
    font-size: 1.2rem;
    color: #2c3e50;
}

.wgr-modal p {
    font-size: .92rem;
    color: #555;
    margin-bottom: 16px;
}

.wgr-modal-riepilogo {
    margin: 16px 0 24px;
}

.wgr-modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.wgr-modal-table th {
    width: 30%;
    padding: 9px 12px;
    text-align: left;
    font-weight: 600;
    background: #f7f7f7;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}
.wgr-modal-table td {
    padding: 9px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    line-height: 1.55;
}

.wgr-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 8px;
}

.wgr-modal-actions .button {
    font-size: .9rem !important;
    padding: 10px 20px !important;
}

#wgr-modal-conferma {
    background: #2c3e50 !important;
    color: #fff !important;
    border-color: #2c3e50 !important;
}
#wgr-modal-conferma:hover {
    background: #1a252f !important;
}

@media (max-width: 480px) {
    .wgr-modal { padding: 20px; }
    .wgr-modal-actions { justify-content: stretch; }
    .wgr-modal-actions .button { width: 100%; text-align: center; }
}
