*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: auto !important;
}

html {
    max-width: 100vw;
}

@media (min-width: 769px) {
    html {
        scroll-behavior: smooth;
    }
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

img {
    display: block;
}

:root {
    --primary-color: #8B5CF6;
    --secondary-color: #EC4899;
    --accent-color: #F472B6;
    --dark-color: #1F2937;
    --light-color: #F9FAFB;
    --text-color: #374151;
    --bg-color: #ffffff;
    --card-bg: #ffffff;
    --border-color: #e0e0e0;
}

[data-theme="dark"] {
    --primary-color: #A78BFA;
    --secondary-color: #F472B6;
    --accent-color: #FBCFE8;
    --dark-color: #F9FAFB;
    --light-color: #1F2937;
    --text-color: #E5E7EB;
    --bg-color: #111827;
    --card-bg: #1F2937;
    --border-color: #374151;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--bg-color);
    padding-top: 80px;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 769px) {
    body {
        transition: background-color 0.3s ease, color 0.3s ease;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
header {
    background-color: var(--card-bg);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.navbar {
    padding: 1rem 0;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1,
.logo span {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: bold;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: color 0.3s;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: #8661ed;
    transition: width 0.3s;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-links a:hover {
    color: var(--primary-color);
}

.btn-login,
.btn-logout {
    background: #8661ed;
    color: white !important;
    padding: 0.6rem 1.5rem;
    border-radius: 10px;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-login:hover,
.btn-logout:hover {
    background: #6d4dc4;
    transform: translateY(-2px);
}

.btn-logout::after {
    display: none !important;
}

/* Dark Mode Toggle */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.theme-toggle svg {
    stroke: var(--primary-color);
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    background-color: var(--light-color);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.theme-toggle:hover svg {
    stroke: var(--primary-color);
    transform: rotate(20deg);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 50%, var(--accent-color) 100%);
    color: white;
    padding: 120px 20px 80px;
    margin-top: 70px;
}

.hero-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.hero-content {
    text-align: left;
}

.hero-content h2 {
    font-size: 2.8rem;
    margin-bottom: 1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.hero-content p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

/* Hero Login Box */
.hero-login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.hero-login-box h3 {
    color: var(--dark-color);
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.hero-login-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.hero-login-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hero-login-form label {
    color: var(--dark-color);
    font-weight: 600;
    font-size: 0.95rem;
}

.hero-login-form input {
    padding: 0.9rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.hero-login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-hero-login {
    width: 100%;
    padding: 0.8rem 1.5rem;
    background: #8661ed;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-hero-login:hover {
    background: #6d4dc4;
    transform: translateY(-2px);
}

.hero-login-error {
    background-color: #ffe0e0;
    color: #d00000;
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #ffb0b0;
    font-size: 0.9rem;
}

.hero-login-footer {
    margin-top: 1rem;
    text-align: center;
}

.hero-login-footer p {
    color: #666;
    font-size: 0.9rem;
    opacity: 1;
}

.hero-login-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.hero-login-footer a:hover {
    text-decoration: underline;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-block;
    font-size: 1rem;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: #8661ed;
    color: white;
}

.btn-primary:hover {
    background: #6d4dc4;
    transform: translateY(-2px);
}

/* About Section */
.about {
    padding: 100px 20px;
    background-color: white;
}

.about-content {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 4rem;
    align-items: center;
}

.about-text h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    color: var(--dark-color);
    font-weight: 700;
}

.about-text p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
    margin-bottom: 1.5rem;
}

.about-stats {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stat-item {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    border-radius: 15px;
    color: white;
}

.stat-item h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-item p {
    font-size: 0.95rem;
    opacity: 0.95;
}

/* Services Section */
.services {
    padding: 100px 20px;
    background-color: var(--light-color);
}

.services h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 4rem;
    color: var(--dark-color);
    font-weight: 700;
}

.services-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
    max-width: 1000px;
    margin: 0 auto;
}

.service-item {
    text-align: center;
}

.service-item h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.service-item p {
    color: var(--text-color);
    font-size: 1.05rem;
    line-height: 1.7;
}

/* CTA Section */
.cta {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: white;
    padding: 100px 20px;
}

.cta-content {
    text-align: center;
    max-width: 700px;
    margin: 0 auto;
}

.cta h2 {
    font-size: 2.8rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
}

.cta p {
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
    opacity: 0.95;
}

.btn-cta {
    background: #8661ed;
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    display: inline-block;
    transition: all 0.3s;
}

.btn-cta:hover {
    background: #6d4dc4;
    transform: translateY(-2px);
}

/* Footer */
footer {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 3rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    color: white;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.footer-section p {
    margin-bottom: 0.5rem;
    opacity: 0.8;
    font-size: 0.95rem;
}

.social-links {
    display: flex;
    gap: 1.5rem;
}

.social-links a {
    color: white;
    text-decoration: none;
    opacity: 0.8;
    transition: all 0.3s;
    font-size: 0.95rem;
}

.social-links a:hover {
    opacity: 1;
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 968px) {
    .about-content {
        grid-template-columns: 1fr;
        gap: 3rem;
    }

    .about-stats {
        flex-direction: row;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .nav-links {
        gap: 1rem;
        font-size: 0.9rem;
    }

    .hero {
        padding: 100px 20px 60px;
    }

    .hero-container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .hero-content {
        text-align: center;
    }

    .hero-content h2 {
        font-size: 2rem;
    }

    .hero-content p {
        font-size: 1rem;
    }

    .hero-login-box {
        padding: 2rem;
    }

    .about {
        padding: 60px 20px;
    }

    .about-text h2 {
        font-size: 2rem;
    }

    .about-text p {
        font-size: 1rem;
    }

    .about-stats {
        flex-direction: column;
    }

    .services h2,
    .cta h2 {
        font-size: 2rem;
    }

    .services {
        padding: 60px 20px;
    }

    .cta {
        padding: 60px 20px;
    }

    .social-links {
        flex-direction: column;
        gap: 1rem;
    }
}

/* ========================================
   MOBILE UTILITIES
   ======================================== */

/* Touch targets - minimum 44x44px */
.touch-target {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   MOBILE TOUCH TARGETS - Phase 1.1
   ======================================== */
@media (max-width: 768px) {
    button,
    .btn,
    .btn-primary,
    .btn-action,
    a.btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 48px;
        min-width: 48px;
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    /* Espacement entre boutons */
    .session-actions,
    .button-group,
    .action-buttons {
        gap: 0.75rem; /* 12px minimum au lieu de 8px */
    }

    /* Rating buttons */
    .rating-container {
        gap: 0.75rem;
    }

    .rating-btn {
        min-width: 52px;
        min-height: 52px;
    }
}

/* Mobile padding utilities */
.mobile-p-1 { padding: 0.5rem; }
.mobile-p-2 { padding: 1rem; }
.mobile-px-1 { padding-left: 0.5rem; padding-right: 0.5rem; }
.mobile-py-1 { padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* Mobile margin utilities */
.mobile-m-0 { margin: 0; }
.mobile-mb-1 { margin-bottom: 0.5rem; }
.mobile-mt-1 { margin-top: 0.5rem; }

/* Text sizing */
.mobile-text-sm { font-size: 0.875rem; }
.mobile-text-base { font-size: 1rem; }
.mobile-text-lg { font-size: 1.125rem; }

/* Flexbox utilities */
.mobile-flex-col { flex-direction: column; }
.mobile-flex-wrap { flex-wrap: wrap; }
.mobile-gap-1 { gap: 0.5rem; }
.mobile-gap-2 { gap: 1rem; }

/* Width utilities */
.mobile-w-full { width: 100%; }
.mobile-w-auto { width: auto; }

/* Display utilities */
.mobile-hidden { display: none !important; }
.mobile-block { display: block !important; }
.mobile-flex { display: flex !important; }

/* Overflow utilities */
.mobile-overflow-x-auto {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.mobile-no-wrap { white-space: nowrap; }

/* ========================================
   SYSTÈME GRID RESPONSIVE - Phase 2.1
   ======================================== */

@media (max-width: 768px) {
    /* Grids 2+ colonnes → 1 colonne */
    .grid-2,
    .grid-3,
    .grid-4,
    .dashboard-grid,
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    /* Services list */
    .services-list {
        grid-template-columns: 1fr !important;
    }
}

/* ========================================
   FORMULAIRES MOBILES - Phase 2.3
   ======================================== */

@media (max-width: 768px) {
    /* Empêcher zoom iOS sur focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important; /* iOS ne zoom pas si >= 16px */
        min-height: 48px;
        padding: 0.75rem 1rem;
    }

    .form-group,
    .form-field {
        margin-bottom: 1rem;
    }

    .form-group label,
    .form-field label {
        font-size: 0.9375rem; /* 15px */
        margin-bottom: 0.5rem;
        display: block;
    }

    /* Multi-column forms become single column */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ========================================
   HAMBURGER MENU
   ======================================== */

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 32px; /* Réduit de 44px à 32px */
    height: 32px; /* Réduit de 44px à 32px */
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px; /* Réduit de 8px à 6px */
    z-index: 1001;
}

.hamburger span {
    width: 20px; /* Réduit de 28px à 20px */
    height: 2px; /* Réduit de 3px à 2px */
    background: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* Styles pour les liens icones dans nav-links (settings, logout) */
.nav-links li a.nav-icon {
    background: none;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    text-decoration: none;
}

.nav-links li a.nav-icon:hover {
    background-color: var(--light-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nav-links li a.nav-icon.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nav-links li a.nav-icon::after {
    display: none;
}

/* Client nav: liens texte centres, icones groupees a droite */
.client-nav .nav-links {
    flex: 1;
    gap: 0.5rem;
}

.client-nav .nav-links li:nth-child(-n+4) {
    margin: 0 0.75rem;
}

.client-nav .nav-links li:first-child {
    margin-left: auto;
}

.client-nav .nav-links li:nth-child(5) {
    margin-left: auto;
}

/* Bouton langue: texte violet */
#langToggle {
    color: var(--primary-color) !important;
    font-weight: 700 !important;
    font-size: 0.85rem !important;
}

.hamburger.active span:nth-child(1) {
    transform: translateY(6px) rotate(45deg); /* Ajusté pour le hamburger plus petit */
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg); /* Ajusté pour le hamburger plus petit */
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-menu-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    .hamburger {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        bottom: 0;
        right: -100%;
        width: 280px;
        background: var(--card-bg);
        flex-direction: column;
        padding: 80px 2rem 4rem;
        padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    .nav-links.active {
        right: 0;
    }

    .nav-links li {
        margin: 0; /* Aucun margin pour menu ultra compact */
        width: 100%;
    }

    .nav-links a {
        font-size: 1.1rem;
        padding: 0.5rem 0; /* Réduit de 0.75rem à 0.5rem */
        display: block;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    /* Bouton login dans le menu mobile */
    .nav-links li a.btn-login {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        width: 100% !important;
        height: 44px;
        border-radius: 8px;
        margin: 0.25rem 0;
        padding: 0 !important;
        box-sizing: border-box;
    }

    .nav-links li a.btn-login::after {
        display: none !important;
    }

    /* Boutons theme-toggle dans le menu mobile */
    .nav-links li button.theme-toggle {
        width: 100%;
        height: 44px;
        border-radius: 8px;
        margin: 0.25rem 0;
        justify-content: center;
    }

    /* Liens icones dans le menu mobile */
    .nav-links li a.nav-icon {
        width: 100%;
        height: 44px;
        border: 2px solid var(--border-color) !important;
        border-radius: 8px;
        margin: 0.25rem 0;
        justify-content: center;
        padding: 0;
    }

    /* Espace entre les liens texte et les boutons icones */
    .nav-links li:nth-child(5) {
        margin-top: 1rem;
    }

    /* Ajouter margin-bottom au dernier élément pour voir la bordure complète */
    .nav-links li:last-child {
        margin-bottom: 2rem;
    }
}

/* ========================================
   TOUCH-SPECIFIC STYLES
   ======================================== */

/* Disable hover on touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .nav-links a:hover,
    .card:hover {
        /* Disable hover effects on touch */
        transform: none;
        box-shadow: none;
    }
}

/* Active states for touch */
@media (pointer: coarse) {
    .btn-primary:active,
    .btn:active {
        background: #5d46b8;
        transform: translateY(2px);
    }

    .nav-links a:active {
        background: rgba(134, 97, 237, 0.1);
    }

    .card:active {
        transform: scale(0.99);
    }

    a:not(.nav-links a) {
        padding: 0.25rem 0;
        margin: 0.25rem 0;
    }

    button:focus,
    a:focus,
    input:focus {
        outline: 2px solid #8661ed;
        outline-offset: 2px;
    }

    .btn {
        position: relative;
        overflow: hidden;
    }

    .btn::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: translate(-50%, -50%);
        transition: width 0.3s, height 0.3s;
    }

    .btn:active::after {
        width: 200px;
        height: 200px;
    }
}

/* iOS momentum scrolling */
.modal-body,
.overflow-scroll,
.table-container {
    -webkit-overflow-scrolling: touch;
}

.photo-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

@media (max-width: 768px) {
    /* Phase 1.2 - Container padding mobile */
    .container {
        padding: 0 1rem; /* 16px */
    }

    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .photo-grid {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .container {
        padding: 0 1rem;
        max-width: 100%;
    }
}

/* ========================================
   VERY SMALL DEVICES (320px - 375px)
   ======================================== */

@media (max-width: 375px) {
    body {
        font-size: 0.875rem;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }

    .container {
        padding: 0 0.875rem; /* 14px - Phase 1.2 minimum confortable */
    }

    .btn-primary,
    .btn {
        padding: 0.7rem 1rem;
        font-size: 0.9rem;
    }

    .navbar {
        padding: 0.75rem 0;
    }

    .logo h1,
    .logo span {
        font-size: 1.25rem;
    }

    .card,
    .workout-card,
    .exercise-card {
        padding: 0.875rem;
    }

    .card-header {
        padding: 0.75rem;
        font-size: 0.95rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    /* Reduce gap in grids */
    .grid-2, .grid-3, .grid-4 {
        gap: 0.5rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    label {
        font-size: 0.85rem;
        margin-bottom: 0.375rem;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    select,
    textarea {
        padding: 0.6rem 0.75rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 320px) {
    body {
        font-size: 0.8125rem;
    }

    h1 { font-size: 1.35rem; }
    h2 { font-size: 1.15rem; }

    .container {
        padding: 0 0.75rem; /* 12px - Phase 1.2 pas moins ! */
    }

    .btn-primary,
    .btn {
        padding: 0.6rem 0.875rem;
        font-size: 0.85rem;
    }

    input, select, textarea {
        font-size: 0.875rem;
    }
}
