/* Reset et base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1600px; /* allow wider workspace for large tables */
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    text-align: center;
    backdrop-filter: blur(10px);
}

header h1 {
    color: #2c3e50;
    font-size: 2.5em;
    margin-bottom: 10px;
}

header h1 i {
    color: #3498db;
    margin-right: 15px;
}

header p {
    color: #7f8c8d;
    font-size: 1.1em;
}

.header-actions {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.admin-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-links .btn {
    font-size: 0.9em;
    padding: 8px 12px;
}

/* Inputs génériques pour la gestion du stock */
.input {
    padding: 8px 10px;
    border: 1px solid #ccd5e0;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #222;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}
.input-compact { min-width: 120px; }
.select-compact { min-width: 140px; }
.textarea-compact { min-width: 180px; min-height: 56px; }

/* Badge MAC */
.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: #eef2f7;
    color: #1f2937;
    border: 1px solid #e1e8f0;
}
.badge-mac { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

/* Statuts (etat) badges */
.badge.status { border-radius: 8px; padding: 4px 8px; font-size: 12px; }
.badge.status.status-0 { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge.status.status-1 { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.badge.status.status-2 { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.badge.status.status-3 { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* Table jolie */
.table-responsive {
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    /* keep overflow visible so content can wrap instead of forcing horizontal scroll */
    overflow-x: visible;
    overflow-y: hidden;
    margin-top: 15px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    /* allow the table to distribute columns and wrap cell content instead of forcing horizontal scroll */
    table-layout: fixed;
}
.data-table thead th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    color: #334155;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    z-index: 1;
    font-size: 13px;
}
.data-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    font-size: 13px;
    white-space: normal; /* allow wrapping */
    word-break: break-word;
}

/* Make form controls inside table cells fit and align nicely */
.data-table td .input,
.data-table td select,
.data-table td textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 13px;
}

/* Tighter compact sizes for table context */
.data-table .input-compact { min-width: 90px; padding:6px 8px; }
.data-table .select-compact { min-width: 120px; padding:6px 8px; }
.data-table .textarea-compact { min-width: 140px; padding:6px 8px; }

/* MAC badge: keep it compact and truncate long values */
.badge-mac { max-width: 140px; display:inline-block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Reduce header padding slightly to fit more columns */
.data-table thead th { padding: 8px 10px; }

/* Allow some columns to remain narrow (actions) */
.row-actions { width: 1%; white-space: nowrap; }
.data-table tbody tr:nth-child(odd) { background: #ffffff; }
.data-table tbody tr:nth-child(even) { background: #fbfdff; }
.row-actions { white-space: nowrap; }
.btn-compact { padding: 8px 12px; font-size: 14px; }

/* Toolbar au-dessus du tableau */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    padding: 8px 10px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
    margin-bottom: 10px;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; }
.toolbar-left i { color: #64748b; }
.toolbar .hint { color: #64748b; font-size: 12px; }

/* Pagination */
.pager { display: inline-flex; align-items: center; gap: 8px; }
.pager-info { color: #475569; font-weight: 600; }

/* Autocomplete suggestions */
.autocomplete-dropdown {
    position: absolute;
    top: 66px; /* approx under the input */
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e1e8f0;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 1000;
    max-height: 260px;
    overflow-y: auto;
    display: none;
}

.autocomplete-item {
    padding: 10px 12px;
    font-size: 14px;
    color: #1f2937;
    cursor: pointer;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: #f1f5f9;
}

/* Alertes */
.alert {
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.alert i {
    margin-right: 10px;
    font-size: 1.2em;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-success .fas.fa-envelope-check {
    color: #27ae60;
}

.alert-success .fas.fa-exclamation-triangle {
    color: #f39c12;
}

/* Formulaire */
.installation-form {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.form-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid #ecf0f1;
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

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

.form-section h2 i {
    margin-right: 10px;
    color: #3498db;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #7f8c8d;
    font-size: 0.9em;
}

/* Upload de photos */
.photo-upload-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

@media (max-width: 768px) {
    .photo-upload-container {
        grid-template-columns: 1fr;
    }
}

.upload-area {
    border: 3px dashed #3498db;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(52, 152, 219, 0.05);
}

.upload-area:hover {
    background: rgba(52, 152, 219, 0.1);
    border-color: #2980b9;
}

.upload-area i {
    font-size: 3em;
    color: #3498db;
    margin-bottom: 15px;
    display: block;
}

.upload-area p {
    font-size: 1.1em;
    color: #2c3e50;
    margin-bottom: 5px;
}

.upload-area small {
    color: #7f8c8d;
}

input[type="file"] {
    display: none;
}

.image-preview {
    margin-top: 15px;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.image-info {
    margin-top: 10px;
    font-size: 0.9em;
    color: #7f8c8d;
}

.filename {
    display: block;
    font-weight: 500;
}

.filesize {
    display: block;
    margin-top: 2px;
}

/* Boutons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
    margin-bottom: 10px;
}

.btn i {
    margin-right: 8px;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(149, 165, 166, 0.3);
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

.form-actions {
    text-align: center;
    padding-top: 20px;
}

/* Page d'administration */
.stats-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 20px; 
    margin-bottom: 30px; 
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.stat-card.active {
    background: #d1ecf1;
    border: 2px solid #3498db;
    transform: translateY(-2px);
}

.stat-card.active i {
    color: #2980b9;
}

/* Styles pour les filtres */
.filter-buttons {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.filter-buttons h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    font-size: 1.2em;
}

.filter-buttons h3 i {
    margin-right: 10px;
    color: #3498db;
}

.filter-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-tab {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: #f8f9fa;
    color: #6c757d;
    text-decoration: none;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
}

.filter-tab:hover {
    background: #e9ecef;
    color: #495057;
    transform: translateY(-1px);
}

.filter-tab.active {
    background: #3498db;
    color: white;
    border-color: #2980b9;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.filter-tab i {
    margin-right: 8px;
    font-size: 1.1em;
}

.filter-info {
    background: #d1ecf1;
    color: #2980b9;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
    display: flex;
    align-items: center;
}

.filter-info i {
    margin-right: 10px;
}

.stat-card i {
    font-size: 2.5em;
    margin-right: 15px;
    color: #3498db;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
}

.stat-label {
    color: #7f8c8d;
    font-size: 0.9em;
}

.installations-grid {
    display: grid;
    gap: 20px;
}

.installation-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.card-header h3 {
    color: #2c3e50;
    font-size: 1.3em;
}

.status-badge {
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.status-badge i {
    margin-right: 5px;
}

.status-pending {
    background: #fff3cd;
    color: #856404;
}

.status-validated {
    background: #d4edda;
    color: #155724;
}

.card-content {
    margin-bottom: 20px;
}

.info-section {
    margin-bottom: 20px;
}

.info-section p {
    margin-bottom: 8px;
    color: #34495e;
}

.photos-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .photos-section {
        grid-template-columns: 1fr;
    }
}

.photo-item h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1em;
}

.photo-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.photo-item img:hover {
    transform: scale(1.05);
}

/* Styles pour les miniatures */
.thumbnail-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

.thumbnail {
    width: 100%;
    height: 240px !important;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.thumbnail:hover {
    transform: scale(1.05);
    border-color: #3498db;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.thumbnail-container::after {
    content: "🔍 Cliquer pour agrandir";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    font-size: 0.8em;
    padding: 8px 5px 5px;
    text-align: center;
    border-radius: 0 0 8px 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.thumbnail-container:hover::after {
    opacity: 1;
}

.comments-section {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.comments-section h4 {
    color: #2c3e50;
    margin-bottom: 10px;
}

.card-actions {
    text-align: center;
    padding-top: 15px;
    border-top: 2px solid #ecf0f1;
}

/* Boutons d'aide */
.help-btn {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    margin-left: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    transition: all 0.3s ease;
    vertical-align: middle;
}

.help-btn:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.help-btn i {
    font-size: 0.9em;
}

/* Modal pour les images */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #3498db;
}

/* Modal d'aide pour les exemples de photos */
.photo-example-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
}

.example-modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.example-modal-header {
    background: linear-gradient(135deg, #3498db, #2ecc71);
    color: white;
    padding: 20px;
    border-radius: 8px 8px 0 0;
    position: relative;
}

.example-modal-header h3 {
    margin: 0;
    font-size: 1.3em;
}

.close-example {
    position: absolute;
    top: 15px;
    right: 20px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-example:hover {
    color: #f39c12;
}

.modal-body {
    padding: 20px;
}

.example-images {
    margin-bottom: 20px;
    text-align: center;
}

.example-image-container {
    display: inline-block;
    margin: 10px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background: white;
}

.example-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    display: block;
    border-radius: 8px 8px 0 0;
}

.example-caption {
    padding: 10px;
    margin: 0;
    font-size: 0.9em;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.example-section {
    background: #f8f9fa;
    padding: 15px;
    margin: 15px 0;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.example-section h4 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
}

.example-section ul {
    margin: 0;
    padding-left: 20px;
}

.example-section li {
    margin: 5px 0;
}

.example-section li strong {
    color: #2c3e50;
}

.example-tip {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
}

.example-tip i {
    margin-right: 8px;
}

.text-danger {
    color: #e74c3c;
}

.text-info {
    color: #3498db;
}

.example-placeholder {
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    padding: 40px 20px;
    text-align: center;
    border-radius: 8px;
    color: #2c3e50;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.example-placeholder i {
    font-size: 3em;
    margin-bottom: 15px;
    color: #3498db;
}

.example-placeholder p {
    margin: 0;
    font-size: 1.1em;
    line-height: 1.4;
    font-weight: 500;
}

/* Email input container avec bouton d'effacement */
.email-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.email-input-container input {
    flex: 1;
    padding-right: 45px;
}

.clear-email-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
    z-index: 10;
}

.clear-email-btn:hover {
    background: #e74c3c;
    color: white;
}

.text-success {
    color: #27ae60;
}

#clear-email-link {
    color: #e74c3c;
    text-decoration: none;
    font-weight: 500;
}

#clear-email-link:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .example-modal-content {
        width: 95%;
        margin: 5% auto;
        max-height: 90vh;
    }
    
    .example-modal-header {
        padding: 15px;
    }
    
    .example-modal-header h3 {
        font-size: 1.1em;
        padding-right: 40px;
    }
    
    .close-example {
        font-size: 24px;
        top: 12px;
        right: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .example-image {
        max-height: 200px;
    }
    
    .help-btn {
        width: 20px;
        height: 20px;
        font-size: 0.7em;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .installation-form {
        padding: 20px;
    }
    
    .form-section h2 {
        font-size: 1.3em;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .status-badge {
        margin-top: 10px;
    }
}

@media (max-width: 480px) {
    .btn {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    .upload-area {
        padding: 20px 10px;
    }
    
    .upload-area i {
        font-size: 2em;
    }
}

/* Stock: highlight installed rows (etat=1) */
.stock-row.installed td {
    background: #f0fdf4; /* light green */
}
.stock-row.installed {
    box-shadow: inset 3px 0 0 0 #34d399; /* emerald accent */
}
.stock-row.installed .badge-mac {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

/* Stock: highlight pending exit rows */
.stock-row.pending-exit td {
    background: #fef2f2; /* light red */
}
.stock-row.pending-exit {
    box-shadow: inset 3px 0 0 0 #ef4444; /* red accent */
}
.stock-row.pending-exit .badge-mac {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}
