/* =========================================================
   Codice Fiscale Inverso — Tool Styles
   Matches site dark theme: #0A1628 bg, #4A9EFF accent
   ========================================================= */

/* --- Wrap --- */
.cfi-wrap {
    background: #071020;
    border: 1px solid #1A2E4A;
    border-radius: 14px;
    padding: 36px 32px 24px;
    max-width: 780px;
    margin: 0 auto 32px;
    font-family: 'Source Sans Pro', 'Segoe UI', sans-serif;
    color: #94B8E0;
}

/* --- Label --- */
.cfi-label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #4A9EFF;
    margin-bottom: 10px;
}

/* --- Input Row --- */
.cfi-input-row {
    display: flex;
    gap: 10px;
}

.cfi-input {
    flex: 1;
    background: #0A1628;
    border: 2px solid #1A2E4A;
    border-radius: 8px;
    padding: 14px 18px;
    font-size: 22px;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 4px;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s;
}

.cfi-input:focus {
    border-color: #4A9EFF;
    box-shadow: 0 0 0 3px rgba(74,158,255,0.12);
}

.cfi-input::placeholder {
    color: #2A4A6A;
    font-size: 16px;
    letter-spacing: 2px;
}

.cfi-btn {
    background: #4A9EFF;
    color: #FFFFFF;
    border: none;
    border-radius: 8px;
    padding: 0 28px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, transform 0.1s;
    min-width: 130px;
}

.cfi-btn:hover { background: #3A8EEF; }
.cfi-btn:active { transform: scale(0.98); }
.cfi-btn:disabled { background: #1A3A6B; color: #5A7A9A; cursor: not-allowed; }

.cfi-btn-spinner {
    display: inline-block;
    animation: cfi-spin 0.8s linear infinite;
    font-size: 18px;
}

@keyframes cfi-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.cfi-hint {
    font-size: 12px;
    color: #3A5A7A;
    margin: 8px 0 0;
}

/* --- Character visualizer --- */
.cfi-chars-row {
    display: flex;
    gap: 4px;
    margin: 24px 0 0;
    flex-wrap: wrap;
    justify-content: center;
}

.cfi-char-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 36px;
}

.cfi-char-block .cfi-char {
    width: 36px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    color: #0A1628;
    border: 1px solid rgba(0,0,0,0.2);
}

.cfi-char-block .cfi-char-pos {
    font-size: 10px;
    color: #3A5A7A;
    font-weight: 600;
}

/* --- Divider --- */
.cfi-chars-divider {
    width: 1px;
    height: 44px;
    background: #1A2E4A;
    align-self: center;
    margin: 0 2px;
}

/* --- Result box --- */
.cfi-result {
    margin-top: 28px;
    border-top: 1px solid #1A2E4A;
    padding-top: 28px;
}

/* Omocodia badge */
.cfi-badge-omocod {
    display: inline-block;
    background: rgba(245,158,11,0.12);
    color: #F59E0B;
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 12px;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

/* Result grid */
.cfi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.cfi-field {
    background: #0A1628;
    border: 1px solid #1A2E4A;
    border-radius: 10px;
    padding: 16px 18px;
    transition: border-color 0.2s;
}

.cfi-field:hover { border-color: #2A4A6A; }

.cfi-field-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #4A7A9A;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cfi-field-label .cfi-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cfi-field-value {
    font-size: 20px;
    font-weight: 700;
    color: #FFFFFF;
    line-height: 1.2;
}

.cfi-field-sub {
    font-size: 12px;
    color: #5A7A9A;
    margin-top: 3px;
}

/* Exact vs stima */
.cfi-field.esatta { border-left: 3px solid #22C55E; }
.cfi-field.stima  { border-left: 3px solid #F59E0B; }

/* Special highlight for data nascita */
.cfi-field.highlight {
    background: rgba(74,158,255,0.06);
    border-color: rgba(74,158,255,0.3);
    border-left: 3px solid #4A9EFF;
}

/* Luogo full-width */
.cfi-field.full { grid-column: 1 / -1; }

/* --- Struttura block --- */
.cfi-struttura {
    background: #040C18;
    border: 1px solid #1A2E4A;
    border-radius: 10px;
    padding: 18px 20px;
    margin-top: 16px;
}

.cfi-struttura-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #3A5A7A;
    margin-bottom: 12px;
}

.cfi-struttura-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}

.cfi-seg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.cfi-seg-chars {
    font-family: 'Courier New', monospace;
    font-size: 17px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 6px;
    color: #0A1628;
    letter-spacing: 2px;
    white-space: nowrap;
}

.cfi-seg-label {
    font-size: 10px;
    color: #4A7A9A;
    text-align: center;
    max-width: 80px;
    line-height: 1.3;
}

.cfi-seg-divider {
    width: 1px;
    height: 32px;
    background: #1A2E4A;
    align-self: center;
    margin: 0 2px;
}

/* --- Affidabilità legend --- */
.cfi-legend {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.cfi-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #5A7A9A;
}

.cfi-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* --- Privacy note --- */
.cfi-privacy-note {
    background: rgba(74,158,255,0.05);
    border: 1px solid rgba(74,158,255,0.15);
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 16px;
    font-size: 13px;
    color: #5A7A9A;
    line-height: 1.6;
}

/* --- Error --- */
.cfi-error {
    background: rgba(239,68,68,0.07);
    border: 1px solid rgba(239,68,68,0.25);
    border-radius: 10px;
    padding: 16px 20px;
    margin-top: 16px;
    color: #FCA5A5;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.cfi-error-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* --- Disclaimer --- */
.cfi-disclaimer {
    font-size: 12px;
    color: #2A4A6A;
    text-align: center;
    margin-top: 20px;
    line-height: 1.6;
}

.cfi-disclaimer a {
    color: #3A6A9A;
    text-decoration: none;
}

.cfi-disclaimer a:hover { color: #4A9EFF; }

/* --- Light theme override --- */
.cfi-wrap[data-theme="light"] {
    background: #FFFFFF;
    border-color: #E2EAF4;
    color: #4A6A8A;
}

.cfi-wrap[data-theme="light"] .cfi-input {
    background: #F6F9FC;
    border-color: #D0DCE8;
    color: #0A1628;
}

.cfi-wrap[data-theme="light"] .cfi-field {
    background: #F6F9FC;
    border-color: #D0DCE8;
}

.cfi-wrap[data-theme="light"] .cfi-field-value { color: #0A1628; }

.cfi-wrap[data-theme="light"] .cfi-struttura {
    background: #F0F4F8;
    border-color: #D0DCE8;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .cfi-wrap { padding: 24px 16px 16px; }
    .cfi-input-row { flex-direction: column; }
    .cfi-btn { width: 100%; padding: 14px; }
    .cfi-input { font-size: 18px; letter-spacing: 2px; }
    .cfi-grid { grid-template-columns: 1fr 1fr; }
    .cfi-chars-row { gap: 3px; }
    .cfi-char-block .cfi-char { width: 28px; height: 34px; font-size: 14px; }
}
