/* css/style.css */

:root { 
    --primary-yellow: #ffd600; /* Le jaune de l'en-tête */
    --header-dark: #2c2c2c; /* Le gris foncé pour l'onglet actif */
    --bg-main: #f4f5f7; /* Le gris très clair du fond de page */
    --bg-sidebar: #ffffff; /* Le blanc de la barre latérale */
    --text-main: #333333;
    --text-muted: #888888;
    --accent-blue: #007bff; /* Pour le bouton "+" */
}

/* ANTI-DÉBORDEMENT ET COMPORTEMENT DE ZOOM FLUIDE */
html, body { 
    margin: 0; 
    font-family: 'Segoe UI', Roboto, sans-serif; 
    background-color: var(--bg-main); 
    color: var(--text-main);
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important; /* Coupe toute fuite horizontale */
    -webkit-text-size-adjust: 100%; /* Stabilise la taille du texte sur iOS */
}

/* =========================================
   HEADER (BARRE SUPÉRIEURE)
========================================= */
.top-header {
    display: flex;
    align-items: center;
    background-color: var(--primary-yellow);
    min-height: 60px; /* S'adapte si le texte zoome */
    height: auto;     
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    box-sizing: border-box;
}

.logo-area {
    width: 250px;
    padding: 0 20px;
    font-weight: bold;
    font-size: 1.1rem;
    line-height: 1.2;
    text-transform: uppercase;
    box-sizing: border-box;
}

.top-nav {
    display: flex;
    height: 100%;
    flex-wrap: wrap; /* Évite les chevauchements au zoom */
}

.top-nav a {
    display: flex;
    align-items: center;
    padding: 0 20px;
    color: var(--text-main);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.85rem;
    text-transform: uppercase;
    transition: background 0.2s;
}

.top-nav a.active {
    background-color: var(--header-dark);
    color: var(--primary-yellow);
}

.user-actions {
    margin-left: auto;
    padding-right: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.85rem;
    font-weight: bold;
    flex-wrap: wrap;
}

.user-actions a {
    color: var(--text-main);
    text-decoration: none;
}

/* =========================================
   LAYOUT PRINCIPAL
========================================= */
.main-layout { 
    display: flex; 
    padding-top: 60px; /* Compense la hauteur du header fixe */
    min-height: 100vh; 
    width: 100%;
    box-sizing: border-box;
}

/* =========================================
   SIDEBAR & TREE
========================================= */
.sidebar { 
    width: 280px; 
    background: var(--bg-sidebar); 
    padding: 20px 0; 
    box-sizing: border-box; 
    height: calc(100vh - 60px);
    position: fixed;
    overflow-y: auto;
    border-right: 1px solid #eef0f2;
    min-height: 0; /* Sécurité anti-zoom */
}

.tree-root { list-style: none; padding: 0; margin: 0; }
.tree-child { list-style: none; padding-left: 20px; margin: 0; display: none; }

.tree-item { 
    display: flex; 
    align-items: center; 
    padding: 10px 20px; 
    cursor: pointer; 
    font-size: 0.85rem; 
    color: var(--text-main);
    text-transform: uppercase;
    transition: all 0.2s ease;
    border-radius: 4px;
    margin: 2px 10px;
    gap: 10px; 
}

.tree-item:hover { 
    background-color: #f4f5f7; 
}

.tree-chevron {
    width: 16px;
    height: 16px;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    transition: transform 0.2s ease;
}

/* =========================================
   ZONE DE CONTENU & GRILLE (RESPONSIVE + ZOOM)
========================================= */
.content-area { 
    margin-left: 280px; 
    padding: 30px 40px; 
    flex-grow: 1;
    box-sizing: border-box;
    max-width: calc(100% - 280px); /* Contraint strictement la zone d'affichage sur PC */
}

.filter-bar { 
    background: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 30px; 
    display: flex; 
    gap: 15px; 
    align-items: center; 
    box-sizing: border-box;
}

.filter-bar select { 
    padding: 8px 15px; 
    border: 1px solid #ddd; 
    border-radius: 4px;
    background: #fafafa; 
}

.products-grid { 
    display: grid; 
    /* Utilisation de auto-fit intelligent : s'auto-organise tout seul si on zoom sans casser le layout */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 20px; 
    width: 100% !important;
    box-sizing: border-box;
}

/* Écrans PC standards : force les 5 colonnes d'origine si l'espace le permet */
@media screen and (min-width: 1300px) {
    .products-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.product-card { 
    position: relative;
    background: #fff; 
    border-radius: 8px; 
    overflow: hidden; 
    aspect-ratio: 1 / 1; 
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    width: 100%;
    box-sizing: border-box;
}

.product-card img { 
    width: 100%; 
    height: 100%; 
    object-fit: contain ; 
}

.product-info { 
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 30px 10px 10px 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 70%, rgba(0,0,0,0) 100%);
    box-sizing: border-box;
    max-height: 100%; 
    overflow: hidden;
}

.product-info h3 { 
    margin: 0; 
    font-size: 0.8rem; 
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
}

/* =========================================
   BOUTON D'ACTION FLOTTANT (FAB)
========================================= */
.floating-actions {
    position: fixed;
    bottom: 30px;
    right: 30px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

.btn-yellow {
    background-color: var(--primary-yellow);
    color: var(--text-main);
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-blue {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    font-size: 1.5rem;
    line-height: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================
   POPUP / MODAL (AMÉLIORÉ EN 2 COLONNES ASYMÉTRIQUES)
========================================= */
.modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.85); 
    justify-content: center; 
    align-items: center; 
    z-index: 1000; 
}

.modal-content { 
    background: #fff; 
    padding: 30px; 
    width: 950px; /*Pour la taille de modal double colonne*/ 
    max-width: 92%; 
    display: flex; 
    gap: 30px; 
    position: relative; 
    border-radius: 8px; 
    box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

/* Colonne Gauche : Image en haut, détails produit en bas */
.modal-left-col {
    width: 60%; 
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
}

.modal-image-wrapper {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f4f5f7;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
	position: relative;
	text-align: center;
}

.modal-image-wrapper img { 
    width: 100%; 
    height: 100%; 
    object-fit: contain ; 
}

.image-zoom-container {
	position: relative;
	overflow: hidden;
	cursor: zoom-in;
}
.zoom-img {
	transition: transform 0.3s ease;
	max-width: 100%;
	display: block;
	margin: 0 auto;
}

.modal-product-specs h2 {
    margin: 0 0 10px 0;
    font-size: 1.4rem;
    color: var(--header-dark);
}

.product-price-badge {
    font-size: 1.25rem;
    font-weight: bold;
    color: #28a745;
    margin-bottom: 15px;
}

.modal-product-specs p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #555;
    margin: 0 0 10px 0;
}

.product-contact-info {
    font-size: 0.85rem !important;
    color: var(--text-muted) !important;
    margin-top: 15px !important;
}

/* Colonne Droite : Formulaire complet ou invite de connexion */
.modal-right-col {
    width: 40%; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
}

.form-group-modal {
    margin-bottom: 12px;
    width: 100%;
}

.form-group-modal label {
    display: block;
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--header-dark);
}

.form-group-modal input, 
.form-group-modal textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    background: #fafafa;
    font-family: inherit;
    font-size: 0.9rem;
}

.form-group-modal input:focus, 
.form-group-modal textarea:focus {
    outline: none;
    border-color: var(--primary-yellow);
    background: #fff;
}

.btn-order-submit {
    background: var(--header-dark);
    color: var(--primary-yellow);
    padding: 12px;
    border: none;
    width: 100%;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    margin-top: 5px;
    transition: background 0.2s;
}

.btn-order-submit:hover {
    background: #000;
}

.close-modal { 
    position: absolute; 
    top: 15px; 
    right: 15px; 
    font-size: 1.5rem; 
    cursor: pointer; 
    color: #333; 
    font-weight: bold;
    z-index: 10;
}

.modal-login-prompt {
    text-align: center;
    background: #f8f9fa;
    padding: 25px 20px;
    border-radius: 6px;
    border: 1px solid #eef0f2;
}

.modal-login-prompt h3 {
    margin-top: 0;
    color: var(--header-dark);
    text-transform: uppercase;
    font-size: 1rem;
}

.modal-login-prompt p {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.5;
    margin-bottom: 20px;
}

.prompt-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-prompt-login {
    background: var(--header-dark);
    color: var(--primary-yellow);
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
}

.btn-prompt-register {
    background: #eee;
    color: #333;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
}

/* =========================================
   FORMULAIRES, CONNEXION & BOUTONS FERMETURE
========================================= */
.login-body {
    background-color: var(--bg-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    width: 100%;
}

.login-container {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 400px;
    border-top: 4px solid var(--primary-yellow);
    box-sizing: border-box;
}

.login-container h2 {
    text-align: center;
    color: var(--header-dark);
    margin-top: 0;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
    background: #fafafa;
    font-family: inherit;
    color: var(--text-main);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-yellow);
    background: #fff;
}

.btn-submit {
    background: var(--header-dark);
    color: var(--primary-yellow);
    padding: 15px;
    border: none;
    width: 100%;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.3s;
}

.btn-submit:hover {
    background: #000;
}

.msg.error {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid #ef9a9a;
}

.close-form-btn {
    position: absolute;
    top: 20px;       
    right: 20px;     
    font-size: 1.4rem;
    cursor: pointer;
    color: #333;
    text-decoration: none;
    font-weight: bold;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
    z-index: 10;     
}

.close-form-btn:hover {
    color: #dc3545;
    transform: scale(1.15);
}

/* =========================================
   TABLEAUX D'ADMINISTRATION
========================================= */
.admin-content {
    padding: 100px 40px 40px 40px; 
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.admin-table th, .admin-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.admin-table th {
    background-color: var(--header-dark);
    color: var(--primary-yellow);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.admin-table tr:hover {
    background-color: #f9f9f9;
}

/* =========================================
   BADGES DE STATUT UNIQUES
========================================= */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-block;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.1);
}

.status-en_attente { background-color: #ff3333 !important; color: #ffffff !important; }
.status-traitement { background-color: #ff9800 !important; color: #ffffff !important; }
.status-livraison { background-color: #a7f3d0 !important; color: #065f46 !important; }
.status-paye_livre { background-color: #fff3cd !important; color: #856404 !important; }
.status-paye_non_livre { background-color: #fce7f3 !important; color: #9d174d !important; }
.status-non_paye_livre { background-color: #ede9fe !important; color: #5b21b6 !important; }
.status-annulee { background-color: #6b7280 !important; color: #ffffff !important; }

/* =========================================
   RESPONSIVE DESIGN & SÉCURISATION DU ZOOM
========================================= */
@media screen and (max-width: 1024px) {
    .content-area { margin-left: 240px; max-width: calc(100% - 240px); padding: 20px; }
    .sidebar { width: 240px; }
    .products-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)) !important; gap: 15px; }
    .modal-content { width: 95%; padding: 20px; }
}

@media screen and (max-width: 768px) {
    html, body { width: 100% !important; max-width: 100% !important; overflow-x: hidden !important; }
    .top-header { position: relative !important; width: 100% !important; max-width: 100% !important; height: auto; flex-direction: column; box-sizing: border-box; }
    .logo-area { width: 100% !important; text-align: center; padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.1); }
    .top-nav { width: 100% !important; justify-content: center; flex-wrap: wrap; }
    .top-nav a { padding: 10px 12px; font-size: 0.8rem; }
    .user-actions { margin: 10px auto; padding-right: 0; justify-content: center; width: 100%; }
    .main-layout { padding-top: 0 !important; flex-direction: column !important; width: 100% !important; max-width: 100% !important; overflow-x: hidden !important; }
    .sidebar { position: relative !important; width: 100% !important; max-width: 100% !important; height: auto !important; max-height: 300px; border-right: none; border-bottom: 1px solid #eef0f2; padding: 10px 0; box-sizing: border-box; }
    .content-area { margin-left: 0 !important; padding: 15px 10px !important; width: 100% !important; max-width: 100% !important; box-sizing: border-box; }
    .filter-bar { flex-direction: column; align-items: flex-start; gap: 10px; padding: 10px; width: 100% !important; box-sizing: border-box; }
    .products-grid { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important; gap: 12px !important; width: 100% !important; max-width: 100% !important; }
    .product-card { width: 100% !important; max-width: 100% !important; }
    .modal-content { flex-direction: column !important; max-height: 85vh; width: 94% !important; margin: 0 auto; overflow-y: auto; gap: 15px; box-sizing: border-box; }
    .modal-left-col, .modal-right-col { width: 100% !important; }
    .modal-image-wrapper { max-height: 200px; }
}

@media screen and (max-width: 480px) {
    .top-nav a { width: 50%; text-align: center; justify-content: center; box-sizing: border-box; }
    .products-grid { grid-template-columns: 1fr !important; }
}

.modal-content.visitor-mode { max-width: 450px; display: flex; flex-direction: column; padding: 25px; }
.modal-content.visitor-mode .modal-left-col { width: 100% !important; }

@media screen and (max-width: 768px) {
    .modal-content.visitor-mode { width: 90% !important; max-height: 85vh; }
}

/* =========================================
   MENU DÉROULANT USER (DROPDOWN)
========================================= */
.user-actions { position: relative; display: flex; align-items: center; }
.user-dropdown { position: relative; display: inline-block; padding-bottom: 10px; margin-bottom: -10px; }
.user-dropdown .dropdown-menu { display: none; position: absolute; right: 0; top: 100%; background-color: #ffffff; min-width: 210px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.15); border-radius: 6px; z-index: 1000; overflow: hidden; border: 1px solid #e2e8f0; }
.user-dropdown .dropdown-item { color: #2c2c2c !important; padding: 12px 16px; text-decoration: none !important; display: block; font-size: 0.88rem; font-weight: 500; text-align: left; transition: background 0.2s ease; }
.user-dropdown .dropdown-item:hover { background-color: #f8fafc; }
.user-dropdown .dropdown-item.logout-item:hover { background-color: #fff5f5; }
.user-dropdown:hover .dropdown-menu { display: block; }

/* =========================================
   CONTENEUR DE ZOOM IMAGE CATALOGUE
========================================= */
.image-zoom-container { overflow: hidden; border-radius: 4px; background-color: #0a0a0a; margin-bottom: 20px; position: relative; width: 100%; }
.zoom-img { width: 100%; height: auto; max-height: 60vh; object-fit: contain; display: block; transition: transform 0.15s ease-out; transform-origin: center center; }

@media (hover: hover) and (pointer: fine) {
    .image-zoom-container:hover .zoom-img { cursor: zoom-in; }
}

/* =========================================
   STRUCTURES APPAREILS SOLAIRES (MODALE)
========================================= */
.sim-popup-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 100000; justify-content: center; align-items: center; }
.sim-popup-content { background: white; padding: 25px; border-radius: 8px; max-width: 1100px; width: 95%; max-height: 90vh; overflow-y: auto; position: relative; font-family: sans-serif; box-shadow: 0 5px 25px rgba(0,0,0,0.4); color: #333; }
.sim-popup-grid { display: grid; grid-template-columns: 1.2fr 1.8fr; gap: 20px; margin-top: 15px; }
@media (max-width: 850px) { .sim-popup-grid { grid-template-columns: 1fr; } }
.sim-box { background: #f8f9fa; padding: 15px; border-radius: 6px; border: 1px solid #eee; }
.sim-fg { margin-bottom: 12px; }
.sim-fg label { display: block; font-weight: bold; margin-bottom: 4px; font-size: 0.8rem; text-transform: uppercase; color: #555; }
.sim-ctrl { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-weight: bold; font-size: 0.85rem; }
.sim-row-inline { display: flex; gap: 6px; }
.sim-section-res { margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px dashed #eee; }
.sim-list-res { list-style: none; padding: 0; margin: 0; }
.sim-list-res li { padding: 4px 0; border-bottom: 1px solid #f9f9f9; display: flex; justify-content: space-between; font-size: 0.85rem; }
.sub-modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 100005; justify-content: center; align-items: center; }
.sub-modal-content { background: white; padding: 20px; border-radius: 6px; max-width: 550px; width: 90%; max-height: 80vh; overflow-y: auto; position: relative; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.btn-sim-action { border: none; padding: 10px; border-radius: 4px; cursor: pointer; font-weight: bold; width: 100%; text-transform: uppercase; font-size: 0.8rem; margin-top: 10px; }
.app-category { margin-bottom: 12px; background: #fafafa; padding: 8px; border-radius: 4px; border: 1px solid #eee; }
.app-category h4 { margin: 0 0 6px 0; color: #007bff; font-size: 0.85rem; text-transform: uppercase; }
.app-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: 0.8rem; }
.app-qty { width: 45px; padding: 2px; text-align: center; border: 1px solid #ccc; border-radius: 3px; }