/* =====================================================
   GLOBAL RESET
   ===================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 5px;
    font-family: "Segoe UI", Arial, sans-serif;

    background: linear-gradient(135deg, #1e3c72, #2a5298);

    display: flex;
    justify-content: center;
    align-items: flex-start;

    min-height: 100vh;
}


/* =====================================================
   INPUT BASE (globale)
   ===================================================== */

select,
input[type="text"] {
    height: 32px;
    padding: 0 10px;

    border-radius: 6px;
    border: 1px solid #ccc;

    font-size: 14px;

    transition: all 0.2s ease;
}

select:focus,
input:focus {
    outline: none;
    border-color: #2a5298;
}


/* =====================================================
   LOGIN PAGE
   ===================================================== */

.login-container {
    width: 100%;
    max-width: 420px;
    margin: 120px auto 0;
}

.login-card {
    background: white;
    padding: 40px;

    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

.login-card h2 {
    margin: 0;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: #777;
    margin-bottom: 25px;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: block;
    font-size: 14px;
    margin-bottom: 5px;
    color: #333;
}

.input-group input {
    width: 100%;
    padding: 10px;
}

button {
    width: 100%;
    padding: 12px;

    background: #2a5298;
    border: none;
    border-radius: 6px;

    color: white;
    font-size: 15px;
    cursor: pointer;
}

button:hover {
    background: #1e3c72;
}

.error-message {
    margin-top: 15px;
    color: red;
    text-align: center;
    font-size: 14px;
}


/* =====================================================
   PAGE WRAPPER
   ===================================================== */

.page-wrapper {
    width: 100%;
    max-width: 1250px;
    margin: 0 auto;

    display: flex;
    flex-direction: column;
    min-height: 95vh;
}


/* =====================================================
   DASHBOARD CARD
   ===================================================== */

.dashboard-card {
    background: white;
    width: 100%;
    padding: 30px;

    box-shadow: 0 15px 40px rgba(0,0,0,0.2);

    flex: 1;
    display: flex;
    flex-direction: column;

    border-radius: 12px 12px 0 0;
}


/* =====================================================
   DASHBOARD HEADER
   ===================================================== */

/* ===== HEADER NUOVO ===== */

.dashboard-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

/* titolo centrato */
.header-title-center {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: #2a5298;
}

/* riga sotto */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* sinistra */
.header-left {
    display: flex;
    align-items: center;
}

/* utente + logout */
.user-logout-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* box utente */
.user-box {
    display: flex;
    align-items: center;
    gap: 6px;

    color: #2a5298;
    font-size: 14px;
}

/* FIX ALLINEAMENTO ICONA */
.user-icon svg {
    display: block;
}

/* separatore */
.separator {
    color: #aaa;
}


/* destra */
.header-right {
    display: flex;
    align-items: center;
}


.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 14px;
}

.logout-btn {
    color: #890303;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
}

.logout-btn:hover {
    text-decoration: underline;
}


/* =====================================================
   SELECT HEADER CONTRATTO
   ===================================================== */


.select-contratto {

    max-width: 180px;
    width: auto;

    flex-shrink: 1;
    min-width: 0;
    
    height: 34px;
    padding: 0 14px;

    border-radius: 10px;
    border: 1px solid #2a5298;

    background-color: #f0f4ff;
    color: #2a5298;

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition: all 0.2s ease;

    appearance: none;

    background-image: url("data:image/svg+xml;utf8,<svg fill='%232a5298' height='20' viewBox='0 0 24 24' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;

    padding-right: 25px;
}

.select-contratto:hover {
    background-color: #2a5298;
    color: white;
}

.select-contratto:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(42, 82, 152, 0.25);
}


/* =====================================================
   DASHBOARD LAYOUT
   ===================================================== */

.dashboard-content {
    display: flex;
    gap: 30px;
    width: 100%;
    flex: 1;
}


/* =====================================================
   SIDEBAR
   ===================================================== */

.sidebar {
    width: 30%;
    border-top: 1px solid #eee;

    padding-right: 20px;
    padding-top: 10px;

    max-height: 65vh;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.sidebar-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}


/* =====================================================
   INPUT MINIMAL (solo bordo sotto)
   ===================================================== */

.sidebar-filter select,
.sidebar-filter input,
.filter-bar select,
.filter-bar input {

    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.25);
    border-radius: 0;
    background: transparent;
    padding: 4px 2px;
    height: 26px;
}

.sidebar-filter select:focus,
.sidebar-filter input:focus,
.filter-bar select:focus,
.filter-bar input:focus {

    border-bottom: 2px solid #2a5298;
}


/* =====================================================
   CARTELLE
   ===================================================== */

.folder {
    padding-left: 25px;
}

.folder-title {
    font-weight: bold;
    margin-top: 10px;
    cursor: pointer;
}

.folder-content {
    display: none;
    margin-left: 10px;
}

.sidebar ul {
    list-style: none;
    padding-left: 18px;
    margin-top: 8px;
}

.sidebar li {
    padding: 6px 0;
    font-size: 14px;
    color: #333;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar li:hover {
    background: #f5f7fb;
    border-radius: 4px;
}


/* =====================================================
   MAIN CONTENT
   ===================================================== */

.main-content {
    width: 65%;
    border-top: 1px solid #eee;
    padding-top: 10px;
}


/* =====================================================
   MAIN HEADER
   ===================================================== */

.main-header {
    display: flex;
    flex-direction: column;
    gap: 10px;

    padding-bottom: 10px;
    margin-bottom: 15px;

    border-bottom: 1px solid #eee;
}

.main-header-title {
    font-size: 20px;
    font-weight: 600;
}


/* =====================================================
   FILTER BAR
   ===================================================== */

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

#filtroDocumenti,
#searchInput {
    width: 165px;
}


/* =====================================================
   TABLE
   ===================================================== */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.resoconto-table {
    width: 100%;
    min-width: 750px;
    border-collapse: collapse;
}

.resoconto-table th,
.resoconto-table td {
    padding: 6px 8px;
    border: 1px solid #e0e0e0;
}

.resoconto-table th {
    background-color: #f5f5f5;
    text-align: center;
}

.resoconto-table td {
    text-align: right;
    white-space: nowrap;
}


/* =====================================================
   TOTALI ROW
   ===================================================== */

.totali-row {
    position: sticky;
    bottom: 0;
    background-color: #f8f9fc;
    z-index: 2;
}


/* =====================================================
   FOOTER
   ===================================================== */

.footer {
    background-color: #1f2a37;
    color: #fff;
    padding: 5px;
    font-size: 13px;
    border-radius: 0 0 12px 12px;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

.footer a {
    color: #ccc;
    text-decoration: none;
}

.footer a:hover {
    color: #fff;
}


/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 1030px) {

    .dashboard-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-bottom: 1px solid #e5e5e5;
        padding-right: 0;
    }

    .main-content {
        width: 100%;
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {

    .header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .header-right {
        width: 100%;
    }

    .select-contratto {
        width: 100%;
    }
}