/*
 * Akili Motor - Système Responsive Universel
 * Compatible avec tous les téléphones et marques
 * Optimisé pour iOS, Android, Samsung, Huawei, Xiaomi, etc.
 */

/* ===========================================
   RESET ET BASE RESPONSIVE
   =========================================== */

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    line-height: var(--line-height-base);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================================
   CONTAINERS RESPONSIVE
   =========================================== */

.container-fluid {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

.container {
    width: 100%;
    max-width: 1200px;
    padding-left: 15px;
    padding-right: 15px;
    margin-left: auto;
    margin-right: auto;
}

/* ===========================================
   GRILLE RESPONSIVE FLEXIBLE
   =========================================== */

.row {
    display: flex;
    flex-wrap: wrap;
    margin-left: -15px;
    margin-right: -15px;
}

.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
.col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
    position: relative;
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    flex: 0 0 auto;
}

/* Colonnes spécifiques */
.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-9 { flex: 0 0 75%; max-width: 75%; }
.col-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
.col-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

/* ===========================================
   TYPOGRAPHIE RESPONSIVE
   =========================================== */

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* ===========================================
   NAVIGATION RESPONSIVE
   =========================================== */

.navbar {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: var(--bg-primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    margin-right: 1rem;
    font-size: 1.25rem;
    text-decoration: none;
    white-space: nowrap;
}

.navbar-nav {
    display: flex;
    flex-direction: column;
    padding-left: 0;
    margin-bottom: 0;
    list-style: none;
}

.navbar-nav .nav-link {
    padding-right: 0;
    padding-left: 0;
}

.navbar-collapse {
    flex-basis: 100%;
    flex-grow: 1;
    align-items: center;
}

.navbar-toggler {
    padding: 0.25rem 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
    background-color: transparent;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 0.375rem;
    color: rgba(0,0,0,0.5);
}

.navbar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
}

/* ===========================================
   BOUTONS RESPONSIVE
   =========================================== */

.btn {
    display: inline-block;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    border-radius: var(--border-radius);
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    color: #fff;
    background-color: var(--akili-primary);
    border-color: var(--akili-primary);
}

.btn-secondary {
    color: #fff;
    background-color: var(--akili-secondary);
    border-color: var(--akili-secondary);
}

.btn-success {
    color: #fff;
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-lg {
    padding: 0.5rem 1rem;
    font-size: 1.25rem;
    border-radius: var(--border-radius-lg);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: var(--border-radius);
}

/* ===========================================
   FORMULAIRES RESPONSIVE
   =========================================== */

.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    background-clip: padding-box;
    border: 1px solid #ced4da;
    appearance: none;
    border-radius: var(--border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

/* ===========================================
   CARTES RESPONSIVE
   =========================================== */

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: var(--bg-primary);
    background-clip: border-box;
    border: 1px solid rgba(0,0,0,0.125);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
}

.card-body {
    flex: 1 1 auto;
    padding: 1rem;
}

.card-header {
    padding: 0.5rem 1rem;
    margin-bottom: 0;
    background-color: rgba(0,0,0,0.03);
    border-bottom: 1px solid rgba(0,0,0,0.125);
    border-top-left-radius: calc(var(--border-radius-lg) - 1px);
    border-top-right-radius: calc(var(--border-radius-lg) - 1px);
}

.card-footer {
    padding: 0.5rem 1rem;
    background-color: rgba(0,0,0,0.03);
    border-top: 1px solid rgba(0,0,0,0.125);
    border-bottom-left-radius: calc(var(--border-radius-lg) - 1px);
    border-bottom-right-radius: calc(var(--border-radius-lg) - 1px);
}

.card-title {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-weight: 500;
}

.card-text {
    margin-top: 0;
    margin-bottom: 1rem;
}

/* ===========================================
   IMAGES RESPONSIVE
   =========================================== */

.img-fluid {
    max-width: 100%;
    height: auto;
}

.img-responsive {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ===========================================
   UTILITAIRES RESPONSIVE
   =========================================== */

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }

.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.m-0 { margin: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

/* ===========================================
   MEDIA QUERIES - MOBILE FIRST
   =========================================== */

/* Extra small devices (phones, 576px and down) */
@media (max-width: 575.98px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    h4 { font-size: 1.25rem; }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    /* Navigation mobile */
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--bg-primary);
        border-top: 1px solid rgba(0,0,0,0.1);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 1000;
    }

    .navbar-nav {
        padding: 0.5rem 0;
    }

    .navbar-nav .nav-item {
        margin: 0.25rem 0;
    }

    .navbar-nav .nav-link {
        padding: 0.5rem 1rem;
        color: var(--text-primary) !important;
    }
}

/* Small devices (tablets, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }

    .col-sm-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-sm-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-sm-3 { flex: 0 0 25%; max-width: 25%; }
    .col-sm-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-sm-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-sm-6 { flex: 0 0 50%; max-width: 50%; }
    .col-sm-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-sm-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-sm-9 { flex: 0 0 75%; max-width: 75%; }
    .col-sm-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-sm-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-sm-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }

    .col-md-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-md-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-md-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
    .col-md-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-md-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-md-9 { flex: 0 0 75%; max-width: 75%; }
    .col-md-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-md-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-md-12 { flex: 0 0 100%; max-width: 100%; }

    .navbar-expand-md .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }

    .navbar-expand-md .navbar-nav {
        flex-direction: row;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }

    .col-lg-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-lg-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-lg-3 { flex: 0 0 25%; max-width: 25%; }
    .col-lg-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-lg-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-lg-6 { flex: 0 0 50%; max-width: 50%; }
    .col-lg-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-lg-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-lg-9 { flex: 0 0 75%; max-width: 75%; }
    .col-lg-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-lg-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-lg-12 { flex: 0 0 100%; max-width: 100%; }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }

    .col-xl-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
    .col-xl-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
    .col-xl-3 { flex: 0 0 25%; max-width: 25%; }
    .col-xl-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
    .col-xl-5 { flex: 0 0 41.666667%; max-width: 41.666667%; }
    .col-xl-6 { flex: 0 0 50%; max-width: 50%; }
    .col-xl-7 { flex: 0 0 58.333333%; max-width: 58.333333%; }
    .col-xl-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
    .col-xl-9 { flex: 0 0 75%; max-width: 75%; }
    .col-xl-10 { flex: 0 0 83.333333%; max-width: 83.333333%; }
    .col-xl-11 { flex: 0 0 91.666667%; max-width: 91.666667%; }
    .col-xl-12 { flex: 0 0 100%; max-width: 100%; }
}

/* ===========================================
   APPAREILS SPÉCIFIQUES - OPTIMISATIONS
   =========================================== */

/* iPhone et iOS */
@media screen and (max-device-width: 896px) and (-webkit-min-device-pixel-ratio: 2) {
    /* Ajustements pour iPhone X, XS, 11, 12, 13, 14, 15 */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .navbar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }

    /* Ajustements pour les boutons arrondis */
    .btn {
        min-height: 44px; /* Taille minimale recommandée par Apple */
    }

    /* Optimisations pour les écrans Retina */
    .img-fluid {
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Samsung Galaxy */
@media screen and (max-device-width: 412px) and (-webkit-min-device-pixel-ratio: 2.625) {
    /* Galaxy S, Note, A series */
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Ajustements pour les écrans AMOLED */
    .card {
        border: 1px solid rgba(255,255,255,0.1);
        background-color: rgba(255,255,255,0.95);
    }

    /* Optimisations pour One UI */
    .navbar-toggler {
        width: 48px;
        height: 48px;
    }
}

/* Huawei et Honor */
@media screen and (max-device-width: 360px) and (-webkit-min-device-pixel-ratio: 3) {
    /* Huawei P, Mate, Nova series */
    .container {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Ajustements pour EMUI */
    .btn {
        font-weight: 500;
        letter-spacing: 0.025em;
    }

    /* Optimisations pour les écrans LCD */
    body {
        font-smoothing: antialiased;
        -webkit-font-smoothing: antialiased;
    }
}

/* Xiaomi et Redmi */
@media screen and (max-device-width: 393px) and (-webkit-min-device-pixel-ratio: 2.75) {
    /* Xiaomi Mi, Redmi, Poco series */
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Ajustements pour MIUI */
    .navbar-brand {
        font-weight: 600;
    }

    /* Optimisations pour les écrans AMOLED */
    .card {
        box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    }
}

/* Google Pixel */
@media screen and (max-device-width: 412px) and (-webkit-min-device-pixel-ratio: 2.625) {
    /* Pixel 4, 5, 6, 7, 8 series */
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Ajustements pour Android Stock */
    .btn {
        font-family: 'Roboto', var(--font-family);
    }

    /* Optimisations Material Design */
    .card {
        border-radius: 12px;
    }
}

/* OnePlus */
@media screen and (max-device-width: 412px) and (-webkit-min-device-pixel-ratio: 2.625) {
    /* OnePlus 8, 9, 10, 11 series */
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Ajustements pour OxygenOS */
    .navbar-toggler {
        border-radius: 50%;
        width: 44px;
        height: 44px;
    }

    /* Optimisations pour les écrans Fluid AMOLED */
    .img-fluid {
        image-rendering: optimizeQuality;
    }
}

/* ===========================================
   ACCESSIBILITÉ ET CONTRASTE
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #ffffff;
        --text-secondary: #cccccc;
        --bg-primary: #1a1a1a;
        --bg-secondary: #2a2a2a;
        --akili-border: #404040;
    }

    .card {
        background-color: var(--bg-secondary);
        border-color: var(--akili-border);
        color: var(--text-primary);
    }

    .navbar {
        background-color: var(--bg-secondary);
        border-bottom: 1px solid var(--akili-border);
    }
}

/* ===========================================
   IMPRESSION
   =========================================== */

@media print {
    .navbar,
    .btn,
    .footer {
        display: none !important;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .card {
        border: 1px solid #000;
        box-shadow: none;
    }
}

/* ===========================================
   ANIMATIONS ET TRANSITIONS RESPONSIVE
   =========================================== */

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===========================================
   UTILITAIRES SPÉCIAUX POUR MOBILE
   =========================================== */

.touch-friendly {
    min-height: 44px;
    min-width: 44px;
}

.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.scroll-smooth {
    scroll-behavior: smooth;
}

/* Fix pour les inputs sur mobile */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
textarea,
select {
    font-size: 16px; /* Empêche le zoom sur iOS */
    border: 1px solid #ced4da;
    border-radius: var(--border-radius);
}

/* Fix pour les boutons sur mobile */
button, .btn {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    outline: none;
}

/* ===========================================
   DEBUGGING RESPONSIVE (décommentez pour debug)
   =========================================== */

/*
.debug-responsive::before {
    content: "XS";
    position: fixed;
    top: 0;
    left: 0;
    background: red;
    color: white;
    padding: 5px;
    font-size: 12px;
    z-index: 9999;
}

@media (min-width: 576px) {
    .debug-responsive::before { content: "SM"; background: orange; }
}

@media (min-width: 768px) {
    .debug-responsive::before { content: "MD"; background: yellow; color: black; }
}

@media (min-width: 992px) {
    .debug-responsive::before { content: "LG"; background: green; }
}

@media (min-width: 1200px) {
    .debug-responsive::before { content: "XL"; background: blue; }
}
*/