/* Dark Mode Toggle */
.dark-mode-toggle {
    position: relative;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px 12px;
    color: #2c3e50;
    z-index: 1;
    transition: all 0.3s ease;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #e1e1e1;
}

body.dark-mode .container {
    background: #2d2d2d;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

body.dark-mode .navbar {
    background-color: #2d2d2d;
}

body.dark-mode .form-section {
    background: #363636;
    border-color: #404040;
}

body.dark-mode .toggle-sidebar,
body.dark-mode .dark-mode-toggle {
    color: #e1e1e1;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: #1a1a1a;
    border-color: #404040;
    color: #e1e1e1;
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
    border-color: #0056b3;
    box-shadow: 0 0 0 0.2rem rgba(0, 86, 179, 0.25);
}

body.dark-mode .navbar h1 {
    color: #e1e1e1;
}

body.dark-mode .slogan {
    color: #b0b0b0;
}

body.dark-mode .title-separator {
    color: #707070;
}

body.dark-mode #currencySelect {
    background-color: #1a1a1a;
    color: #e1e1e1;
}

body.dark-mode .item-row {
    background: #363636;
}

body.dark-mode .sidebar {
    background-color: #1a1a1a;
}

body.dark-mode .sidebar-button {
    background-color: #363636;
}

body.dark-mode .sidebar-button:hover {
    background-color: #404040;
}

body.dark-mode .saved-client-item {
    background-color: #363636;
}

body.dark-mode .saved-client-item:hover {
    background-color: #404040;
}

body.dark-mode h2 {
    color: #e1e1e1;
}

body.dark-mode label {
    color: #e1e1e1;
}

body.dark-mode .dark-mode-toggle {
    color: #e1e1e1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1em;
    resize: vertical;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.flex-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.flex-item {
    flex: 1;
    min-width: 0;
}

.form-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

label {
    display: block;
    margin-bottom: 5px;
    color: #2c3e50;
    font-weight: bold;
}

label input[type="checkbox"] {
    margin-right: 8px;
    vertical-align: middle;
}

input, select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1em;
}

input[type="checkbox"] {
    width: auto;
}

#currencySelect {
    width: auto;
    margin-left: 10px;
    padding: 4px 8px;
    font-size: 0.9em;
    background-color: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
}

input:focus, select:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

button {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

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

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.button-group button {
    flex: 1;
    padding: 12px 20px;
}

/* Navbar et titre */
.navbar {
    background-color: #fff;
    padding: 15px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.title-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.navbar h1 {
    margin: 0;
    font-size: 1.8em;
    font-weight: bold;
    color: #2c3e50;
}

.title-separator {
    color: #95a5a6;
    margin: 0 8px;
    font-size: 1.5em;
}

.slogan {
    color: #7f8c8d;
    font-size: 1em;
    font-weight: normal;
}

.toggle-sidebar {
    position: relative;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 8px 12px;
    color: #2c3e50;
    z-index: 1;
}

#previewInvoice {
    flex: 1;
    background-color: #6c757d;
}

#previewInvoice:hover {
    background-color: #5a6268;
}

#generateInvoice {
    flex: 1;
    background-color: #28a745;
}

#generateInvoice:hover {
    background-color: #218838;
}

.item-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    background: white;
    padding: 10px;
    border-radius: 4px;
}

.item-row .item-description {
    width: 100%;
    margin-bottom: 10px;
}

.item-row .item-details {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

.remove-item {
    background-color: #dc3545;
    padding: 8px 12px;
}

.remove-item:hover {
    background-color: #c82333;
}

#addItem {
    margin-top: 10px;
    width: 100%;
    background-color: #6c757d;
}

#addItem:hover {
    background-color: #5a6268;
}

.sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 300px;
    height: 100%;
    background-color: #2c3e50;
    transition: left 0.3s ease;
    z-index: 1001; /* Augmenté pour être au-dessus de l'overlay */
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar.open {
    left: 0;
}

.sidebar-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-button {
    width: 100%;
    padding: 12px;
    background-color: #34495e;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 10px;
    text-align: left;
    transition: background-color 0.3s;
}

.sidebar-button:hover {
    background-color: #3d5a80;
}

.sidebar-divider {
    height: 1px;
    background-color: #415b76;
    margin: 20px 0;
}

.sidebar-section {
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-section h3 {
    margin-bottom: 15px;
    color: #ecf0f1;
}

.main-content {
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-open {
    margin-left: 300px;
}

/* Styles pour l'historique */
.history-button {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

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

.history-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.history-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
}

.history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-modal {
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: #666;
}

.close-modal:hover {
    color: #333;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.history-table th,
.history-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.history-table th {
    background-color: #f8f9fa;
    font-weight: bold;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.action-buttons button {
    padding: 6px 12px;
}

.preview-btn {
    background-color: #6c757d;
}

.preview-btn:hover {
    background-color: #5a6268;
}

.download-btn {
    background-color: #28a745;
}

.download-btn:hover {
    background-color: #218838;
}

.delete-btn {
    background-color: #dc3545;
    padding: 4px 8px !important;
}

.delete-btn:hover {
    background-color: #c82333;
}

/* Styles pour les clients sauvegardés */
.saved-client-item {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    background-color: #34495e;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    width: 100%;
}

.saved-client-item:hover {
    background-color: #3d5a80;
}

.saved-clients-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
}

.client-name {
    margin-right: 5px;
    color: #ffffff; /* Ajout de la couleur blanche pour le texte */
}

.delete-client {
    color: #e74c3c;
    visibility: hidden;
    opacity: 0;
    margin-left: 5px;
    font-weight: bold;
    font-size: 1.2em;
    transition: all 0.3s ease;
}

.saved-client-item:hover .delete-client {
    visibility: visible;
    opacity: 1;
}

.delete-client:hover {
    color: #c0392b;
}

.saved-items-list {
    margin-bottom: 20px !important;
}

.email-button {
    flex: 1;
    background-color: #4CAF50;
}

.email-button:hover {
    background-color: #45a049;
}

/* Responsive */
@media screen and (max-width: 768px) {

      .dark-mode-toggle {
        position: relative;
        right: 0;
        font-size: 24px;
        padding: 6px 10px;
        margin-left: 10px;
        flex-shrink: 0; /* Empêche le bouton de se rétrécir */
    }

      .navbar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
        position: relative;
        min-height: 60px;
    }
    
    .flex-container {
        flex-direction: column;
    }
    
    .action-buttons {
        flex-direction: column;
    }

    .sidebar {
        width: 250px;
    }
    
    .main-content.sidebar-open {
        margin-left: 0;
    }

   .title-container {
        position: relative;
        left: 0;
        transform: none;
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        min-width: 0;
        padding: 0 5px;        
        flex-wrap: nowrap; /* Empêche le retour à la ligne */
        gap: 4px; /* Réduit l'espace entre les éléments */
    }
    
    .title-separator {
        margin: 0 4px;
        display: inline-block; /* Assure que le séparateur reste visible */
    }
    
      .slogan {
        font-size: 0.8em; /* Légèrement réduit pour mieux s'adapter */
        white-space: normal; /* Permet le retour à la ligne si nécessaire */
        min-width: 0;
        flex-shrink: 1; /* Permet au slogan de se rétrécir si nécessaire */
        text-overflow: clip; /* Évite les points de suspension */
        overflow: visible; /* Permet au texte d'être entièrement visible */
        line-height: 1.2; /* Optimise la hauteur de ligne */
    }
    
      .navbar h1 {
        font-size: 1.1em; /* Légèrement réduit */
        white-space: nowrap;
        margin: 0;
        flex-shrink: 0; /* Empêche le titre de se rétrécir */
    }
    
     .toggle-sidebar {
        position: relative;
        left: 0;
        font-size: 24px;
        padding: 6px 10px;
        margin-right: 10px;
        flex-shrink: 0; /* Empêche le bouton de se rétrécir */
    }
}

@media screen and (max-width: 380px) {
    .navbar h1 {
        font-size: 1em;
    }

    .slogan {
        font-size: 0.7em;
    }
}
