/* ========================================
   assets/css/style.css
   Tema Soft UI per Gestione Fatture
   Colori tenui, angoli arrotondati, ombre morbide
   ======================================== */

/* Variabili globali (facili da modificare) */
:root {
    /* Colori primari */
    --primary-light: #e3f2fd;
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Colori secondari */
    --secondary-light: #f3e8ff;
    --secondary: #9f7aea;

    /* Colori di stato */
    --success: #48bb78;
    --warning: #ecc94b;
    --danger: #f56565;
    --info: #4299e1;

    /* Neutri */
    --white: #ffffff;
    --gray-50: #f7fafc;
    --gray-100: #edf2f7;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #a0aec0;
    --gray-500: #718096;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
    --gray-900: #171923;

    /* Ombre morbide (soft UI) */
    --shadow-sm: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-md: 0 5px 15px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.05);
    --shadow-hover: 0 15px 30px rgba(102, 126, 234, 0.1);

    /* Bordi */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    /* Spaziature */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Font */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;

    /* Transizioni */
    --transition: all 0.2s ease;
}

/* Reset e base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: var(--gray-50);
    color: var(--gray-700);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Tipografia
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--gray-800);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--space-md);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

p {
    margin-bottom: var(--space-md);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ========================================
   Layout
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    width: 100%;
}

.main-content {
    flex: 1;
    padding: var(--space-xl) 0;
}

/* ========================================
   Header con azioni
   ======================================== */
.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    width: 100%;
    flex-wrap: wrap;
    gap: var(--space-md);
}

@media (max-width: 768px) {
    .header-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ========================================
   Navbar (ereditabile)
   ======================================== */
.navbar {
    background: var(--white);
    box-shadow: var(--shadow-sm);
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.95);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    font-size: var(--font-size-xl);
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: var(--space-xl);
}

.nav-menu a {
    color: var(--gray-600);
    font-weight: 500;
    text-decoration: none;
    padding: var(--space-sm) 0;
    position: relative;
}

.nav-menu a:hover {
    color: var(--primary);
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-gradient);
    transition: var(--transition);
}

.nav-menu a:hover::after {
    width: 100%;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm) 0;
    min-width: 220px;
    display: none;
    z-index: 1000;
    border: 1px solid var(--gray-100);
}

.dropdown:hover .dropdown-menu {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu li {
    list-style: none;
}

.dropdown-menu a {
    display: block;
    padding: var(--space-sm) var(--space-lg);
    color: var(--gray-600);
    text-decoration: none;
    transition: var(--transition);
}

.dropdown-menu a:hover {
    background: var(--gray-50);
    color: var(--primary);
    padding-left: calc(var(--space-lg) + 5px);
}

.dropdown-menu a::after {
    display: none;
}

/* ========================================
   Cards (Soft UI)
   ======================================== */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-lg);
    margin: var(--space-xl) 0;
}

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.card-header h3 {
    margin-bottom: 0;
    font-size: var(--font-size-lg);
    color: var(--gray-600);
}

.card-number {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: var(--space-md);
}

.card-footer {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--gray-100);
}

.card-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.card-link:hover {
    gap: var(--space-sm);
}

/* ========================================
   Tabelle
   ======================================== */
.table-responsive {
    overflow-x: auto;
    margin: var(--space-lg) 0;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    background: var(--white);
    border-collapse: collapse;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table thead {
    background: var(--gray-50);
}

.table th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-weight: 600;
    color: var(--gray-600);
    font-size: var(--font-size-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-600);
}

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

.table tbody tr:hover {
    background: var(--gray-50);
}

/* ========================================
   Form
   ======================================== */
.form-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    box-shadow: var(--shadow-md);
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
    color: var(--gray-700);
    font-size: var(--font-size-sm);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    font-family: inherit;
    transition: var(--transition);
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input.error,
.form-group select.error,
.form-group textarea.error {
    border-color: var(--danger);
}

.form-error {
    color: var(--danger);
    font-size: var(--font-size-sm);
    margin-top: var(--space-xs);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

/* ========================================
   Bottoni
   ======================================== */
.btn {
    display: inline-block;
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    color: var(--white);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #e53e3e;
    transform: translateY(-2px);
}

.btn-sm {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: var(--space-lg) var(--space-xl);
    font-size: var(--font-size-lg);
}

/* ========================================
   Messaggi Flash
   ======================================== */
.flash-message {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.flash-message.success {
    background: #c6f6d5;
    color: #22543d;
    border-left: 4px solid var(--success);
}

.flash-message.error {
    background: #fed7d7;
    color: #742a2a;
    border-left: 4px solid var(--danger);
}

.flash-message.warning {
    background: #feebc8;
    color: #744210;
    border-left: 4px solid var(--warning);
}

.flash-message.info {
    background: #bee3f8;
    color: #2a4365;
    border-left: 4px solid var(--info);
}

.flash-close {
    background: none;
    border: none;
    font-size: var(--font-size-xl);
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    transition: var(--transition);
}

.flash-close:hover {
    opacity: 1;
}

/* ========================================
   Badge e stati
   ======================================== */
.badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 9999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-success {
    background: #c6f6d5;
    color: #22543d;
}

.badge-warning {
    background: #feebc8;
    color: #744210;
}

.badge-danger {
    background: #fed7d7;
    color: #742a2a;
}

.badge-info {
    background: #bee3f8;
    color: #2a4365;
}

/* ========================================
   Utility classes
   ======================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.p-1 { padding: var(--space-sm); }
.p-2 { padding: var(--space-md); }
.p-3 { padding: var(--space-lg); }
.p-4 { padding: var(--space-xl); }

/* ========================================
   Dashboard - righe fatture non saldate
   ======================================== */
.row-da-saldare {
    background-color: #ffc000;
}
.row-da-saldare:hover {
    background-color: #f5b800 !important;
}

/* ========================================
   Gestione Righe Dinamiche (Avvisi/Fatture)
   ======================================== */

/* Contenitore tabella righe */
.righe-wrapper {
    margin: var(--space-lg) 0;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

/* Tabella righe */
.righe-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: var(--white);
    border: none;
}

/* Colonne - proporzioni che sommano a 100% */
.righe-table .col-descrizione { width: 55%; }
.righe-table .col-quantita    { width: 8%; }
.righe-table .col-prezzo      { width: 15%; }
.righe-table .col-totale      { width: 20%; }
.righe-table .col-azioni      { width: 2%; }

/* Allineamenti intestazioni */
.righe-table th {
    padding: var(--space-md) var(--space-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.righe-table th.col-descrizione { text-align: left; }
.righe-table th.col-quantita    { text-align: center; }
.righe-table th.col-prezzo      { text-align: center; }
.righe-table th.col-totale      { text-align: right; }
.righe-table th.col-azioni      { text-align: right; }

/* Padding celle */
.righe-table th:last-child,
.righe-table td:last-child {
    padding-right: var(--space-sm);
}

.righe-table th:first-child,
.righe-table td:first-child {
    padding-left: var(--space-sm);
}

/* Celle della tabella */
.righe-table td {
    padding: var(--space-sm);
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}

/* Allineamenti contenuto celle */
.righe-table td.col-descrizione { text-align: left; }
.righe-table td.col-quantita    { text-align: right; }
.righe-table td.col-prezzo      { text-align: right; }
.righe-table td.col-totale      { text-align: right; }
.righe-table td.col-azioni      { text-align: center; }

/* Input fields nelle righe */
.righe-table input,
.righe-table textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    font-family: inherit;
    transition: var(--transition);
    background: var(--white);
    box-sizing: border-box;
    resize: vertical;
    min-height: 50px;
}

.righe-table input:focus,
.righe-table textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Input numerici allineati a destra */
.righe-table .col-quantita input,
.righe-table .col-prezzo input,
.righe-table .col-totale input {
    text-align: right;
}

/* Campo totale riga (readonly) */
.righe-table .col-totale input {
    background-color: var(--gray-50);
    font-weight: 500;
    color: var(--gray-700);
    border-color: var(--gray-200);
    cursor: default;
}

.righe-table .col-totale input:focus {
    border-color: var(--gray-200);
    box-shadow: none;
}

/* Contenitore cella azioni */
.righe-table .col-azioni {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60px;
    padding: var(--space-xs);
    vertical-align: middle;
}

/* Pulsante rimuovi riga */
.btn-remove-row {
    align-self: center;
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin: 0 auto;
}

.btn-remove-row:hover {
    background: var(--gray-100);
    color: #e53e3e;
    transform: scale(1.1);
}

.btn-remove-row:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Pulsante aggiungi riga */
.btn-add-row {
    background: var(--gray-100);
    border: 2px dashed var(--gray-300);
    color: var(--gray-600);
    padding: var(--space-md);
    width: 100%;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: var(--font-size-md);
    margin-top: var(--space-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.btn-add-row:hover {
    background: var(--gray-200);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.btn-add-row:active {
    transform: translateY(0);
}

.btn-add-row i {
    font-size: 1.2em;
    font-weight: bold;
    font-style: normal;
}

/* Totale documento */
.totale-documento-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-lg);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 2px solid var(--gray-200);
}

.totale-documento-label {
    font-size: var(--font-size-lg);
    color: var(--gray-600);
    font-weight: 500;
}

.totale-documento-valore {
    font-size: var(--font-size-2xl);
    color: var(--primary);
    font-weight: 700;
}

/* Messaggi di validazione righe */
.row-validation-error {
    color: var(--danger);
    font-size: var(--font-size-xs);
    margin-top: 2px;
    display: none;
}

.riga-item.invalid .row-validation-error {
    display: block;
}

/* Responsive righe */
@media (max-width: 768px) {
    .righe-table,
    .righe-table thead,
    .righe-table tbody,
    .righe-table tr,
    .righe-table td,
    .righe-table th {
        display: block;
    }

    .righe-table thead {
        display: none;
    }

    .righe-table tr {
        margin-bottom: var(--space-md);
        border: 1px solid var(--gray-200);
        border-radius: var(--radius-md);
        padding: var(--space-md);
    }

    .righe-table td {
        display: flex;
        align-items: center;
        padding: var(--space-xs) 0;
        border-bottom: none;
    }

    .righe-table td:before {
        content: attr(data-label);
        width: 120px;
        font-weight: 600;
        color: var(--gray-600);
    }

    .righe-table .col-quantita,
    .righe-table .col-prezzo,
    .righe-table .col-totale {
        text-align: left;
    }

    .righe-table input {
        width: calc(100% - 120px);
    }
}

/* ========================================
   Filtri di ricerca
   ======================================== */
.filters-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
}

.filters-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 150px;
}

.filter-group label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: var(--space-xs);
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    font-family: inherit;
    transition: var(--transition);
    background: var(--white);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-actions {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.filter-actions .btn {
    margin: 0;
    white-space: nowrap;
}

/* Pulsante reset filtri */
.btn-reset {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-500);
}

.btn-reset:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-600);
}

/* ========================================
   Tabella con azioni (elenco avvisi/fatture)
   ======================================== */
.table-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.table-actions-row {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
}

.table-actions .btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

/* Pulsanti azioni - uniformati */
.btn-modifica {
    background: var(--primary);
    color: var(--white);
}

.btn-modifica:hover {
    color: var(--white);
    transform: translateY(-2px);
}

.btn-pdf {
    background: var(--primary);
    color: var(--white);
}

.btn-pdf:hover {
    color: var(--white);
    transform: translateY(-2px);
}

.btn-xml {
    background: var(--primary);
    color: var(--white);
}

.btn-xml:hover {
    color: var(--white);
    transform: translateY(-2px);
}

.btn-converti {
    background: var(--primary);
    color: var(--white);
}

.btn-converti:hover {
    color: var(--white);
    transform: translateY(-2px);
}

.btn-email {
    background: var(--primary);
    color: var(--white);
}

.btn-email:hover {
    color: var(--white);
    transform: translateY(-2px);
}

.btn-elimina {
    background: var(--danger);
    color: var(--white);
}

.btn-elimina:hover {
    color: var(--white);
    transform: translateY(-2px);
}

/* Badge stati - definizione unica */
.stato-badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: 9999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stato-attivo {
    background: var(--warning);
    color: #744210;
}

.stato-convertito {
    background: var(--success);
    color: white;
}

.stato-incassato {
    background: var(--info);
    color: white;
}

/* Info vuota */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    background: var(--white);
    border-radius: var(--radius-lg);
    color: var(--gray-400);
}

.empty-state p {
    margin-bottom: var(--space-lg);
}

/* Riga cliccabile (opzionale) */
.clickable-row {
    cursor: pointer;
    transition: var(--transition);
}

.clickable-row:hover {
    background: var(--gray-50);
}

/* Responsive filtri e azioni */
@media (max-width: 768px) {
    .filters-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-actions {
        flex-direction: row;
        justify-content: flex-end;
    }
    
    .table-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .table-actions .btn-sm {
        width: 100%;
        text-align: center;
    }
}
