:root {
    --primary-color: #4eb848;
    --primary-dark: #358930;
    --secondary-color: #6c757d;
    --accent-color: #F26522;
    --dark-bg: #212529;
    --light-bg: #f8f9fa;
    --text-dark: #212529;
    --text-light: #6c757d;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease-in-out;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--light-bg);
}

/* Skip link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* Navigation Styles */
.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem 0;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    transition: var(--transition);
}

.navbar-brand:hover {
    transform: translateY(-2px);
}

.nav-link {
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    margin: 0 0.25rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    position: relative;
    color: white !important;
}

.nav-link:hover,
.nav-link:focus {
    background-color: rgba(78, 184, 72, 0.3);
    transform: translateY(-2px);
    color: white !important;
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-link:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem 0;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2.5rem 0;
    margin-bottom: 3rem;
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 100%;
    height: 200%;
    background: rgba(255, 255, 255, 0.05);
    transform: rotate(15deg);
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    animation: fadeInUp 0.8s ease-out;
}

.hero p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.95;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

/* Cards */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    height: 100%;
    overflow: hidden;
}

.card:not(.gallery-card) {
    height: auto;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.2);
}

.card:focus-within {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-weight: 600;
    padding: 1rem 1.5rem;
    border-bottom: none;
}

.card-body {
    padding: 1.5rem;
}

.card-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    transition: var(--transition);
    border: none;
}

.btn:focus {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(13, 110, 253, 0.3);
}

.btn-outline-light:hover {
    transform: translateY(-2px);
}

/* Forms */
.form-control,
.form-select {
    border-radius: var(--border-radius);
    border: 2px solid #dee2e6;
    padding: 0.75rem 1rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
    outline: none;
}

.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

/* Footer */
.footer {
    margin-top: auto;
    background: var(--dark-bg) !important;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

.social-links a {
    transition: var(--transition);
    display: inline-block;
}

.social-links a:hover,
.social-links a:focus {
    transform: translateY(-3px);
    color: var(--accent-color) !important;
    outline: 2px solid var(--accent-color);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Utility Classes */
.section-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-dark);
    position: relative;
    padding-bottom: 1rem;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 2px;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.8s ease-out;
}

/* Accessibility Improvements */
*:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid var(--text-dark);
    }

    .btn {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Responsive Design */
@media (max-width: 991.98px) {
    .hero h1 {
        font-size: 2.5rem;
    }

    .section-title {
        font-size: 2rem;
    }

    .nav-link {
        margin: 0.25rem 0;
    }
}

@media (max-width: 767.98px) {
    .hero {
        padding: 2rem 0;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero p {
        font-size: 1.1rem;
    }

    .section-title {
        font-size: 1.75rem;
    }
}

@media (max-width: 575.98px) {
    .hero h1 {
        font-size: 1.75rem;
    }

    .card-icon {
        font-size: 2.5rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .footer,
    .btn {
        display: none;
    }

    main {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
        page-break-inside: avoid;
    }
}

/* AI Score Calculator Specific Styles */
.aiscore-results-col {
    display: flex;
    flex-direction: column;
}

.aiscore-results-col .card {
    height: auto !important;
}

.aiscore-card-compact {
    flex-shrink: 0;
}

.aiscore-card-fill {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.aiscore-card-fill .card-body {
    display: flex;
    flex-direction: column;
}

.aiscore-badge-container {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ratio inputs with flexible layout */
.ratio-inputs-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.ratio-input-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Give more space to labels with longer text */
.ratio-input-item--wide {
    flex: 1.4 1 0;
    min-width: 0;
}

.ratio-input-item .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    min-height: 2.6rem;
    display: flex;
    align-items: flex-end;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .ratio-input-item {
        flex: 1 1 calc(50% - 0.375rem);
        min-width: calc(50% - 0.375rem);
    }

    .ratio-input-item--wide {
        flex: 1 1 calc(50% - 0.375rem);
        min-width: calc(50% - 0.375rem);
    }
}

@media (max-width: 576px) {
    .ratio-input-item,
    .ratio-input-item--wide {
        flex: 1 1 100%;
        min-width: 100%;
    }
}


/* Gallery Styles */
.gallery-card {
    position: relative;
    transition: var(--transition);
    overflow: hidden;
}

.gallery-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.2);
}

.gallery-image-wrapper {
    position: relative;
    overflow: hidden;
    background: var(--light-bg);
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: var(--transition);
    cursor: pointer;
}

.gallery-card:hover .gallery-image {
    transform: scale(1.05);
}

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.gallery-card:hover .gallery-overlay,
.gallery-card:focus-within .gallery-overlay {
    opacity: 1;
}

.gallery-preview-btn {
    transform: scale(0.8);
    transition: var(--transition);
}

.gallery-card:hover .gallery-preview-btn {
    transform: scale(1);
}

.gallery-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
}

.gallery-checkbox .form-check-input {
    width: 1.5rem;
    height: 1.5rem;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.gallery-checkbox .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.gallery-item.selecting .gallery-card {
    cursor: pointer;
}

.gallery-item.selected .gallery-card {
    outline: 3px solid var(--primary-color);
    outline-offset: -3px;
}

/* Lightbox */
.lightbox-image {
    max-height: 70vh;
    object-fit: contain;
}

.modal-xl {
    max-width: 1200px;
}

.carousel-caption {
    background: rgba(0, 0, 0, 0.7);
    padding: 1rem;
    border-radius: var(--border-radius);
}

/* Download buttons */
.download-single-btn {
    transition: var(--transition);
}

.download-single-btn:hover {
    transform: translateY(-2px);
}

/* Selection mode */
.selection-mode .gallery-checkbox {
    display: block !important;
}

.selection-mode .gallery-overlay {
    opacity: 0 !important;
}

/* Visually hidden but accessible */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Loading state */
.gallery-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Metric colors for accessibility */
.metric-color-pi {
    color: #1565c0;
}

.metric-color-cac {
    color: #b45309;
}

.metric-color-mf {
    color: #c62828;
}

/* Cookie Banner Styles */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-top: 3px solid var(--primary-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    padding: 1.5rem;
    z-index: 9999;
    animation: slideUp 0.4s ease-out;
    transition: opacity 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cookie-banner-content {
    max-width: 1200px;
    margin: 0 auto;
}

.cookie-banner-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

.cookie-banner-text {
    color: #495057;
    margin-bottom: 1rem;
    line-height: 1.6;
}

.cookie-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.cookie-detailed {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

.cookie-category {
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    border-left: 3px solid var(--primary-color);
}

.cookie-category .form-check-label {
    cursor: pointer;
    user-select: none;
}

.cookie-category .form-check-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cookie-category .form-check-input:disabled + label {
    cursor: not-allowed;
}

/* Responsive cookie banner */
@media (max-width: 767.98px) {
    .cookie-banner {
        padding: 1rem;
    }
    
    .cookie-banner-title {
        font-size: 1.1rem;
    }
    
    .cookie-options {
        flex-direction: column;
        align-items: stretch;
    }
    
    .cookie-options .btn {
        width: 100%;
        margin: 0 0 0.5rem 0 !important;
    }
}

/* Cookie Management Button (floating button) */
.cookie-manage-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.cookie-manage-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    background: linear-gradient(135deg, #0056b3 0%, var(--primary-color) 100%);
}

.cookie-manage-btn:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 3px;
}

.cookie-manage-btn:active {
    transform: scale(0.95);
}

/* Force hide cookie banner */
.cookie-banner-force-hide {
    display: none !important;
    opacity: 0 !important;
}

@media (max-width: 767.98px) {
    .cookie-manage-btn {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
        bottom: 15px;
        right: 15px;
    }
}

/* Responsive adjustments for gallery */
@media (max-width: 767.98px) {
    .gallery-image-wrapper {
        aspect-ratio: 1 / 1;
    }

    .modal-xl {
        max-width: 100%;
        margin: 0.5rem;
    }
}

/* Print only modal content when printing from modal */
@media print {
    body.modal-open > *:not(.modal) {
        display: none !important;
    }

    body.modal-open .modal {
        position: absolute;
        left: 0;
        top: 0;
        margin: 0;
        padding: 0;
    }

    .modal-dialog {
        max-width: 100% !important;
        margin: 0 !important;
    }

    .modal-content {
        border: none !important;
        box-shadow: none !important;
    }

    .modal-header,
    .modal-footer {
        display: none !important;
    }

    .modal-body {
        padding: 20px !important;
    }

    .modal-backdrop {
        display: none !important;
    }
}

/* Progress bar styling */
.progress {
    height: 2rem;
}

.progress-bar {
    line-height: 2rem;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Print styles for aiscorec page */
@media print {
    /* Masquer les éléments non nécessaires à l'impression */
    .no-print,
    nav,
    footer,
    .hero,
    .btn,
    button {
        display: none !important;
    }

    /* Afficher les éléments print-only */
    .print-only {
        display: block !important;
    }

    /* Optimiser l'affichage pour l'impression */
    body {
        background: white !important;
        color: black !important;
    }

    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    .card-header {
        background-color: #f8f9fa !important;
        color: black !important;
        border-bottom: 1px solid #dee2e6 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Assurer que les couleurs des métriques sont visibles */
    .text-primary,
    .text-success,
    .text-info,
    .text-danger,
    .metric-color-pi,
    .metric-color-cac,
    .metric-color-mf {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Optimiser la mise en page */
    .row {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    .accordion-body .row {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    .accordion-body .col-6 {
        width: 50% !important;
        flex: 0 0 50% !important;
    }

    .col-lg-6 {
        width: 100% !important;
        margin-bottom: 1rem;
    }

    table {
        border: 1px solid #dee2e6;
        page-break-inside: avoid;
    }

    /* Afficher les métriques moyennes sur une ligne */
    .average-metrics-grid {
        display: flex !important;
        flex-wrap: wrap !important;
    }

    .average-metrics-grid > .col-6 {
        width: 50% !important;
        flex: 0 0 50% !important;
    }

    /* Saut de page avant chaque run (sauf le premier) */
    .accordion-item:not(:first-child) {
        page-break-before: always !important;
    }

    /* Saut de page avant le bloc des métriques moyennes */
    .average-metrics-row {
        page-break-before: always !important;
    }

    /* Forcer l'expansion des accordéons à l'impression */
    .accordion-collapse {
        display: block !important;
        height: auto !important;
        visibility: visible !important;
    }

    .accordion-item {
        page-break-inside: avoid;
    }

    .accordion-button {
        background-color: #f8f9fa !important;
        color: black !important;
    }

    .accordion-button::after {
        display: none !important;
    }

    /* S'assurer que les images sont imprimées */
    img {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        max-width: 100%;
    }

    /* Améliorer la visibilité du pourcentage dans la barre de progression */
    .progress-bar {
        color: #fff !important;
        font-weight: bold !important;
        font-size: 1.1rem !important;
        line-height: 2rem !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .progress {
        background-color: #e9ecef !important;
        border: 1px solid #dee2e6 !important;
        height: 2rem !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
