@charset "UTF-8";

/* =========================================
 * FONTS & BASE
 * ========================================= */
body {
    font-family: 'Inter', sans-serif;
}

/* =========================================
 * ACCORDION (PRIMA NOTA / FATTURE)
 * ========================================= */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease-out;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-bottom: 1px solid #e5e7eb;
}

.accordion-content.open {
    max-height: 1500px;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

.accordion-toggle {
    background-color: #f9fafb; /* gray-50 */
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    font-weight: 600;
    color: #1f2937;
    transition: all 0.2s ease-out;
}

.accordion-toggle:hover {
    background-color: #f3f4f6;
}

.accordion-toggle.open {
    background-color: #4f46e5 !important; /* indigo-600 */
    color: white !important;
    border-color: #4f46e5 !important;
}

.accordion-icon {
    font-size: 1.5rem;
    font-weight: 300;
    transition: transform 0.3s ease-out;
}

.accordion-toggle.open .accordion-icon {
    transform: rotate(45deg);
}

/* =========================================
 * SCROLLBAR CUSTOM (SIDEBAR DOCK & ROLODEX)
 * ========================================= */
.sidebar-dock, .rolodex-sidebar, .rolodex-content-scroll {
    scrollbar-width: thin;
    scrollbar-color: #4A5568 #f3f4f6;
}

.sidebar-dock::-webkit-scrollbar, .rolodex-sidebar::-webkit-scrollbar, .rolodex-content-scroll::-webkit-scrollbar {
    width: 8px;
}

.sidebar-dock::-webkit-scrollbar-track {
    background: #0f172a;
    border-radius: 10px;
}

.rolodex-sidebar::-webkit-scrollbar-track, .rolodex-content-scroll::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.sidebar-dock::-webkit-scrollbar-thumb {
    background-color: #4A5568;
    border-radius: 10px;
    border: 2px solid #0f172a;
}

.rolodex-sidebar::-webkit-scrollbar-thumb, .rolodex-content-scroll::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

/* =========================================
 * CALCOLATRICE WIDGET
 * ========================================= */
.calc-btn:active {
    transform: translateY(1px);
    filter: brightness(0.9);
}

/* =========================================
 * SCHEDARIO (ROLODEX) STYLE
 * ========================================= */
.rolodex-layout {
    display: flex;
    height: calc(100vh - 220px);
    overflow: hidden;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
}

.rolodex-sidebar {
    width: 30%;
    min-width: 250px;
    max-width: 350px;
    overflow-y: auto;
    padding: 10px;
    background-color: #e2e8f0;
    border-right: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.rolodex-card-tab {
    position: relative;
    background: white;
    padding: 15px;
    margin-bottom: -5px;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
    border: 1px solid #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    z-index: 1;
    border-left-width: 6px;
}

.rolodex-card-tab:hover {
    transform: translateX(5px);
    z-index: 10;
    box-shadow: -2px -2px 8px rgba(0,0,0,0.1);
}

.rolodex-card-tab.active {
    z-index: 20;
    background-color: #fff;
    transform: translateX(10px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-bottom: 10px;
    margin-top: 5px;
    font-weight: bold;
}

.rolodex-card-tab.type-cliente { border-left-color: #2563eb; }
.rolodex-card-tab.type-fornitore { border-left-color: #dc2626; }

.rolodex-detail-panel {
    flex: 1;
    padding: 0;
    overflow: hidden;
    background-color: white;
    display: flex;
    flex-direction: column;
}

.rolodex-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #94a3b8;
    text-align: center;
}

.rolodex-placeholder span {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* =========================================
 * MODALI & POPUP
 * ========================================= */
.modal {
    display: none;
    position: fixed;
    z-index: 50;
    left: 16rem;
    top: 0;
    width: calc(100% - 16rem);
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal[style*="display: block"],
.modal[style*="display: flex"] {
    display: flex !important;
}

.modal-content {
    background-color: #fefefe;
    position: relative;
    margin: 0;
    padding: 1.5rem;
    border-radius: 8px;
    width: 95%;
    max-width: 1000px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 95vh;
    overflow-y: auto;
}

.modal-close {
    position: sticky;
    top: 0;
    float: right;
    width: 32px;
    height: 32px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background-color 0.2s, transform 0.1s;
    z-index: 100;
    line-height: 1;
    border: 2px solid white;
    margin-bottom: -32px;
    margin-right: -10px;
    margin-top: -10px;
}

.modal-close:hover {
    background-color: #dc2626;
    transform: scale(1.1);
}

/* =========================================
 * BACKUP REMINDER MODAL
 * ========================================= */
.dimmed-background {
    opacity: 0.3 !important;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
}

#backup-reminder-modal .modal-content {
width: 60% !important;
max-width: 60% !important;
min-height: 300px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: relative;
top: auto;
margin: 0;
}

/* =========================================
 * ELEMENTI UI VARI
 * ========================================= */
#autocomplete-list {
border: 1px solid #e5e7eb;
border-top: none;
max-height: 150px;
overflow-y: auto;
position: absolute;
background: white;
z-index: 10;
width: 100%;
}

#autocomplete-list div {
padding: 8px 12px;
cursor: pointer;
}

#autocomplete-list div:hover {
background-color: #f3f4f6;
}

.inline-editor {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.inline-editor input {
    flex-grow: 1;
    min-width: 100px;
}

button:disabled,
input:disabled,
select:disabled,
fieldset:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #f3f4f6;
}

.report-btn {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: 0.5rem;
    transition: transform 0.1s, box-shadow 0.1s;
    background-color: #f3f4f6;
    cursor: pointer;
}

.report-btn:hover {
    transform: translateY(-2px);
    background-color: #e5e7eb;
}

.report-btn span {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* =========================================
 * ANIMAZIONI
 * ========================================= */
@keyframes pulse-negative {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.7; }
}

.pulse-negative {
    animation: pulse-negative 1s ease-in-out infinite;
    display: inline-block;
}

@keyframes blink-border {
    0%, 100% { opacity: 1; box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); }
    50% { opacity: 0.8; box-shadow: 0 0 15px rgba(255, 255, 255, 0.8) inset; }
}

.blink-active {
    animation: blink-border 2s infinite;
    border: 2px solid white !important;
    position: relative;
    z-index: 10;
}

@keyframes highlight-row-pulse {
    0%, 100% { background-color: #fef3c7; }
    50% { background-color: #fcd34d; }
}

.highlight-row {
    animation: highlight-row-pulse 1s ease-in-out 3;
}

/* =========================================
 * TOAST MESSAGE (RIPRISTINO BOTTOM-RIGHT)
 * ========================================= */
#toast-message {
/* Tailwind classes gestiscono il posizionamento (bottom-5 right-5) */
/* Nessun override necessario qui se vogliamo il default */
}

/* =========================================
 * MODERN TABLES & BADGES
 * ========================================= */
.sticky-header th {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: #f9fafb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid transparent;
}

/* =========================================
 * SPLASH SCREEN FX
 * ========================================= */
.splash-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #0f172a;
    overflow: hidden;
    z-index: 99999;
}

.aurora-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float 15s infinite alternate ease-in-out;
}

.blob-1 { top: -10%; left: -10%; width: 50vw; height: 50vw; background: #4f46e5; animation-delay: 0s; }
.blob-2 { bottom: -10%; right: -10%; width: 60vw; height: 60vw; background: #7c3aed; animation-delay: -5s; }
.blob-3 { top: 40%; left: 40%; width: 40vw; height: 40vw; background: #06b6d4; animation-delay: -10s; filter: blur(60px); opacity: 0.3; }

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

.glass-panel {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.abstract-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #4f46e5, #ec4899);
    border-radius: 20px;
    transform: rotate(45deg);
    position: relative;
    box-shadow: 0 0 30px rgba(79, 70, 229, 0.6);
    animation: logo-pulse 3s infinite ease-in-out;
}

.abstract-logo::after {
    content: '';
    position: absolute;
    inset: 10px;
    background: #0f172a;
    border-radius: 12px;
}

.abstract-logo-inner {
    position: absolute;
    inset: 25px;
    background: white;
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 0 15px white;
    animation: inner-pulse 3s infinite ease-in-out;
}

@keyframes logo-pulse {
    0%, 100% { box-shadow: 0 0 30px rgba(79, 70, 229, 0.6); transform: rotate(45deg) scale(1); }
    50% { box-shadow: 0 0 60px rgba(236, 72, 153, 0.8); transform: rotate(45deg) scale(1.05); }
}

@keyframes inner-pulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

.modern-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
}

/* =========================================
 * TILE SELECTION FX
 * ========================================= */
@keyframes border-pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); border-color: #16a34a; transform: scale(1); }
    50% { box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2); border-color: #22c55e; transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); border-color: #16a34a; transform: scale(1); }
}

@keyframes border-pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); border-color: #dc2626; transform: scale(1); }
    50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2); border-color: #ef4444; transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); border-color: #dc2626; transform: scale(1); }
}

@keyframes border-pulse-yellow {
    0% { box-shadow: 0 0 0 0 rgba(202, 138, 4, 0.4); border-color: #ca8a04; transform: scale(1); }
    50% { box-shadow: 0 0 0 4px rgba(202, 138, 4, 0.2); border-color: #eab308; transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(202, 138, 4, 0.4); border-color: #ca8a04; transform: scale(1); }
}

.tile-active-green {
    animation: border-pulse-green 2s infinite;
    background-color: #dcfce7 !important;
    z-index: 10;
}

.tile-active-red {
    animation: border-pulse-red 2s infinite;
    background-color: #fee2e2 !important;
    z-index: 10;
}

.tile-active-yellow {
    animation: border-pulse-yellow 2s infinite;
    background-color: #fef9c3 !important;
    z-index: 10;
}

/* =========================================
 * TUTORIAL / TOUR GUIDATO
 * ========================================= */
#tour-overlay {
position: fixed;
top: 0; left: 0; width: 100vw; height: 100vh;
background: transparent;
z-index: 9000;
opacity: 0;
transition: opacity 0.3s ease;
pointer-events: none;
}

#tour-overlay.active {
opacity: 1;
pointer-events: auto;
background: rgba(0,0,0,0.05);
}

.tour-highlighted-element {
    position: relative;
    z-index: 10000 !important;
    box-shadow: 0 0 0 4px #f59e0b, 0 0 0 5000px rgba(0, 0, 0, 0.75) !important;
    border-radius: 4px;
    pointer-events: none;
    transition: box-shadow 0.3s ease-in-out;
}

.tour-parent-elevated {
    z-index: 10001 !important;
}

#tour-tooltip {
position: fixed;
z-index: 10002;
background: white;
padding: 20px;
border-radius: 12px;
width: 480px;
box-shadow: 0 10px 30px rgba(0,0,0,0.5);
opacity: 0;
visibility: hidden;
transition: opacity 0.3s ease, top 0.4s ease, left 0.4s ease;
border-left: 6px solid #f59e0b;
}
#tour-tooltip.active { opacity: 1; visibility: visible; }
#tour-tooltip h3 { margin-top: 0; color: #1f2937; font-weight: 800; font-size: 1.1rem; margin-bottom: 8px; }
#tour-tooltip p { color: #4b5563; font-size: 0.9rem; line-height: 1.5; margin-bottom: 20px; }

#tour-character {
position: fixed; z-index: 10003; pointer-events: none;
transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
filter: drop-shadow(0 5px 15px rgba(0,0,0,0.2));
}
#tour-character.hidden { display: none !important; }

.tour-controls { display: flex; justify-content: space-between; }
.tour-btn { padding: 8px 16px; border-radius: 6px; font-weight: bold; font-size: 0.85rem; cursor: pointer; border: none; }
.tour-btn-skip { background: transparent; color: #9ca3af; }
.tour-btn-skip:hover { color: #6b7280; }
.tour-btn-next { background: #f59e0b; color: white; box-shadow: 0 2px 5px rgba(245, 158, 11, 0.4); }
.tour-btn-next:hover { background: #d97706; transform: translateY(-1px); }

@keyframes attention-pulse-anim {
    0% {
        box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7);
        background-color: rgba(255, 255, 255, 0.05);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(234, 179, 8, 0);
        background-color: rgba(254, 240, 138, 0.2);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(234, 179, 8, 0);
        background-color: rgba(255, 255, 255, 0.05);
    }
}

.attention-pulse {
    animation: attention-pulse-anim 1.5s infinite;
    z-index: 100 !important;
    position: relative;
    border: 2px solid #eab308 !important;
    color: #eab308 !important;
}

/* =========================================
 * STILE TOGGLE TAX SIDEBAR
 * ========================================= */
.sidebar-toggle-btn {
    opacity: 0.5;
    filter: grayscale(100%);
    transition: all 0.3s ease;
}

.sidebar-toggle-btn.active {
    opacity: 1;
    filter: grayscale(0%);
    box-shadow: 0 0 10px rgba(234, 179, 8, 0.5);
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-toggle-btn:hover {
    opacity: 0.8;
}

/* =========================================
 * CHART & GRAPHICS
 * ========================================= */
canvas {
    /* Migliora l'esperienza di click sui grafici */
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* =========================================
 * VALIDAZIONE UX (ERROR HIGHLIGHTING)
 * ========================================= */
.input-error {
    border-color: #ef4444 !important;
    border-width: 2px !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15) !important;
    background-color: #fef2f2 !important;
    animation: shake-input 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake-input {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* =========================================
 * RIFINITURE LEGGIBILITÀ INPUT
 * ========================================= */
input, select, textarea {
    padding-left: 0.4rem !important;
    padding-right: 0.4rem !important;
}

/* Testo non troncato ma visibile il più possibile */
input {
    text-overflow: clip !important;
}

/* Ottimizzazione specifica per campi tecnici/piccoli */
input[type="number"],
.font-mono,
[id*="tax-rate"],
[id*="ritenuta"],
[id*="percent"] {
    letter-spacing: -0.025em !important;
    font-variant-numeric: tabular-nums;
}

/* =========================================
 * OVERRIDE "CORAZZA" PER VISIBILITÀ CAMPI
 * (Bypass Griglie Tailwind)
 * ========================================= */

/* Allargamento forzato Descrizione Fattura */
[id="invoice-description"] {
    min-width: 300px !important;
    width: 100% !important;
}

/* Sblocco contenitore Descrizione per evitare troncamenti esterni */
[id="invoice-description"]-parent,
[id="invoice-description"]-wrapper,
[id="invoice-description"] + div,
[id="invoice-description"] {
    max-width: none !important;
    overflow: visible !important;
}

/* Allargamento forzato Ritenuta d'Acconto */
[id="invoice-withholding-rate"],
[id="cn-withholding-rate"],
[id*="ritenuta-pct"] {
    min-width: 80px !important;
    width: 90px !important;
    font-weight: 800 !important;
}

/* Forza la visualizzazione del testo completo negli input di descrizione manuale */
[id="manual-description"] {
    min-width: 350px !important;
    width: 100% !important;
}

/* Sblocco delle celle della griglia che contengono questi ID */
#modal-new-invoice .grid > div:has(> #invoice-description) {
    grid-column: span 8 / span 8 !important; /* Espande la colonna nella griglia Tailwind */
}

/* =========================================
 * PRINT OPTIMIZATION
 * ========================================= */
@media print {
    html, body {
        height: auto !important;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    #main-container, .flex-1 {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
    flex: none !important;
    width: 100% !important;
    }

    nav,
    #splash-screen,
    .no-print,
    .rolodex-sidebar,
    .modal,
    header,
    ::-webkit-scrollbar,
    #tour-overlay,
    #tour-tooltip,
    #tour-character,
    #tour-start-modal {
    display: none !important;
    }

    .section-content.hidden {
        display: none !important;
    }

    .section-content:not(.hidden) {
        display: block !important;
        visibility: visible !important;
        height: auto !important;
        overflow: visible !important;
    }

    canvas {
        max-width: 100% !important;
        max-height: 400px !important;
        page-break-inside: avoid;
    }

    table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    tr, td, th {
        page-break-inside: avoid;
    }

    .bg-white.rounded.shadow.p-4 {
        page-break-inside: auto;
        margin-bottom: 20px;
        border: 1px solid #eee;
        box-shadow: none !important;
    }

    h2, h3, h4 {
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    .grid, .chart-container {
        page-break-inside: avoid;
    }

    .smart-report-page {
        page-break-after: always;
        display: block !important;
        margin-top: 20px;
    }

    .print-break-before {
        page-break-before: always;
        break-before: page;
        margin-top: 2rem;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
