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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
    overflow-x: hidden;
}

/* Vidéo de fond pour la page de login */
.bg-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

/* Loader plein écran */
.admin-loader {
    position: fixed;
    inset: 0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    transition: opacity 0.3s ease;
}

.admin-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.admin-loader img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    animation: loader-bounce 1.2s infinite ease-in-out;
}

@keyframes loader-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

/* Layout principal */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #C41E3A 0%, #A01A2E 100%);
    /* Rouge Iturri */
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.sidebar-header {
    padding: 30px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.sidebar-header img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.sidebar-header p {
    font-size: 14px;
    opacity: 0.85;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: white;
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: white;
}

.menu-item.active {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: white;
    font-weight: 600;
}

.menu-icon {
    font-size: 20px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.menu-text {
    font-size: 15px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-info-sidebar span {
    font-weight: 500;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid white;
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-header {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.top-header h2 {
    font-size: 24px;
    color: #333;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info button {
    background: #C41E3A;
    /* Rouge Iturri */
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.user-info button:hover {
    background: #5568d3;
}

/* Page Content */
.page-content {
    display: none;
    padding: 30px;
    flex: 1;
}

.page-content.active {
    display: block;
}

/* Spécifique page de login: centrer le formulaire */
body.login-page .admin-layout {
    justify-content: center;
    align-items: center;
}

body.login-page .sidebar {
    background: transparent;
    box-shadow: none;
}

body.login-page .main-content {
    margin-left: 0;
    background: transparent;
}

body.login-page .top-header {
    background: transparent;
    border-bottom: none;
    box-shadow: none;
    justify-content: center;
}

body.login-page .page-content {
    display: flex;
    justify-content: center;
    align-items: center;
}

body.login-page .form-container {
    max-width: 420px;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #C41E3A 0%, #A01A2E 100%);
    /* Rouge Iturri */
    color: white;
    padding: 25px;
    border-radius: 10px;
    text-align: center;
}

.stat-card h3 {
    font-size: 14px;
    margin-bottom: 10px;
    opacity: 0.9;
}

.stat-card p {
    font-size: 32px;
    font-weight: bold;
}

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

.btn-primary {
    background: #C41E3A;
    /* Rouge Iturri */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

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

.item-actions {
    display: flex;
    gap: 8px;
    margin-left: 20px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.item-actions button {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 8px 12px;
}

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

.filters select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.items-list {
    display: grid;
    gap: 15px;
}

.item-card {
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.item-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.item-info {
    flex: 1;
}

.item-info h3 {
    margin-bottom: 5px;
    color: #333;
}

.item-info p {
    color: #666;
    font-size: 14px;
}

.item-actions {
    display: flex;
    gap: 8px;
    margin-left: 20px;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

.item-actions button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: fit-content;
}

.item-actions button i {
    font-size: 14px;
}

.item-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1);
}

.btn-edit,
.btn-delete {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-edit {
    background: #4caf50;
    color: white;
}

.btn-edit:hover {
    background: #45a049;
}

.btn-delete:hover {
    background: #da190b;
}

.btn-info {
    background: #2196f3;
    color: white;
}

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

.btn-success {
    background: #4caf50;
    color: white;
}

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

.btn-info,
.btn-warning,
.btn-success,
.btn-danger {
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-info:hover,
.btn-warning:hover,
.btn-success:hover,
.btn-danger:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Détail annonce */
.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.detail-main h3 {
    margin-bottom: 10px;
}

.detail-main p {
    margin-bottom: 6px;
    color: #555;
}

.detail-sidebar {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 16px;
}

.detail-sidebar h4 {
    margin-bottom: 10px;
}

.detail-label {
    font-weight: 500;
}

.detail-images {
    margin-top: 20px;
}

.detail-images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.detail-images-grid img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
}

/* Form Container */
.form-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 900px;
}

.form-container form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #C41E3A;
    /* Rouge Iturri */
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #4caf50;
    color: white;
}

.status-pending {
    background: #ff9800;
    color: white;
}

.status-inactive {
    background: #9e9e9e;
    color: white;
}

.status-rejected {
    background: #f44336;
    color: white;
}

.chart-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chart-section h3 {
    margin-bottom: 20px;
}

#categoryChart {
    margin-top: 20px;
}

.chart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    background: #f9f9f9;
    border-radius: 5px;
}

/* Image Preview */
.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
}

.image-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(244, 67, 54, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview-item .remove-btn:hover {
    background: rgba(244, 67, 54, 1);
}

.uploaded-images-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.uploaded-image-item {
    position: relative;
    width: 100px;
    height: 100px;
    border: 2px solid #4caf50;
    border-radius: 8px;
    overflow: hidden;
}

.uploaded-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.uploaded-image-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(244, 67, 54, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-progress {
    margin-top: 10px;
    padding: 10px;
    background: #f0f0f0;
    border-radius: 5px;
    display: none;
}

.upload-progress.active {
    display: block;
}

/* Modal (pour catégories uniquement) */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal-content {
    background: white;
    margin: 50px auto;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-content label {
    font-weight: 500;
    color: #333;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    font-family: inherit;
}

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

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

/* Responsive */
@media (max-width: 992px) {
    .admin-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }

    .main-content {
        margin-left: 0;
    }

    .top-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .form-container {
        max-width: 100%;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

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

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .item-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .item-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .item-actions .btn-edit,
    .item-actions .btn-delete,
    .item-actions .btn-secondary {
        width: auto;
    }

    .page-content {
        padding: 20px 15px;
    }

    body.login-page .page-content {
        padding: 20px;
    }
}

/* Styles pour la page de diagnostic */
.diagnostic-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
}

.health-status {
    transition: all 0.3s ease;
}

.diagnostic-tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.recent-errors {
    max-height: 500px;
    overflow-y: auto;
}

.errors-list {
    max-height: 500px;
    overflow-y: auto;
}

.errors-list::-webkit-scrollbar {
    width: 8px;
}

.errors-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.errors-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.errors-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.errors-by-category {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

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

    .errors-by-category {
        grid-template-columns: 1fr;
    }
}