/* ============================================================
   components.css — Componenti UI riusabili
   Bottoni, form, modali, dropdown, notifiche, badge, import CSV
   ============================================================ */

/* ================================
   LOGIN COMPONENTS
   ================================ */
.button-icon {
    filter: brightness(0) saturate(100%) invert(27%) sepia(11%) saturate(634%) hue-rotate(186deg) brightness(94%) contrast(88%);
    transition: filter 0.2s ease;
}

.login-button:hover .button-icon {
    filter: brightness(0) saturate(100%) invert(100%);
}

.forgot {
    text-align: right;
    font-size: 13px;
    margin-bottom: 12px;
}

.forgot a {
    color: #667eea;
    text-decoration: none;
}

.login-button {
    background: #e5e7eb;
    border: none;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    transition: all 0.2s ease;
    width: 100%;
    margin-bottom: 10px;
}

.login-button:hover {
    background: #475569;
    color: white;
    transform: translateY(-1px);
}

.reset-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

/* ================================
   ACTION BUTTONS
   ================================ */
.action-button {
    background: transparent;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    color: #374151;
    transition: all 0.2s ease;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.action-button:hover {
    background: #475569;
    color: white;
    border-color: #475569;
    transform: translateY(-1px);
}

.action-button span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.action-button svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

.action-tooltip {
    position: fixed;
    background: #1e293b;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 21000;
    pointer-events: none;
}

.action-tooltip::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #1e293b;
}

.top-menu .action-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
}

/* ================================
   ACCOUNT MENU
   ================================ */
.account-menu {
    position: relative;
}

.account-btn {
    width: 40px;
    height: 40px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.account-btn:hover {
    background: #b91c1c;
    transform: scale(1.05);
}

/* ================================
   DROPDOWN MENUS
   ================================ */
.menu-dropdown {
    position: absolute;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    z-index: 1000;
    display: none;
    margin-top: 8px;
}

.menu-dropdown.show {
    display: block;
}

.section-dropdown {
    top: 100%;
    left: 0;
    min-width: 250px;
}

.dropdown-menu {
    top: 100%;
    right: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 14px;
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
    color: #374151;
}

.dropdown-item-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dropdown-item:hover {
    background: #f8fafc;
    color: #000;
}

.dropdown-header {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease, color 0.2s ease;
}

.dropdown-header:hover {
    background: #f8fafc;
    color: #64748b;
}

.dropdown-header:not(:first-child) {
    margin-top: 4px;
    border-top: 1px solid #e2e8f0;
    padding-top: 8px;
}

.dropdown-submenu {
    top: 0;
    left: 100%;
    margin-top: 0;
    margin-left: 4px;
    min-width: 250px;
}

/* ================================
   MODALS - Sistema base
   ================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    max-height: 85vh;
}

.modal-content.modal-flex {
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.modal-content.modal-lg {
    max-width: 800px;
}

.modal-header {
    flex-shrink: 0;
    margin-bottom: 20px;
}

.modal-body {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 20px;
    min-height: 0;
}

.modal-footer {
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 0;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.modal-flex .action-button {
    border-radius: 50%;
    position: relative;
    z-index: 20050;
}

.modal-flex .action-button .action-tooltip {
    z-index: 21000;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* ================================
   FORM FIELDS
   ================================ */
.modal-field {
    margin-bottom: 20px;
}

.modal-field-label {
    display: block;
    margin-bottom: 12px;
    font-weight: 700;
    color: #1e293b;
    font-size: 16px;
    text-align: left;
}

.modal-field-input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    font-size: 15px;
    transition: border-color 0.2s ease;
}

.modal-field-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.modal-field-with-button {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.modal-field-with-button .modal-field-input {
    flex: 1;
}

.modal-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.modal-section-title {
    font-weight: 600;
    color: #374151;
    font-size: 18px;
    margin: 0;
}

.modal-table-container {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.modal-table-small {
    height: 180px;
    min-height: 180px;
    max-height: 180px;
}

.filter-section {
    flex-shrink: 0;
    padding: 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.table-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#aziendaTable,
#scenarioTable,
#balReTable,
#balReAssignTable,
#balReAccountsTable,
#balReMonthlyCostsTable,
#balParamsCalcFunctionsTable,
#balParamsCdcTypesTable,
#balParamsDriverTypesTable,
#balParamsReTypesTable,
#balParamsAbsorptionMethodsTable,
#balParamsParametersTable,
#balParamsAccountsTable,
#balParamsCostItemsTable,
#balRepartiTable,
#balWorkflowTable,
#balCicliCycleParamsTable,
#balCicliMinBatchesTable,
#balCicliTaskMapTable,
#balConfigurationsTable,
#auditLoginTable {
    flex: 1;
    height: 100%;
}

.section-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 128px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* ================================
   BUTTONS
   ================================ */
.btn {
    padding: 12px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-width: 100px;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.btn-danger {
    background: #e5e7eb;
    color: #374151;
}

.btn-danger:hover {
    background: #dc2626;
    color: white;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #475569;
    color: white;
    transform: translateY(-1px);
}

.modal-btn {
    background: #e5e7eb;
    color: #374151;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 80px;
}

.modal-btn.red_hover:hover {
    background: #dc2626;
    color: white;
    transform: translateY(-1px);
}

.modal-btn.green_hover:hover {
    background: #10b981;
    color: white;
    transform: translateY(-1px);
}

.modal-btn:hover:not(.red_hover):not(.green_hover) {
    background: #6b7280;
    color: white;
    transform: translateY(-1px);
}

/* ================================
   STATUS BADGES + TABLE ACTIONS
   ================================ */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
    cursor: pointer;
    transition: all 0.2s ease;
}

.status-badge.active {
    background: #dcfce7;
    color: #475569;
}

.status-badge.active:hover {
    background: #166534;
    color: #ffffff;
}

.status-badge.inactive {
    background: #fee2e2;
    color: #475569;
}

.status-badge.inactive:hover {
    background: #dc2626;
    color: #ffffff;
}

.action-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.action-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    background: transparent;
    color: #475569;
}

.action-btn:hover {
    background: #475569;
    color: #ffffff;
}

.action-btn img {
    width: 16px;
    height: 16px;
    filter: brightness(0) saturate(100%) invert(41%) sepia(17%) saturate(634%) hue-rotate(186deg) brightness(94%) contrast(88%);
    transition: all 0.2s ease;
}

.action-btn:hover img {
    filter: brightness(0) saturate(100%) invert(100%);
}

.cell-detail-text {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.cell-detail-success {
    color: #166534;
}

.cell-detail-danger {
    color: #dc2626;
}

/* ================================
   FORM CONTROLS
   ================================ */
.modal-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
}

.modal-checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.modal-checkbox label {
    margin: 0;
    font-size: 15px;
    font-weight: normal;
    color: #374151;
    cursor: pointer;
}

.modal-select {
    width: 100%;
    padding: 12px 16px;
    padding-right: 40px;
    margin-bottom: 16px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    font-size: 15px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: white;
    background-image: url("../icons/freccia_giu.svg");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    cursor: pointer;
}

.modal-select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.modal-conditional-fields {
    margin-left: 24px;
}

/* ================================
   NOTIFICATION TOAST
   ================================ */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: transparent;
    box-shadow: none;
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    z-index: 3000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    font-size: 14px;
}

.notification.show {
    transform: translateX(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.notification.success {
    background: #10b981;
}

.notification.warning {
    background: #f59e0b;
}

.notification.error {
    background: #dc2626;
}

/* ================================
   IMPORT CSV MODAL
   ================================ */
.import-csv-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

.import-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 16px;
    border: 2px dashed #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
    text-align: center;
}

.import-dropzone:hover,
.import-dropzone.dragover {
    border-color: #10b981;
    background: #f0fdf4;
}

.import-dropzone-icon {
    opacity: 0.35;
}

.import-dropzone-label {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

.import-dropzone-hint {
    font-size: 11px;
    color: #94a3b8;
}

.import-result {
    display: none;
    max-height: 150px;
    overflow-y: auto;
}

.import-summary {
    display: flex;
    gap: 16px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.import-ok {
    color: #166534;
}

.import-error-row {
    font-size: 12px;
    color: #dc2626;
    background: #fef2f2;
    border-radius: 6px;
    padding: 4px 10px;
    margin-bottom: 4px;
    border-left: 3px solid #dc2626;
}