body { font-family: sans-serif; padding: 20px; }
/* Navigation */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
    position: relative;
    z-index: 1000;
}

/* Burger Menu Button (Hidden by default) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    flex-direction: column;
    gap: 5px;
    z-index: 2005;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Container for nav links and actions */
.nav-menu-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.nav-links, .nav-actions {
    display: flex;
    align-items: center;
}

nav a {
    margin-right: 15px;
    text-decoration: none;
    color: #333;
    font-weight: bold;
}

nav button {
    margin-right: 15px;
    text-decoration: none;
    color: #333;
    font-weight: bold;
}
nav a:hover { color: #007bff; }

nav .logout-button {
    margin-right: 15px;
    text-decoration: none;
    color: #333;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    font-family: inherit;
}
nav .logout-button:hover { color: #007bff; }

/* Dropdown Menu */
.dropdown {
  position: relative;
  display: inline-block;
  margin-right: 15px;
}

.dropbtn {
  background-color: transparent;
  color: #333;
  padding: 0;
  font-size: 16px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  font-family: inherit;
}
.dropbtn:hover { color: #007bff; }

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #fff;
  min-width: 160px;
  box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
  z-index: 1000;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.dropdown-content a {
  color: #333;
  padding: 10px 15px;
  text-decoration: none;
  display: block;
  margin-right: 0;
  font-weight: normal;
  border-bottom: 1px solid #f1f1f1;
}
.dropdown-content a:last-child {
    border-bottom: none;
}

.dropdown-content a:hover {background-color: #f8f9fa; color: #007bff;}

/* Sub Dropdown */
.sub-dropdown {
  position: relative;
}

/* Style the account link to look like a menu item */
.sub-dropbtn {
  color: #333;
  padding: 10px 15px;
  text-decoration: none;
  display: block;
  margin-right: 0;
  font-weight: normal;
  background-color: #fff;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  border: none; /* Reset default button border */
  border-bottom: 1px solid #f1f1f1;
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
}

.sub-dropbtn:hover {
  background-color: #f8f9fa;
  color: #007bff;
}

/* Hide the sub-menu by default */
.sub-dropdown-content {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  background-color: #fff;
  min-width: 160px;
  box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
  z-index: 1001;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.sub-dropdown-content a {
  color: #333;
  padding: 10px 15px;
  text-decoration: none;
  display: block;
  margin-right: 0;
  font-weight: normal;
  border-bottom: 1px solid #f1f1f1;
}

.sub-dropdown-content a:last-child {
    border-bottom: none;
}

.sub-dropdown-content a:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

/* DESKTOP HOVER INTERACTIONS */
@media screen and (min-width: 769px) {
    .dropdown:hover .dropdown-content {
      display: block;
    }

    .sub-dropdown:hover .sub-dropdown-content {
      display: block;
    }
}

/* Mobile Menu Header (Back & Close) - Hidden on Desktop */
.mobile-menu-header {
    display: none;
}

/* Styles communs (cartes, couleurs, tableaux) */
.card { border: 1px solid #ddd; padding: 15px; border-radius: 5px; display: inline-block; width: 200px; margin-right: 10px; vertical-align: top;}
.green { color: green; }
.red { color: red; }
.blue { color: blue; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }

/* Styles pour le pointage */
.reconciled { color: green; font-weight: bold; }
.not-reconciled { color: red; font-weight: bold; cursor: pointer; text-decoration: underline; }

/* Account List Grid */
.account-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
}

.account-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    width: 250px;
    text-align: center;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    display: block;
}

.account-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    border-color: #007bff;
}

.account-card h3 {
    margin-top: 0;
    font-size: 1.25rem;
    color: #333;
    margin-bottom: 15px;
}

.account-card .balance {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 10px 0;
}

.account-card .sub-text {
    font-size: 0.875rem;
    color: #666;
}

/* Transaction Form Styles */
.transaction-form-container {
    background-color: #fff;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    max-width: 600px;
    margin: 20px auto;
}

.transaction-form-container h1 {
    text-align: center;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box; /* Make sure padding doesn't affect width */
}

.form-group .errorlist {
    color: red;
    list-style-type: none;
    padding: 0;
    margin-top: 5px;
    font-size: 0.9em;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.button {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.button:hover {
    background-color: #0056b3;
}

.cancel-button {
    background-color: #6c757d;
}

.cancel-button:hover {
    background-color: #5a6268;
}

/* Utility Classes */
.justify-center {
    justify-content: center;
}

.hidden {
    visibility: hidden;
}

/* Helper Classes */
.mb-20 {
    margin-bottom: 20px;
}

.inline-form {
    display: inline;
}

/* Action Icons */
.link-no-decoration {
    text-decoration: none;
}

.mr-10 {
    margin-right: 10px;
}

.icon-blue {
    color: #007bff;
}

.icon-red {
    color: #dc3545;
}

/* Recurring List Styles */
.icon-green {
    color: green;
}

/* Specific component styles override or extension */
.new-account-title {
    font-size: 3rem;
    margin-bottom: 0;
}

/* Table Styles */
.dimmed-row {
    opacity: 0.6;
    background-color: #f9f9f9;
}

.text-center {
    text-align: center;
}

/* Form Styles */
.help-text {
    font-size: 0.8rem;
    color: #666;
    margin-top: 5px;
}

/* Accessibility Improvements */
a:focus, button:focus, input:focus, select:focus, textarea:focus {
    outline: 2px solid #0056b3;
    outline-offset: 2px;
}

/* Date Selector Form (Year & Month) */
.year-selector, .date-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.year-input, .month-input {
    width: 80px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    nav {
        flex-wrap: wrap;
        padding: 10px 20px;
        position: static;
        box-sizing: border-box;
    }

    .menu-toggle {
        display: flex;
    }

    /* Animate burger to X when active */
    .menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }

    /* Overlay Full Screen Menu */
    .nav-menu-container {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: white;
        z-index: 2000;
        flex-direction: column;
        justify-content: flex-start;
        padding: 20px; /* Match body padding */
        margin: 0; /* Remove margin to ensure full edge coverage */
        border-top: none;
        overflow-y: auto;
        box-sizing: border-box; /* Include padding in width/height */
    }

    .nav-menu-container.active {
        display: flex;
    }

    /* Mobile Menu Header (Back & Title) */
    .mobile-menu-header {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: center;
        width: 100%;
        box-sizing: border-box;
        padding: 15px 20px; /* Match nav padding exactly */
        border-bottom: 1px solid #ddd;
        margin-bottom: 20px;
        position: sticky;
        top: 0;
        background: white;
        z-index: 2002;
        min-height: 50px;
    }

    /* Grid item 1: Back Button (moved to right as requested) */
    .mobile-menu-header .back-button {
      grid-column: 3;
      justify-self: end;
      background: none;
      border: none;
      font-size: 1.1rem;
      cursor: pointer;
      margin: 0;
      color: #333;
      font-weight: bold;
      display: flex;
      align-items: center;
      min-width: 80px;
      justify-content: flex-end; /* Ensure inner content aligns right */
    }

    /* Grid item 2: Title */
    .mobile-menu-header .menu-title {
        grid-column: 2;
        font-weight: bold;
        font-size: 1.2rem;
        text-align: center;
        white-space: nowrap;
    }

    /* Navigation Links Styling for Level 1 */
    .nav-links, .nav-actions {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        box-sizing: border-box;
        padding: 0 20px; /* Restore horizontal padding */
    }

    /* Target all nav items including sub-buttons and logout button */
    nav a, .dropbtn, .sub-dropbtn, nav .logout-button {
        width: 100%;
        text-align: left;
        padding: 15px 0;
        border: none; /* Reset all borders first */
        border-bottom: 1px solid #f1f1f1; /* Apply desired border */
        font-size: 1.1rem;
        margin-right: 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: none;
        color: #333;
        font-family: inherit;
        font-weight: bold; /* Ensure all are bold including sub-dropbtn */
        cursor: pointer;
    }

    /* Logout form container needs to take full width */
    .inline-form {
        width: 100%;
    }

    /* Dropdown Reset for Mobile */
    .dropdown, .sub-dropdown {
        width: 100%;
        margin-bottom: 0;
        position: static;
    }

    .dropdown-content, .sub-dropdown-content {
        display: none;
        position: static;
        width: 100%;
        box-shadow: none;
        border: none;
        padding: 0;
        background-color: white;
    }

    /* Fix level 2 and 3 links to match level 1 style on mobile */
    .dropdown-content a,
    .sub-dropdown-content a {
        padding: 15px 0 !important;
        font-size: 1.1rem;
        border-bottom: 1px solid #f1f1f1 !important;
        color: #333;
        font-weight: bold;
    }

    /* Drill-down Logic */
    /* Ensure active submenu covers everything, opaque background */
    .nav-menu-container .active-submenu {
        position: fixed;
        top: 98px; /* Aligned with header bottom (20px pad + 45px header) */
        left: 0;
        width: 100vw;
        height: calc(100vh - 65px);
        background: white;
        padding: 0 40px 20px 40px; /* Align with header content (20px body + 20px nav) */
        z-index: 2010; /* Higher than other content */
        overflow-y: auto;
        display: block !important;
        box-shadow: none;
    }

    /* Disable hover on mobile */
    .dropdown:hover .dropdown-content,
    .sub-dropdown:hover .sub-dropdown-content {
        display: none;
    }

    /* Restore display for active state specifically */
    .dropdown-content.active-submenu,
    .sub-dropdown-content.active-submenu {
        display: block !important;
    }

    /* Other Mobile Styles */
    .account-grid {
        justify-content: center;
    }

    .account-card {
        width: 100%;
        max-width: none;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    .transaction-form-container {
        padding: 15px;
        margin: 10px 0;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .button {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
        box-sizing: border-box;
    }

    /* Date Selector Mobile */
    .year-selector, .date-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .year-input, .month-input {
        width: 100%;
        margin-bottom: 10px;
    }
}
