/* public_html/css/admin_style.css */

/*
   ================================================
   TABLE OF CONTENTS
   ================================================
   1. VARIABLES & GENERAL LAYOUT
   2. HEADER & NAVIGATION
   3. MESSAGES & ALERTS
   4. GITE NAVIGATION
   5. FORMS
   6. TABLES & DATA DISPLAY
   7. GITE SPECIFIC STYLES
   8. MISCELLANEOUS (BUTTONS, ETC.)
   9. RESPONSIVE DESIGN (MEDIA QUERIES)
*/

/* ================================
   1. VARIABLES & GENERAL LAYOUT
   ================================ */
:root {
    --admin-primary-color: #007bff;
    --admin-secondary-color: #6c757d;
    --admin-success-color: #28a745;
    --admin-danger-color: #dc3545;
    --admin-warning-color: #ffc107;
    --admin-header-bg: #343a40;
    --admin-nav-link-color: white;
    --admin-nav-hover-color: #007bff;
    --admin-dropdown-bg: #495057;
    --admin-dropdown-hover-bg: #5a6268;
    --admin-dropdown-text-color: white;
    --admin-light-bg: #f4f4f4;
    --admin-white-bg: #fff;
    --admin-border-color: #e0e0e0;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background-color: var(--admin-light-bg);
    color: #333;
    padding-top: 70px;
}

.container {
    background-color: var(--admin-white-bg);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    max-width: 1200px;
    margin: 20px auto;
}

/* ================================
   2. HEADER & NAVIGATION
   ================================ */
.admin-header {
    background-color: var(--admin-header-bg);
    color: var(--admin-nav-link-color);
    padding: 10px 20px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    align-items: center; 
    box-sizing: border-box;
    flex-wrap: wrap;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.admin-header.scrolled {
    background-color: #2a2e32;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.header-inner-wrapper {
    display: flex; 
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.admin-header h1 {
    margin: 0;
    font-size: 1.5em;
    color: var(--admin-primary-color);
}

.admin-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
    position: relative;
    z-index: 1001;
    width: 30px;
    height: 24px;
    flex-direction: column;
    justify-content: space-between;
}

.admin-menu-toggle .bar {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--admin-nav-link-color);
    border-radius: 2px;
    transition: all 0.3s ease-in-out;
}

.admin-menu-toggle.open .bar:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}
.admin-menu-toggle.open .bar:nth-child(2) {
    opacity: 0;
}
.admin-menu-toggle.open .bar:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

.admin-nav {
    display: flex;
    width: auto;
    margin-left: auto;
}

.admin-nav-ul { 
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
}

.admin-nav-ul li {
    margin-left: 20px;
    flex-shrink: 0;
    position: relative;
}

.admin-nav-ul li a {
    color: var(--admin-nav-link-color);
    text-decoration: none;
    font-weight: bold;
    padding: 5px 10px;
    display: flex; 
    align-items: center;
    height: 30px; 
    text-transform: uppercase; 
    transition: color 0.3s ease;
}

.admin-nav-ul li a:hover,
.admin-nav-ul li.active > a {
    color: var(--admin-nav-hover-color);
}

/* Dropdown specific styles */
.arrow-down {
    margin-left: 8px;
    border: solid;
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
    transition: transform 0.3s ease;
    border-color: var(--admin-nav-link-color);
}

.admin-nav-ul li.dropdown .dropbtn.open .arrow-down {
    transform: rotate(-135deg);
    -webkit-transform: rotate(-135deg);
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--admin-dropdown-bg);
    min-width: 180px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 10;
    border-radius: 4px;
    left: 0;
    padding: 10px 0;
    top: 100%;
}

.dropdown.active .dropdown-content {
    display: block !important;
}

.dropdown-content a {
    color: var(--admin-dropdown-text-color) !important;
    padding: 10px 15px;
    text-decoration: none;
    display: block;
    text-align: left;
    white-space: nowrap;
    font-weight: normal;
    font-size: 0.95em;
    text-transform: none;
}

.dropdown-content a:hover,
.dropdown-content a.active {
    background-color: var(--admin-dropdown-hover-bg);
    color: var(--admin-primary-color) !important;
}

/* ================================
   3. MESSAGES & ALERTS
   ================================ */
.message {
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid;
    border-radius: 5px;
    text-align: center;
}

.message.success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.message.error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.info-message {
    background-color: #e7f3fe;
    border-left: 6px solid #2196F3;
    margin: 20px 0;
    padding: 10px;
    color: #0c5460;
    font-size: 0.9em;
    border-radius: 4px;
}

/* ================================
   4. GITE NAVIGATION
   ================================ */
.gite-navigation {
    text-align: center;
    margin-bottom: 30px;
    padding: 10px;
    background-color: #e9ecef;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.gite-navigation a {
    display: inline-block;
    padding: 8px 15px;
    text-decoration: none;
    color: var(--admin-primary-color);
    border: 1px solid var(--admin-primary-color);
    border-radius: 4px;
    transition: background-color 0.3s, color 0.3s;
}

.gite-navigation a:hover {
    background-color: var(--admin-primary-color);
    color: white;
}

.gite-navigation a.active {
    background-color: var(--admin-primary-color);
    color: white;
    font-weight: bold;
    cursor: default;
}

@media (max-width: 768px) {
    .gite-navigation {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    .gite-navigation a {
        flex: 1 1 100%; /* S'assure que chaque bouton occupe toute la largeur disponible */
        margin: 5px 0; /* Ajoute un peu d'espace vertical entre les boutons */
        text-align: center;
        box-sizing: border-box; /* Pour inclure padding et bordure dans le calcul de la largeur */
    }
}

/* ================================
   5. FORMS
   ================================ */
form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid var(--admin-border-color);
    border-radius: 8px;
    background-color: #f9f9f9;
}

form h3 {
    grid-column: 1 / -1;
    color: var(--admin-primary-color);
    margin-top: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group-full {
    grid-column: 1 / -1;
}

form label {
    margin-bottom: 5px;
    font-weight: bold;
}

form input[type="text"],
form input[type="email"],
form input[type="tel"],
form input[type="date"],
form input[type="number"],
form textarea,
form select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    width: 100%;
    box-sizing: border-box;
}

form .checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

form .checkbox-group input[type="checkbox"] {
    margin-right: 5px;
}

form button,
.button {
    background-color: var(--admin-success-color);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

form button:hover,
.button:hover {
    background-color: #218838;
}

.cancel-button {
    background-color: var(--admin-secondary-color);
    margin-left: 10px;
}

.cancel-button:hover {
    background-color: #5a6268;
}

.add-button-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.add-reservation-button {
    padding: 12px 25px; 
    background-color: var(--admin-success-color);
    color: white;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.add-reservation-button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}

/* ================================
   6. TABLES & DATA DISPLAY
   ================================ */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: var(--admin-white-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-radius: 8px;
    overflow: hidden;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: var(--admin-primary-color);
    color: white;
    font-weight: bold;
}

tr:hover {
    background-color: #f1f1f1;
}

.actions {
    white-space: nowrap;
}

.actions a {
    background-color: var(--admin-warning-color);
    color: #333;
    padding: 6px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9em;
    margin-right: 5px;
    transition: background-color 0.3s ease;
}

.actions a.delete {
    background-color: var(--admin-danger-color);
    color: white;
}

.actions a:hover {
    opacity: 0.9;
}

.actions a.delete:hover {
    background-color: #c82333;
}

/* Specific table column styles */
.reservation-table td:nth-child(6) {
    font-size: 0.85em;
}

.reservation-table .status-created {
    color: var(--admin-success-color);
    font-weight: bold;
}

/* ================================
   7. GITE SPECIFIC STYLES
   ================================ */
.gite-columns-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
}

.gite-info-wrapper {
    flex: 1 1 calc(33.333% - 20px);
    min-width: 300px;
    box-sizing: border-box;
    border: 1px solid var(--admin-border-color);
    padding: 20px;
    border-radius: 8px;
    background-color: var(--admin-white-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.gite-info-wrapper table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
}

.gite-info-wrapper th,
.gite-info-wrapper td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    font-size: 0.9em;
}

.gite-info-wrapper th {
    background-color: #3498db;
    color: white;
    font-weight: bold;
    white-space: nowrap;
}

.gite-info-wrapper tbody tr:nth-child(even) {
    background-color: #f8f8f8;
}

.gite-info-wrapper tbody tr:hover {
    background-color: #eef;
}

.gite-info-wrapper h2 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    display: block;
    text-align: center;
}

.no-data-message {
    text-align: center;
    padding: 10px;
    color: #777;
}

.modify-button-container {
    text-align: center;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid #eee;
    margin-top: 20px;
}

.gites-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 30px;
}

.gite-column {
    flex: 1 1 calc(33.333% - 20px);
    max-width: calc(33.333% - 20px);
    min-width: 300px;
    background-color: #fcfcfc;
    border: 1px solid var(--admin-border-color);
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.gite-column h3 {
    text-align: center;
    margin-top: 0;
    color: var(--admin-primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.gite-column .tarif-item {
    border: 1px solid var(--admin-border-color);
    border-radius: 6px;
    padding: 10px 15px;
    background-color: var(--admin-white-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
}

.gite-column .tarif-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.gite-column .tarif-item:last-child {
    margin-bottom: 0;
}

.gite-column .tarif-item .tarif-details {
    flex-basis: 65%;
    margin-right: 10px;
}

.gite-column .tarif-item .tarif-actions {
    flex-basis: auto;
    text-align: right;
    white-space: nowrap;
}

.gite-column .tarif-item strong {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-size: 0.95em;
}
.gite-column .tarif-item span {
    display: block;
    color: #555;
    font-size: 0.85em;
    margin-bottom: 2px;
}
.gite-column .tarif-item span:last-child {
    margin-bottom: 0;
}

.gite-column .tarif-actions a.button.edit-button {
    background-color: var(--admin-warning-color);
    color: #333;
    padding: 6px 10px;
    font-size: 0.8em;
    border-radius: 4px;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s ease;
}
.gite-column .tarif-actions a.button.edit-button:hover {
    background-color: #e0a800;
}

.container.gite-blanc {
    background-color: #e6f7ff;
}

.container.gite-rose {
    background-color: #ffb3d9;
}

.container.gite-rouge {
    background-color: #ff3b3b;
}

/* ================================
   8. MISCELLANEOUS
   ================================ */
.gap-ok {
    color: var(--admin-success-color);
    font-weight: bold;
}

.gap-sad {
    color: var(--admin-danger-color);
    font-weight: bold;
}

.gap-price-down {
    color: var(--admin-warning-color);
    font-weight: bold;
}

.gap-neutral {
    color: #333;
    font-weight: normal;
}

.gap-icon {
    margin-left: 5px;
    font-size: 0.9em;
}

.photo-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

.photo-item {
    position: relative;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 5px;
    overflow: hidden;
    width: 120px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.photo-item img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

.photo-item .remove-photo,
.photo-item .remove-single-photo {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: var(--admin-danger-color);
    color: white;
    border: 2px solid white;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 16px;
    line-height: 21px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.photo-item .remove-photo:hover,
.photo-item .remove-single-photo:hover {
    background-color: #c82333;
}

.single-photo-preview .photo-item {
    width: 200px;
    height: 150px;
}

.button-file-upload {
    display: inline-block;
    padding: 10px 15px;
    background-color: var(--admin-primary-color);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.3s ease;
}

.button-file-upload:hover {
    background-color: #0056b3;
}

/* ================================
   9. RESPONSIVE DESIGN
   ================================ */
@media (max-width: 992px) {
    .gite-info-wrapper {
        flex: 1 1 calc(50% - 20px);
    }
}

@media (max-width: 768px) {
    body {
        padding-top: 140px;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        padding-bottom: 0; 
    }

    .header-inner-wrapper {
        display: flex; 
        width: 100%;
        padding-bottom: 10px; 
        border-bottom: 1px solid rgba(255, 255, 255, 0.1); 
    }

    .admin-header h1 {
        font-size: 1.3em;
    }

    .admin-menu-toggle {
        display: flex;
    }

    .admin-nav {
        width: 100%;
        background-color: var(--admin-header-bg); 
        box-shadow: 0 5px 10px rgba(0,0,0,0.2);
        z-index: 999;
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        transition: max-height 0.3s ease-out, opacity 0.3s ease-out, transform 0.3s ease-out;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-10px);
        pointer-events: none;
    }

    .admin-nav.active {
        display: flex;
        flex-direction: column;
        max-height: 500px;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .admin-nav-ul {
        flex-direction: column;
        padding: 10px 0;
        align-items: flex-start;
        width: 100%;
    }

    .admin-nav-ul li {
        margin: 0;
        width: 100%;
        text-align: left; 
    }

    .admin-nav-ul li a {
        padding: 12px 20px;
        border-bottom: 1px solid #495057;
    }
    .admin-nav-ul li:last-child a {
        border-bottom: none;
    }
    .admin-nav-ul li a:hover,
    .admin-nav-ul li a.active {
        background-color: #495057;
        color: var(--admin-nav-hover-color);
    }

    .dropdown-content {
        position: static;
        box-shadow: none;
        width: 100%;
        background-color: var(--admin-dropdown-hover-bg);
        border-radius: 0;
        padding-left: 30px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
        opacity: 0;
        pointer-events: none;
    }

    .dropdown-content a {
        color: var(--admin-dropdown-text-color) !important; 
    }

    .dropdown-content a:hover,
    .dropdown-content a.active {
        background-color: var(--admin-secondary-color);
        color: var(--admin-primary-color) !important;
    }

    .dropdown:hover .dropdown-content {
        display: none;
    }

    .dropdown.active .dropdown-content {
        max-height: 500px;
        opacity: 1;
        pointer-events: auto;
    }

    .reservation-table thead, .tarifs-table thead {
        display: none;
    }

    .reservation-table, .reservation-table tbody, .reservation-table tr,
    .tarifs-table, .tarifs-table tbody, .tarifs-table tr {
        display: block;
        width: 100%;
    }

    .reservation-table td, .tarifs-table td {
        display: block;
        text-align: right;
        padding-left: 50%;
        position: relative;
        font-size: 14px;
        border-bottom: 1px solid #ddd;
    }

    .reservation-table td::before, .tarifs-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
    }

    .reservation-table tbody tr:first-child td[data-label="Écart"]::before {
        content: "";
    }

    .mouvement-row td.gite-cell {
        padding-left: 50%;
    }
    .mouvement-row td.gite-cell::before {
        content: attr(data-label);
    }

    .gite-columns-container {
        flex-direction: column;
        align-items: center;
    }
    .gite-info-wrapper {
        width: 100%;
        max-width: 450px;
        margin-bottom: 20px;
    }

    /* FORMS: Fix for stacking on mobile */
    form {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .form-group, .form-group-full {
        grid-column: 1 / -1;
        width: 100%;
    }

    .gite-navigation {
        flex-direction: column;
    }

    .gite-navigation a {
        display: block;
        margin: 5px auto;
        width: calc(100% - 10px);
    }
    .gites-grid {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    .gite-column {
        max-width: 95%;
        flex: 1 1 95%;
        margin-bottom: 0;
    }
    .gite-column .tarif-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
    }
    .gite-column .tarif-item .tarif-details {
        flex-basis: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    .gite-column .tarif-item .tarif-actions {
        flex-basis: 100%;
        text-align: left;
    }
    .gite-column .tarif-actions a.button.edit-button {
        width: 100%;
        margin-bottom: 5px;
    }
}

@media (max-width: 480px) {
    .admin-nav-ul li a {
        font-size: 1rem;
    }
    .admin-menu-toggle {
        font-size: 1.6rem;
    }
}

/* --- Bouton menu sandwich pour petits écrans --- */
.admin-header .admin-menu-toggle {
    display: none; /* Masqué par défaut sur les grands écrans */
}

@media (max-width: 768px) {
    .admin-header .admin-menu-toggle {
        display: block; /* Affiché uniquement sur les petits écrans */
        font-size: 2.5rem; /* Augmente la taille du caractère ☰ */
        line-height: 1; /* Aligne mieux le caractère */
        color: white; /* Couleur du caractère */
        background-color: transparent;
        border: none;
        padding: 10px 15px; /* Augmente la zone cliquable */
        cursor: pointer;
        position: absolute;
        top: 50%;
        right: 15px;
        transform: translateY(-50%);
        z-index: 1000; /* Assure que le bouton est au-dessus des autres éléments */
    }

    .admin-header .header-inner-wrapper {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 10px 15px;
    }
    
    .admin-header h1 {
        font-size: 1.5rem;
        margin: 0;
        white-space: nowrap; /* Empêche le titre de se couper */
        overflow: hidden;
        text-overflow: ellipsis; /* Ajoute des points de suspension si le titre est trop long */
    }

    /* Le menu lui-même doit être masqué et affiché avec du JS */
    .admin-nav {
        display: none;
    }
    .admin-nav.active {
        display: block;
        width: 100%;
        position: absolute;
        top: 60px; /* Ajustez selon la hauteur de votre header */
        left: 0;
        background-color: #333; /* Couleur de fond du menu ouvert */
    }
}