/* ══════════════════════════════════════════════════════════
   ERMES — Stylesheet
   DC Software
   ══════════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --c-bg: #f5f6fa;
    --c-surface: #ffffff;
    --c-border: #e2e5ee;
    --c-text: #1a1f36;
    --c-text-muted: #6b7280;
    --c-primary: #2d4a6b;
    --c-primary-dk: #223a57;
    --c-primary-lt: #e8f0f7;
    --c-danger: #e63946;
    --c-success: #2a9d8f;
    --c-warning: #f4a261;
    /* badge colori stato */
    --c-aperta: #3b82f6;
    --c-lavorazione: #8b5cf6;
    --c-attesa: #f59e0b;
    --c-chiusa: #6b7280;
    --c-annullata: #ef4444;
    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
    --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "SF Mono", "Fira Code", monospace;
}

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.5;
}

/* ─── Blazor error UI ────────────────────────────────────── */
#blazor-error-ui {
    display: none;
    background: #fee2e2;
    border-top: 1px solid #fca5a5;
    bottom: 0;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 9999;
    font-size: 13px;
    color: var(--c-danger);
}
#blazor-error-ui .reload { font-weight: 600; margin-left: 0.5rem; }
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ─── Layout ─────────────────────────────────────────────── */
.ermes-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.ermes-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 52px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.ermes-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.brand-logo {
    height: 30px;
    object-fit: contain;
}

.ermes-nav {
    display: flex;
    gap: 4px;
    flex: 1;
}

    .ermes-nav a {
        padding: 6px 14px;
        border-radius: var(--radius-sm);
        text-decoration: none;
        color: var(--c-text-muted);
        font-weight: 500;
        transition: background .15s, color .15s;
    }

        .ermes-nav a:hover, .ermes-nav a.active {
            background: var(--c-primary-lt);
            color: var(--c-primary);
        }

.ermes-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.user-name {
    font-weight: 600;
}

.user-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--c-primary-lt);
    color: var(--c-primary);
    padding: 2px 8px;
    border-radius: 12px;
}

.ermes-main {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.ermes-main--noauth {
    max-width: 100%;
    padding: 0;
}

/* ─── Page header ────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

    .page-header h1 {
        font-size: 22px;
        font-weight: 700;
    }

.header-actions {
    display: flex;
    gap: 8px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0 12px;
}

    .section-header h2 {
        font-size: 16px;
        font-weight: 600;
    }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, opacity .15s;
    text-decoration: none;
}

    .btn:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.btn-primary {
    background: var(--c-primary);
    color: #fff;
}

    .btn-primary:hover:not(:disabled) {
        background: var(--c-primary-dk);
    }

.btn-secondary {
    background: var(--c-primary-lt);
    color: var(--c-primary);
}

    .btn-secondary:hover:not(:disabled) {
        background: #c8d9e5;
    }

.btn-danger {
    background: #fee2e2;
    color: var(--c-danger);
}

    .btn-danger:hover:not(:disabled) {
        background: #fecaca;
    }

.btn-ghost {
    background: transparent;
    color: var(--c-text-muted);
    border: 1px solid var(--c-border);
}

    .btn-ghost:hover:not(:disabled) {
        background: var(--c-bg);
    }

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-link {
    background: none;
    border: none;
    color: var(--c-primary);
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    opacity: .6;
    transition: opacity .15s;
}

    .btn-icon:hover {
        opacity: 1;
        background: var(--c-bg);
    }

.btn-logout {
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--c-border);
    background: var(--c-bg);
    cursor: pointer;
    font-size: 12px;
    color: var(--c-text-muted);
}

    .btn-logout:hover {
        background: #fee2e2;
        color: var(--c-danger);
        border-color: #fecaca;
    }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .form-group label {
        font-size: 12px;
        font-weight: 600;
        color: var(--c-text-muted);
        text-transform: uppercase;
        letter-spacing: .5px;
    }

.form-control {
    padding: 8px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--c-surface);
    color: var(--c-text);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}

    .form-control:focus {
        outline: none;
        border-color: var(--c-primary);
        box-shadow: 0 0 0 3px rgba(67,97,238,.12);
    }

    .form-control:disabled {
        background: var(--c-bg);
        color: var(--c-text-muted);
    }

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 11px;
    color: var(--c-text-muted);
    margin-top: 2px;
}

.form-label-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

    .form-label-check input {
        width: 16px;
        height: 16px;
        accent-color: var(--c-primary);
    }

.required {
    color: var(--c-danger);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

/* ─── Filtri bar ─────────────────────────────────────────── */
.filtri-bar {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.filtri-row {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

.form-group--sm {
    min-width: 130px;
}

.check-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding-top: 4px;
}

.check-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    white-space: nowrap;
}

.filtri-actions {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    padding-top: 20px;
}

/* ─── Tabella ─────────────────────────────────────────────── */
.table-wrapper {
    position: relative;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table-summary {
    font-size: 12px;
    color: var(--c-text-muted);
    margin-bottom: 8px;
    padding-left: 2px;
}

.table-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url('img/Completo.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 50% auto;
    opacity: 0.025;
    pointer-events: none;
    z-index: 0;
}

.ermes-table {
    position: relative;
    z-index: 1;
    width: 100%;
    border-collapse: collapse;
}

    .ermes-table th {
        background: var(--c-bg);
        text-align: left;
        padding: 9px 12px;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .5px;
        color: var(--c-text-muted);
        border-bottom: 1px solid var(--c-border);
    }

    .ermes-table td {
        padding: 10px 12px;
        border-bottom: 1px solid var(--c-border);
        vertical-align: middle;
    }

    .ermes-table tbody tr:last-child td {
        border-bottom: none;
    }

    .ermes-table tbody tr:hover {
        background: #f9fafb;
    }

.ermes-table--sm td, .ermes-table--sm th {
    padding: 7px 10px;
    font-size: 13px;
}

.col-id {
    width: 52px;
    color: var(--c-text-muted);
    font-size: 12px;
}

.col-data {
    width: 80px;
    white-space: nowrap;
}

.col-actions {
    width: 40px;
    text-align: right;
}

.col-descrizione {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-right {
    text-align: right;
}

.text-mono {
    font-family: var(--font-mono);
    font-size: 12px;
}

/* Righe con stato */
.row-chiusa td {
    color: var(--c-text-muted);
}

.row-annullata td {
    color: var(--c-text-muted);
    text-decoration: line-through;
}

/* Cliente nella lista */
.cliente-nome {
    display: block;
}

.cliente-fatt {
    display: block;
    font-size: 11px;
    color: var(--c-text-muted);
}

/* ─── Badge ──────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-tipo {
    background: #f0f0f0;
    color: #444;
}

.badge-aperta {
    background: #dbeafe;
    color: var(--c-aperta);
}

.badge-lavorazione {
    background: #ede9fe;
    color: var(--c-lavorazione);
}

.badge-attesa {
    background: #fef3c7;
    color: #b45309;
}

.badge-chiusa {
    background: #f3f4f6;
    color: var(--c-chiusa);
}

.badge-annullata {
    background: #fee2e2;
    color: var(--c-annullata);
}

.badge-direzionale {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-finale {
    background: #f0fdf4;
    color: #15803d;
}

/* ─── Form section title ─────────────────────────────────── */
.form-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--c-text-muted);
    border-bottom: 1px solid var(--c-border);
    padding-bottom: 6px;
    margin: 20px 0 14px;
}

    .form-section-title:first-of-type {
        margin-top: 0;
    }

.form-group--wide {
    grid-column: span 2;
}

.form-checks {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

/* ─── LookupLabel ────────────────────────────────────────── */
.lookup-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

.lookup-label__link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-primary);
    text-transform: uppercase;
    letter-spacing: .5px;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-style: dashed;
    transition: color .15s;
}

    .lookup-label__link:hover {
        color: var(--c-primary-dk);
    }

.lookup-label__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--c-primary);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    font-weight: 700;
}

/* ─── Modal header ───────────────────────────────────────── */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--c-text-muted);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

    .modal-close:hover {
        background: var(--c-bg);
        color: var(--c-text);
    }

/* ─── Card ───────────────────────────────────────────────── */
.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card--form {
    max-width: 720px;
}

.card--dettaglio {
    margin-bottom: 4px;
}

/* ─── Dettaglio ──────────────────────────────────────────── */
.dettaglio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.dettaglio-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.field-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--c-text-muted);
}

.field-value {
    font-size: 14px;
    font-weight: 500;
}

.field-sub {
    font-size: 12px;
    color: var(--c-text-muted);
    margin-top: 1px;
}

.field-link {
    color: var(--c-primary);
    text-decoration: none;
    font-weight: 500;
}

.field-link:hover {
    text-decoration: underline;
}

.field-value-with-action {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dettaglio-descrizione, .dettaglio-note {
    border-top: 1px solid var(--c-border);
    padding-top: 14px;
    margin-top: 4px;
}

    .dettaglio-descrizione p, .dettaglio-note p {
        margin-top: 6px;
        white-space: pre-wrap;
        line-height: 1.6;
    }

.dettaglio-note {
    background: #fffbeb;
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 12px;
}

/* ─── Alert ──────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ─── Empty / Loading ────────────────────────────────────── */
.empty-state {
    text-align: center;
    color: var(--c-text-muted);
    padding: 48px 24px;
    font-size: 14px;
}

.loading {
    text-align: center;
    color: var(--c-text-muted);
    padding: 32px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

    50% {
        opacity: .4;
    }
}

/* ─── Minuti preview ─────────────────────────────────────── */
.minuti-preview {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-bottom: 12px;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: var(--c-surface);
    border-radius: var(--radius);
    padding: 24px;
    width: 380px;
    max-width: 95vw;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-box--lg {
    width: 520px;
}

.modal-box h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.confirm-message {
    color: var(--c-text-muted);
    line-height: 1.5;
    margin: 0;
}

/* ─── Login ──────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--c-primary-lt) 0%, #f5f6fa 100%);
    padding: 24px;
}

.login-card {
    position: relative;
    overflow: hidden;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 36px 32px;
    width: 360px;
    max-width: 100%;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-card-bg {
    position: absolute;
    bottom: -8px;
    right: -12px;
    height: 60px;
    object-fit: contain;
    opacity: 0.10;
    pointer-events: none;
    user-select: none;
}

.login-brand {
    text-align: center;
    margin-bottom: 4px;
}

.login-logo {
    height: 120px;
    object-fit: contain;
    display: block;
    margin: 0 auto 8px;
}

/* ─── Anagrafiche ────────────────────────────────────────── */
.card--section {
    margin-bottom: 24px;
}

.inline-form {
    border-top: 1px solid var(--c-border);
    margin-top: 16px;
    padding-top: 16px;
}

.inline-form h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 12px;
    color: var(--c-primary);
}

.form-grid--2col {
    grid-template-columns: 2fr 1fr;
}

.form-grid--3col {
    grid-template-columns: 2fr 1fr 2fr;
}

.row-inattivo td {
    opacity: 0.45;
}

.btn-icon--danger {
    color: #b91c1c;
}

.btn-icon--ok {
    color: #065f46;
}
