/* ============================================
   BookAI - Apple Premium Design System
   100% Responsive - Mobile First
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    background-color: #ffffff;
    color: #1d1d1f;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --color-anthracite: #1d1d1f;
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-indigo: #4F46E5;
    --color-indigo-dark: #4338CA;
    --color-violet: #7C3AED;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 40px rgba(79, 70, 229, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
}

/* ============================================
   NAVIGATION - STICKY WITH BLUR
   ============================================ */
#navbar {
    background: transparent;
    transition: all 0.3s ease;
}

#navbar.nav-scrolled {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Mobile Navigation */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 60;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-anthracite);
    transition: all 0.3s ease;
    border-radius: 2px;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    z-index: 50;
    padding: 80px 24px 24px;
    flex-direction: column;
    gap: 16px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.mobile-nav.active {
    transform: translateX(0);
}

.mobile-nav a {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--color-anthracite);
    padding: 16px;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
}

.mobile-nav a:hover {
    background: var(--color-gray-100);
}

/* ============================================
   TYPOGRAPHIE
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-anthracite);
    letter-spacing: -0.02em;
}

p {
    color: var(--color-gray-500);
}

a {
    color: inherit;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* ============================================
   BOUTONS - TOUCH FRIENDLY
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-indigo) 0%, var(--color-violet) 100%);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: var(--color-anthracite);
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    border-color: var(--color-gray-300);
    box-shadow: var(--shadow-md);
}

/* Large touch-friendly buttons for mobile */
.btn-touch {
    min-height: 56px;
    padding: 1rem 2rem;
    font-size: 1.0625rem;
}

/* ============================================
   FORMULAIRES
   ============================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-anthracite);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    background: var(--color-gray-50);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--color-anthracite);
    transition: all 0.2s ease;
    min-height: 52px;
    -webkit-appearance: none;
    appearance: none;
}

.form-input:focus {
    outline: none;
    background: white;
    border-color: var(--color-indigo);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
    color: var(--color-gray-400);
}

/* ============================================
   CARTES
   ============================================ */
.card {
    background: white;
    border-radius: var(--radius-xl);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-4px);
}

/* ============================================
   REVIEWS
   ============================================ */
.review-card {
    transition: all 0.3s ease;
}

.review-card:hover {
    transform: translateY(-4px);
}

/* ============================================
   ANIMATIONS SCROLL REVEAL
   ============================================ */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Hero animations */
.hero-title {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.1s;
}

.hero-subtitle {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.2s;
}

.hero-cta {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.3s;
}

.hero-trust {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.4s;
}

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

/* Stagger animations for reviews */
.review-card:nth-child(1) { animation-delay: 0.1s; }
.review-card:nth-child(2) { animation-delay: 0.2s; }
.review-card:nth-child(3) { animation-delay: 0.3s; }
.review-card:nth-child(4) { animation-delay: 0.4s; }
.review-card:nth-child(5) { animation-delay: 0.5s; }
.review-card:nth-child(6) { animation-delay: 0.6s; }

/* ============================================
   MORE REVIEWS EXPAND
   ============================================ */
#more-reviews {
    transition: max-height 0.5s ease-in-out;
}

#more-reviews.expanded {
    max-height: 5000px !important;
}

/* ============================================
   UTILITAIRES
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

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

/* ============================================
   SÉLECTION
   ============================================ */
::selection {
    background: var(--color-indigo);
    color: white;
}

/* ============================================
   PAGES AUTH
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--color-gray-400);
    font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-gray-200);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
}

/* Google button */
.btn-google {
    background: white;
    color: var(--color-anthracite);
    border: 1px solid var(--color-gray-200);
    box-shadow: var(--shadow-sm);
    width: 100%;
    padding: 1rem 1.5rem;
}

.btn-google:hover {
    background: var(--color-gray-50);
    border-color: var(--color-gray-300);
}

.btn-google svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   SETTINGS PAGE
   ============================================ */
.settings-page {
    padding: 6rem 0 3rem;
    min-height: 100vh;
    background: var(--color-gray-50);
}

.settings-header {
    margin-bottom: 2rem;
}

.settings-header h1 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.settings-grid {
    display: grid;
    gap: 1.5rem;
}

.settings-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.settings-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-gray-100);
}

.settings-card-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--color-indigo) 0%, var(--color-violet) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.settings-card-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.settings-card-subtitle {
    font-size: 0.875rem;
    color: var(--color-gray-500);
}

.subscription-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.subscription-active {
    background: #d1fae5;
    color: #065f46;
}

.subscription-inactive {
    background: var(--color-gray-100);
    color: var(--color-gray-500);
}

/* ============================================
   FLASH MESSAGES
   ============================================ */
.flash-messages {
    position: fixed;
    top: 90px;
    right: 1.5rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.flash-message {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

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

.flash-success {
    background: #d1fae5;
    color: #065f46;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================
   FOOTER
   ============================================ */
footer a {
    position: relative;
}

footer a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--color-anthracite);
    transition: width 0.2s ease;
}

footer a:hover::after {
    width: 100%;
}

/* ============================================
   ANIMATIONS KEYFRAMES
   ============================================ */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* ============================================
   BOOK READER / LISEUSE
   ============================================ */
.book-reader {
    background: #FEFEFE;
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 2;
    color: #2d2d2d;
    padding: 40px 50px;
    max-height: 700px;
    overflow-y: auto;
    box-shadow: inset 0 0 60px rgba(0,0,0,0.03);
    -webkit-overflow-scrolling: touch;
}

.book-reader::-webkit-scrollbar {
    width: 8px;
}

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

.book-reader::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.book-reader::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.book-reader h1 {
    font-family: 'Georgia', serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin: 2rem 0 1.5rem;
    color: #1a1a1a;
    text-align: center;
    line-height: 1.3;
}

.book-reader h2 {
    font-family: 'Georgia', serif;
    font-size: 1.8rem;
    font-weight: 600;
    margin: 2.5rem 0 1.5rem;
    color: #1a1a1a;
    border-bottom: 2px solid #e5e5e5;
    padding-bottom: 0.5rem;
}

.book-reader h3 {
    font-family: 'Georgia', serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin: 2rem 0 1rem;
    color: #3d3d3d;
}

.book-reader p {
    margin-bottom: 1.5rem;
    text-align: justify;
    text-indent: 2em;
    font-size: 1.05rem;
}

.book-reader p:first-of-type {
    text-indent: 0;
}

.book-reader ul, .book-reader ol {
    margin: 1.5rem 0;
    padding-left: 2.5rem;
}

.book-reader li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.book-reader strong {
    color: #1a1a1a;
    font-weight: 700;
}

.book-reader em {
    font-style: italic;
}

.book-reader hr {
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 2rem 0;
}

.book-reader blockquote {
    border-left: 4px solid #4F46E5;
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #555;
}

/* ============================================
   PROGRESS BAR - MOBILE OPTIMIZED
   ============================================ */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: rgba(79, 70, 229, 0.1);
    z-index: 100;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4F46E5, #7C3AED);
    transition: width 0.5s ease;
}

/* ============================================
   MEDIA QUERIES - MOBILE RESPONSIVE
   ============================================ */

/* Tablet and below */
@media (max-width: 1024px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .hero-title {
        font-size: 3rem !important;
    }
}

/* Mobile */
@media (max-width: 768px) {
    /* Navigation */
    .mobile-menu-btn {
        display: flex;
    }
    
    .desktop-nav {
        display: none !important;
    }
    
    .mobile-nav {
        display: flex;
    }
    
    /* Hero */
    .hero-title {
        font-size: 2.25rem !important;
        line-height: 1.2 !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
    
    /* Buttons */
    .btn {
        min-height: 56px;
        padding: 1rem 1.5rem;
        font-size: 1rem;
        width: 100%;
    }
    
    /* Cards */
    .card {
        border-radius: var(--radius-lg);
    }
    
    /* Auth */
    .auth-card {
        padding: 1.5rem;
        margin: 0 0.5rem;
    }
    
    .auth-header h1 {
        font-size: 1.5rem;
    }
    
    /* Settings */
    .settings-page {
        padding: 5rem 0 2rem;
    }
    
    .settings-header h1 {
        font-size: 1.5rem;
    }
    
    .settings-card {
        padding: 1.25rem;
    }
    
    /* Book Reader - Mobile optimized */
    .book-reader {
        padding: 24px 20px;
        max-height: 60vh;
        font-size: 16px;
        line-height: 1.8;
    }
    
    .book-reader h1 {
        font-size: 1.75rem;
        margin: 1.5rem 0 1rem;
    }
    
    .book-reader h2 {
        font-size: 1.35rem;
        margin: 2rem 0 1rem;
    }
    
    .book-reader h3 {
        font-size: 1.15rem;
        margin: 1.5rem 0 0.75rem;
    }
    
    .book-reader p {
        font-size: 1rem;
        text-indent: 1.5em;
        margin-bottom: 1rem;
    }
    
    /* Pricing cards stack */
    .pricing-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Dashboard cards */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Create page */
    .create-grid {
        grid-template-columns: 1fr !important;
    }
    
    .create-sidebar {
        position: static;
        order: -1;
        margin-bottom: 1.5rem;
    }
    
    /* Progress bar mobile */
    .progress-section {
        position: sticky;
        top: 64px;
        z-index: 40;
        background: white;
        padding: 1rem;
        margin: -1rem -1rem 1rem;
        border-bottom: 1px solid #e5e7eb;
    }
    
    /* Flash messages */
    .flash-messages {
        left: 1rem;
        right: 1rem;
        top: 80px;
    }
    
    .flash-message {
        font-size: 0.875rem;
        padding: 0.875rem 1rem;
    }
    
    /* Footer */
    footer .flex-col {
        text-align: center;
    }
    
    footer .gap-8 {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Scroll reveal */
    .scroll-reveal {
        transform: translateY(20px);
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .hero-title {
        font-size: 1.875rem !important;
    }
    
    .btn {
        min-height: 60px;
        font-size: 1.0625rem;
    }
    
    .auth-card {
        padding: 1.25rem;
    }
    
    .book-reader {
        padding: 20px 16px;
    }
    
    .book-reader h1 {
        font-size: 1.5rem;
    }
    
    .book-reader h2 {
        font-size: 1.2rem;
    }
    
    .settings-card-icon {
        width: 40px;
        height: 40px;
    }
    
    .settings-card-title {
        font-size: 1rem;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .book-reader {
        max-height: 50vh;
    }
    
    .hero-title {
        font-size: 2rem !important;
    }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    .nav-glass {
        padding-top: env(safe-area-inset-top);
    }
    
    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn:hover {
        transform: none;
    }
    
    .card:hover {
        transform: none;
    }
    
    .review-card:hover {
        transform: none;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-reveal {
        opacity: 1;
        transform: none;
    }
}
