/* ══════════════════════════════════════════════════════════
   CROGNOLO — Stylesheet
   DC Software — Ufficio Patenti CRI
   ══════════════════════════════════════════════════════════ */

/* ─── 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: #CC1122;
    --c-primary-dk: #A0000F;
    --c-primary-lt: #FCE8EA;
    --c-danger: #e63946;
    --c-success: #2a9d8f;
    --c-warning: #f4a261;
    --c-aperta: #059669;
    --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 ─────────────────────────────────────────────── */
.crognolo-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.crognolo-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);
}

.crognolo-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.header-logo {
    height: 30px;
    width: auto;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--c-primary);
    letter-spacing: -.3px;
}

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

    .crognolo-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;
    }

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

/* ─── Nav Dropdown ──────────────────────────────────────────── */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--c-text-muted);
    transition: background .15s, color .15s;
}

.nav-dropdown-btn:hover,
.nav-dropdown-btn.active,
.nav-dropdown--open .nav-dropdown-btn {
    background: var(--c-primary-lt);
    color: var(--c-primary);
}

.nav-dropdown-arrow {
    font-size: 10px;
    display: inline-block;
    transition: transform .15s;
}

.nav-dropdown--open .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.nav-dropdown--open .nav-dropdown-menu {
    display: flex;
    flex-direction: column;
}

.nav-dropdown-menu a {
    padding: 9px 16px;
    text-decoration: none;
    color: var(--c-text);
    font-weight: 500;
    font-size: 14px;
    transition: background .12s;
    white-space: nowrap;
}

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

.crognolo-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;
}

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

.crognolo-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: #f5c0c4;
    }

.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(204,17,34,.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;
}

.crognolo-table {
    width: 100%;
    border-collapse: collapse;
}

    .crognolo-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);
    }

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

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

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

.crognolo-table--sm td, .crognolo-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;
}

.row-chiusa td {
    color: var(--c-text-muted);
}

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

/* ─── 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: #d1fae5;
    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);
}

/* ─── 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;
}

/* ─── 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-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);
    }

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

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

/* ─── 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;
}

.card--filters {
    margin-bottom: 16px;
    padding: 16px 20px 12px;
}

/* ─── Filtri ─────────────────────────────────────────────── */
.filter-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    margin-bottom: 10px;
}

    .filter-row:last-child {
        margin-bottom: 0;
        align-items: flex-end;
    }

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

    .filter-group label {
        font-size: 11px;
        font-weight: 600;
        color: var(--c-text-muted);
        text-transform: uppercase;
        letter-spacing: .4px;
        white-space: nowrap;
    }

.filter-group--lg {
    flex: 1.5;
}

.filter-group--check {
    flex: 0 0 auto;
    justify-content: flex-end;
    padding-bottom: 2px;
}

/* ─── 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;
}

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

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

/* ─── 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; }
}

/* ─── 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 {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-top: 4px solid var(--c-primary);
    border-radius: 12px;
    padding: 36px 32px;
    width: 400px;
    max-width: 100%;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.login-logo-img {
    width: 360px;
    height: auto;
    margin-bottom: 16px;
}

.login-logo-text {
    font-size: 26px;
    font-weight: 700;
    color: var(--c-primary);
    letter-spacing: -.5px;
}

.login-logo-sub {
    font-size: 13px;
    color: var(--c-text-muted);
    margin-top: 2px;
}

/* ─── Tipi patente (check list) ──────────────────────────── */
.tipi-patente-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.tipo-patente-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--c-primary-lt);
    color: var(--c-primary);
}

/* ─── Stato richiesta ────────────────────────────────────── */
.badge-visita      { background: #d1fae5; color: #059669; }
.badge-fare-patente { background: #d1fae5; color: #065f46; }
.badge-foglio-rosa  { background: #fce7f3; color: #9d174d; }
.badge-altro        { background: #f3f4f6; color: #374151; }

/* ─── Label link (apre modal al click) ──────────────────── */
.label-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-primary);
    text-transform: uppercase;
    letter-spacing: .5px;
    cursor: pointer;
    text-decoration: underline dotted;
}

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

/* ─── Typeahead ─────────────────────────────────────────── */
.typeahead-wrap {
    position: relative;
}

.typeahead-list {
    position: absolute;
    z-index: 200;
    width: 100%;
    background: #fff;
    border: 1px solid var(--c-border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 220px;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
}

    .typeahead-list li {
        padding: 8px 12px;
        cursor: pointer;
        font-size: 14px;
    }

    .typeahead-list li:hover {
        background: var(--c-primary-lt);
    }

.conducente-info {
    margin-top: 6px;
    padding: 8px 12px;
    background: var(--c-primary-lt);
    border-radius: 4px;
    font-size: 13px;
    color: var(--c-text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

/* ─── Misc ───────────────────────────────────────────────── */
.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;
}
