/* ==============================
   STILE BASE GENERALE
   ============================== */
body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    margin: 0;
    padding: 0;
    color: #222;
}

/* ==============================
   NAVBAR
   ============================== */
.navbar {
    background-color: #333;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 25px;
}

.navbar a {
    color: #ccc;
    margin-left: 18px;
    text-decoration: none;
    font-weight: 500;
}

.navbar a.active,
.navbar a:hover {
    color: #fff;
    text-decoration: underline;
}

/* ==============================
   CONTENITORE PRINCIPALE
   ============================== */
.container {
    background: #fff;
    max-width: 95%;
    margin: 30px auto;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow-x: auto; /* Scroll orizzontale per tabelle larghe */
}

h2 {
    margin-top: 0;
    color: #333;
}

/* ==============================
   FORM E INPUT
   ============================== */
form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

input[type="text"],
input[type="date"],
input[type="password"],
input[type="email"],
textarea {
    width: 100%;
    max-width: 400px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
    box-sizing: border-box;
}

textarea {
    resize: vertical;
}

label {
    display: block;
    font-weight: bold;
    margin-top: 10px;
    margin-bottom: 5px;
}

/* ==============================
   PULSANTI
   ============================== */
button,
.btn {
    background: #333;
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

button:hover,
.btn:hover {
    background: #555;
}

.btn-secondary {
    background: #888;
}

.btn-secondary:hover {
    background: #666;
}

/* ==============================
   TABELLE
   ============================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 14px;
    min-width: 900px; /* per garantire spazio adeguato */
}

th, td {
    padding: 10px 8px;
    border-bottom: 1px solid #ddd;
    text-align: left;
    vertical-align: middle;
}

/* Riga intestazione con effetto sticky */
th {
    background-color: #f1f1f1;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Riga alternata */
tr:nth-child(even) {
    background-color: #fafafa;
}

/* Hover sulle righe */
tr:hover {
    background-color: #f0f8ff;
}

/* ==============================
   MESSAGGI / ERRORI
   ============================== */
.error {
    background: #ffecec;
    border: 1px solid #ff9a9a;
    color: #a33;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 15px;
}

/* ==============================
   RESPONSIVE DESIGN
   ============================== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
        max-width: 98%;
    }

    table {
        font-size: 13px;
        min-width: 600px;
    }

    input[type="text"],
    input[type="date"],
    input[type="password"],
    input[type="email"],
    textarea {
        max-width: 100%;
    }

    form {
        flex-direction: column;
        align-items: stretch;
    }
}
