/* File: frontend/html/css/previsione.css */
/* CSS FORZATO CON MASSIMA PRIORITÀ - VERSIONE ESTETICA MIGLIORATA */

/* RESET COMPLETO TABELLA */
#previsione table,
#previsione .previsione-table,
table.previsione-table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    font-size: 0.85rem !important;
}

/* FORZATURA HEADER E CELLE */
#previsione table th,
#previsione table td,
#previsione .previsione-table th,
#previsione .previsione-table td,
table.previsione-table th,
table.previsione-table td {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
    padding: 0.4rem 0.15rem !important;
    text-align: center !important;
}

/* COLONNA TIPOLOGIA - PIÙ LARGA */
#previsione table th:first-child,
#previsione table td:first-child,
#previsione .previsione-table th:first-child,
#previsione .previsione-table td:first-child,
table.previsione-table th:first-child,
table.previsione-table td:first-child {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    text-align: left !important;
    background: #f8f9fa !important;
    position: sticky !important;
    left: 0 !important;
    z-index: 5 !important;
    padding-left: 0.5rem !important;
}

/* COLONNA AZIONI */
#previsione table th:last-child,
#previsione table td:last-child,
#previsione .previsione-table th:last-child,
#previsione .previsione-table td:last-child,
table.previsione-table th:last-child,
table.previsione-table td:last-child {
    width: 60px !important;
    min-width: 60px !important;
    max-width: 60px !important;
}

/* COLONNE MESI - PIÙ STRETTE */
#previsione table th:not(:first-child):not(:last-child),
#previsione table td:not(:first-child):not(:last-child),
#previsione .previsione-table th:not(:first-child):not(:last-child),
#previsione .previsione-table td:not(:first-child):not(:last-child),
table.previsione-table th:not(:first-child):not(:last-child),
table.previsione-table td:not(:first-child):not(:last-child) {
    width: auto !important;
    min-width: 60px !important;
}

/* HEADERS SPECIFICI */
#previsione table thead th,
#previsione .previsione-table thead th,
table.previsione-table thead th {
    background: #2c3e50 !important;
    color: white !important;
    font-size: 0.8rem !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
}

#previsione table thead th:first-child,
#previsione .previsione-table thead th:first-child,
table.previsione-table thead th:first-child {
    background: #34495e !important;
    z-index: 15 !important;
}

/* INPUT FIELDS */
#previsione input.cell-input,
#previsione .cell-input,
.previsione-table .cell-input {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: center !important;
    padding: 0.2rem !important;
    font-size: 0.8rem !important;
}

#previsione input.row-name-input,
#previsione .row-name-input,
.previsione-table .row-name-input {
    width: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: left !important;
    padding: 0.2rem 0.5rem !important;
    font-size: 0.85rem !important;
}

/* RIMOZIONE SPINNER DA INPUT NUMERICI - SENZA ALTERARE DIMENSIONI */
#previsione input[type="number"],
.previsione-table input[type="number"] {
    -moz-appearance: textfield !important; /* Firefox */
}

#previsione input[type="number"]::-webkit-outer-spin-button,
#previsione input[type="number"]::-webkit-inner-spin-button,
.previsione-table input[type="number"]::-webkit-outer-spin-button,
.previsione-table input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none !important; /* Chrome, Safari, Edge */
    margin: 0 !important;
}

/* STYLING PER INPUT EFFETTIVO CON SIMBOLO € - NASCOSTO COME STIMA */
#previsione .effettivo-cell {
    position: relative !important;
}

#previsione .effettivo-input {
    border: none !important;
    background: transparent !important;
    font-size: inherit !important;
    font-weight: 600 !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    outline: none !important;
    color: #2c3e50 !important;
}

/* Nascondi il simbolo € dal CSS precedente per la riga effettivo */
#previsione .effettivo-cell::before {
    display: none !important;
}

/* LINEA VERTICALE MESE CORRENTE */
#previsione .current-month-line {
    position: relative;
}

#previsione .current-month-line::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #e74c3c;
    z-index: 20;
    box-shadow: 0 0 4px rgba(231, 76, 60, 0.5);
}

/* Alternativa: linea sul border-right del mese precedente */
#previsione .previous-month-line {
    position: relative;
}

#previsione .previous-month-line::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: #e74c3c;
    z-index: 20;
    box-shadow: 0 0 4px rgba(231, 76, 60, 0.5);
}

/* RIGHE SPECIALI - STIMA ED EFFETTIVO CON ALTERNANZA COLORI */
#previsione .stima-row,
.previsione-table .stima-row {
    background-color: #fafafa !important; /* Grigio chiaro alternato */
    font-weight: 600 !important;
}

#previsione .effettivo-row,
.previsione-table .effettivo-row {
    background-color: white !important; /* Bianco alternato */
    font-weight: 600 !important;
}

#previsione .delta-row,
.previsione-table .delta-row {
    background-color: #f8f9fa !important;
    font-weight: 600 !important;
}

#previsione .special-row td,
.previsione-table .special-row td {
    border-top: 1px solid #dee2e6 !important;
}

/* DELTA COLORS */
#previsione .delta-positive,
.previsione-table .delta-positive {
    color: #27ae60 !important;
    background-color: #d5f4e6 !important;
}

#previsione .delta-negative,
.previsione-table .delta-negative {
    color: #e74c3c !important;
    background-color: #fdeaea !important;
}

/* DELTA EMPTY (QUANDO NON C'È EFFETTIVO) */
#previsione .delta-empty,
.previsione-table .delta-empty {
    color: transparent !important;
    background-color: inherit !important;
}

/* ALTERNATING ROWS */
#previsione table tbody tr:nth-child(even):not(.special-row),
#previsione .previsione-table tbody tr:nth-child(even):not(.special-row),
table.previsione-table tbody tr:nth-child(even):not(.special-row) {
    background-color: #fafafa !important;
}

#previsione table tbody tr:nth-child(odd):not(.special-row),
#previsione .previsione-table tbody tr:nth-child(odd):not(.special-row),
table.previsione-table tbody tr:nth-child(odd):not(.special-row) {
    background-color: white !important;
}

/* BOTTONI */
#previsione .remove-row-btn {
    background-color: #e74c3c !important;
    color: white !important;
    border: none !important;
    border-radius: 3px !important;
    padding: 0.2rem 0.4rem !important;
    font-size: 0.75rem !important;
}

/* NUOVO BOTTONE AGGIUNGI RIGA - PICCOLA ICONA */
#previsione .add-row-btn-icon {
    background-color: #95a5a6 !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    width: 30px !important;
    height: 30px !important;
    font-size: 1.2rem !important;
    font-weight: bold !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0.5rem 0 !important;
    transition: background-color 0.2s ease !important;
}

#previsione .add-row-btn-icon:hover {
    background-color: #7f8c8d !important;
}

/* CONTAINER BOTTONE AGGIUNGI */
#previsione .add-row-container {
    display: flex !important;
    justify-content: flex-start !important;
    padding-left: 0.5rem !important;
    background: #f8f9fa !important;
    position: sticky !important;
    left: 0 !important;
    z-index: 5 !important;
}

/* CONTAINER */
#previsione .previsione-table-container {
    overflow-x: auto !important;
    margin-bottom: 1rem !important;
}

/* STILE AZZURRINO INVECE DI VERDE */
#previsione .add-row-tr-old {
    border-top: 2px solid #3498db !important;
}

#previsione .add-row-tr-old td {
    background-color: #e8f4fd !important;
    padding: 1rem !important;
}

/* MOBILE */
@media (max-width: 768px) {
    #previsione table th:first-child,
    #previsione table td:first-child,
    #previsione .previsione-table th:first-child,
    #previsione .previsione-table td:first-child {
        width: 160px !important;
        min-width: 160px !important;
        max-width: 160px !important;
    }
    
    #previsione table th:last-child,
    #previsione table td:last-child,
    #previsione .previsione-table th:last-child,
    #previsione .previsione-table td:last-child {
        width: 50px !important;
        min-width: 50px !important;
        max-width: 50px !important;
    }
    
    #previsione table th:not(:first-child):not(:last-child),
    #previsione table td:not(:first-child):not(:last-child),
    #previsione .previsione-table th:not(:first-child):not(:last-child),
    #previsione .previsione-table td:not(:first-child):not(:last-child) {
        min-width: 50px !important;
    }
}