/* Stili generali */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Header e Navigazione */
header {
    background-color: #fff;
    padding: 15px 30px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Per gestire schermi piccoli */
}

header h1 {
    margin: 0;
    font-size: 1.5em;
    color: #0056b3;
}

header nav {
    display: flex;
    align-items: center;
    gap: 15px; /* Spazio tra i pulsanti */
}

/* Pulsanti */
.btn {
    background-color: #007bff;
    color: #fff;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 500;
    transition: background-color 0.2s ease-in-out;
}
.btn:hover {
    background-color: #0056b3;
}
.btn-logout {
    background-color: #dc3545;
    color: #fff;
    padding: 8px 12px;
    border-radius: 5px;
    text-decoration: none;
    transition: background-color 0.2s ease-in-out;
}
.btn-logout:hover {
    background-color: #c82333;
}

/* Form */
.form-box {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin-top: 20px;
}
.form-box h2 {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
}
.form-box label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}
.form-box input[type="text"],
.form-box input[type="email"],
.form-box input[type="password"],
.form-box input[type="number"],
.form-box input[type="date"],
.form-box select,
.form-box textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Cruciale per il layout */
}
.form-box button {
    width: 100%;
    padding: 12px;
}
.form-box p {
    text-align: center;
    margin-top: 15px;
}

/* Dashboard */
.portfolios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.portfolio-card {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.portfolio-card h3 {
    margin-top: 0;
    color: #007bff;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
.portfolio-card p {
    margin: 8px 0;
    font-size: 1.1em;
}
.total-summary {
    text-align: center;
    margin-bottom: 30px;
}

/* Colori per entrate/uscite/saldo */
.income { color: #28a745; font-weight: bold; }
.expense { color: #dc3545; font-weight: bold; }
.balance.positive { color: #28a745; font-weight: bold; }
.balance.negative { color: #dc3545; font-weight: bold; }

/* Messaggi di errore e successo */
.error {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
}
.success {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 15px;
    text-align: center;
}

/* Pagina di Benvenuto */
.welcome {
    text-align: center;
    padding-top: 100px;
}
.welcome h1 {
    font-size: 3em;
}
.welcome .buttons a {
    margin: 0 10px;
}

/* Stili per le tabelle generiche e liste pulite */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}
table th, table td {
    border-bottom: 1px solid #ddd;
    padding: 12px 8px;
    text-align: left;
}
table th {
    background-color: #f8f9fa;
    font-weight: 600;
}
.clean-list {
    list-style: none;
    padding: 0;
}
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

/* Stile per i tag delle categorie */
.category-tag {
    background: #e9ecef;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    color: #495057;
}

/* Stili per il menu a tendina nel header */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown-btn {
  background-color: #6c757d;
}
.dropdown-btn:hover {
    background-color: #5a6268;
}
.dropdown-content {
  display: none;
  position: absolute;
  right: 0; /* Allinea a destra */
  background-color: #f1f1f1;
  min-width: 200px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 100;
  border-radius: 5px;
  overflow: hidden;
}
.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}
.dropdown-content a:hover { background-color: #ddd; }
.dropdown:hover .dropdown-content { display: block; }

/* Stili per le barre di progresso del budget */
.budget-item {
    margin-bottom: 15px;
}
.budget-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.9em;
}
.progress-bar-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: .25rem;
    height: 20px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background-color: #007bff;
    border-radius: .25rem;
    text-align: center;
    color: white;
    line-height: 20px;
    transition: width 0.6s ease;
}
.progress-bar.over-budget {
    background-color: #dc3545; /* Rosso quando si supera il budget */
}

/* Stili per il Modale */
.modal {
    display: none; /* Nascosto di default */
    position: fixed; /* Rimane fisso durante lo scrolling */
    z-index: 1000; /* Davanti a tutto */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Permette lo scrolling se il contenuto è troppo lungo */
    background-color: rgba(0,0,0,0.5); /* Sfondo nero semi-trasparente */
    padding-top: 60px;
}
.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
    animation: animatetop 0.4s;
}
@keyframes animatetop {
  from {top: -300px; opacity: 0}
  to {top: 0; opacity: 1}
}
.close-btn {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 25px;
    font-size: 28px;
    font-weight: bold;
}
.close-btn:hover,
.close-btn:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}
