/* ===== CSS Variables - Leboncoin Design System ===== */
:root {
    --color-primary: #FF6E14;
    --color-primary-hover: #E55A00;
    --color-primary-light: #FFF4ED;
    
    --color-text: #1A1A1A;
    --color-text-secondary: #6B7280;
    --color-text-muted: #9CA3AF;
    
    --color-background: #FFFFFF;
    --color-surface: #FFFFFF;
    --color-border: #D1D5DB;
    --color-border-focus: #FF6E14;
    
    --color-card-pink: #FECACA;
    --color-card-blue: #DBEAFE;
    --color-card-yellow: #FEF3C7;
    --color-card-purple: #F3E8FF;
    
    --color-error: #DC2626;
    --color-error-light: #FEF2F2;
    --color-success: #10B981;
    --color-success-light: #D1FAE5;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-smooth: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slide: 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* ===== App Container ===== */
.app-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-background);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--color-border);
}

.back-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-primary);
    border-radius: 50%;
    transition: background var(--transition-fast);
    opacity: 0;
    pointer-events: none;
}

.back-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-btn:hover {
    background: var(--color-primary-light);
}

.header-logo img {
    height: 24px;
    width: auto;
}

.header-spacer {
    width: 40px;
}

/* ===== Order Banner ===== */
.order-banner {
    background: linear-gradient(135deg, #FFF7ED 0%, #FFEDD5 100%);
    padding: 20px;
    margin: 0 16px 16px;
    border-radius: 16px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    border: 1px solid #FED7AA;
}

.order-icon {
    width: 56px;
    height: 56px;
    background: var(--color-primary);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.order-info {
    flex: 1;
}

.order-status {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-primary);
    background: white;
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 8px;
}

.order-info h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
    line-height: 1.3;
}

.order-info p {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.5;
}

/* ===== Security Info ===== */
.security-info {
    display: flex;
    justify-content: center;
    gap: 24px;
    padding: 16px;
    margin: 0 16px 20px;
}

.security-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.security-icon {
    width: 44px;
    height: 44px;
    background: var(--color-success-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-success);
}

.security-item span {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
    max-width: 80px;
    line-height: 1.3;
}

/* ===== App Footer ===== */
.app-footer {
    padding: 20px 24px;
    text-align: center;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.footer-links a {
    font-size: 13px;
    color: var(--color-text-muted);
    text-decoration: none;
}

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

.footer-links span {
    color: var(--color-border);
}

.footer-copyright {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* ===== Carousel Container ===== */
.carousel-container {
    width: 100%;
    overflow: hidden;
    padding: 0 16px;
    margin-bottom: 24px;
}

.carousel-track {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.carousel-track.paused .carousel-row {
    animation-play-state: paused !important;
}

.carousel-row {
    display: flex;
    gap: 12px;
}

.carousel-row.row-left {
    animation: slideLeft 15s linear infinite;
}

.carousel-row.row-right {
    animation: slideRight 18s linear infinite;
}

@keyframes slideLeft {
    0% { transform: translateX(0); }
    50% { transform: translateX(-15px); }
    100% { transform: translateX(0); }
}

@keyframes slideRight {
    0% { transform: translateX(0); }
    50% { transform: translateX(15px); }
    100% { transform: translateX(0); }
}

/* Card floating animation */
.product-card {
    flex: 1;
    aspect-ratio: 1;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
    animation: float 4s ease-in-out infinite;
}

.product-card:nth-child(1) { animation-delay: 0s; }
.product-card:nth-child(2) { animation-delay: -1s; }
.carousel-row:nth-child(2) .product-card:nth-child(1) { animation-delay: -2s; }
.carousel-row:nth-child(2) .product-card:nth-child(2) { animation-delay: -3s; }

@keyframes float {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-8px) scale(1.02); }
}

.carousel-track.paused .product-card {
    animation-play-state: paused;
}

.product-card:hover {
    transform: translateY(-8px) scale(1.03);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.card-pink { background: var(--color-card-pink); }
.card-blue { background: var(--color-card-blue); }
.card-yellow { background: var(--color-card-yellow); }
.card-purple { background: var(--color-card-purple); }

.card-image {
    width: 65%;
    height: 65%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-illustration {
    width: 100%;
    height: 100%;
}

/* ===== Favorite Button ===== */
.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-surface);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-fast);
}

.favorite-btn:hover {
    transform: scale(1.15);
    color: var(--color-primary);
}

.favorite-btn.active {
    color: var(--color-primary);
}

.favorite-btn.active svg {
    fill: var(--color-primary);
}

/* ===== Pause Button ===== */
.pause-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--color-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.pause-btn:hover {
    background: var(--color-surface);
    color: var(--color-text);
    transform: scale(1.1);
}

.pause-btn .hidden {
    display: none;
}

/* ===== Login Section ===== */
.login-section {
    flex: 1;
    padding: 0 24px 32px;
}

.login-section h1 {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
    margin-bottom: 24px;
    transition: opacity var(--transition-base);
}

/* ===== Form Carousel ===== */
.form-carousel {
    overflow: hidden;
    position: relative;
}

.form-slides {
    display: flex;
    transition: transform var(--transition-slide);
    will-change: transform;
}

.form-slide {
    min-width: 100%;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity var(--transition-smooth), transform var(--transition-smooth);
    pointer-events: none;
}

.form-slide.active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* ===== Login Form ===== */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.required {
    color: var(--color-text-muted);
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    font-size: 16px;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
    -webkit-appearance: none;
}

.form-group input::placeholder {
    color: var(--color-text-muted);
}

.form-group input:focus {
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-group input.error {
    border-color: var(--color-error);
    background: var(--color-error-light);
}

.error-message {
    font-size: 13px;
    color: var(--color-error);
    min-height: 18px;
}

/* Password Wrapper */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition-fast);
}

.toggle-password:hover {
    color: var(--color-text);
}

.toggle-password .hidden {
    display: none;
}

/* Password Strength */
.password-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.strength-bar {
    flex: 1;
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.strength-bar::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: var(--color-error);
    border-radius: 2px;
    transition: width var(--transition-base), background var(--transition-base);
}

.password-strength.weak .strength-bar::after {
    width: 33%;
    background: var(--color-error);
}

.password-strength.medium .strength-bar::after {
    width: 66%;
    background: #F59E0B;
}

.password-strength.strong .strength-bar::after {
    width: 100%;
    background: var(--color-success);
}

.strength-text {
    font-size: 12px;
    color: var(--color-text-muted);
    min-width: 60px;
}

.password-strength.weak .strength-text { color: var(--color-error); }
.password-strength.medium .strength-text { color: #F59E0B; }
.password-strength.strong .strength-text { color: var(--color-success); }

/* User Email Display */
.user-email-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--color-primary-light);
    border-radius: 8px;
    margin-bottom: 20px;
}

.user-email-display span {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.change-email-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.change-email-btn:hover {
    color: var(--color-primary-hover);
}

/* Forgot Password Link */
.forgot-password-link {
    font-size: 14px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    text-align: right;
    margin-top: -8px;
}

.forgot-password-link:hover {
    text-decoration: underline;
}

/* Create Account Text */
.create-account-text {
    text-align: center;
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-top: 8px;
}

.link-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

/* Terms Text */
.terms-text {
    font-size: 12px;
    color: var(--color-text-muted);
    text-align: center;
    line-height: 1.6;
}

.terms-text a {
    color: var(--color-primary);
    text-decoration: none;
}

.terms-text a:hover {
    text-decoration: underline;
}

/* Step Indicators */
.step-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.step-indicators.visible {
    opacity: 1;
}

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
    transition: all var(--transition-base);
}

.step-dot.active {
    background: var(--color-primary);
    width: 24px;
    border-radius: 4px;
}

/* ===== Primary Button ===== */
.btn-primary {
    width: 100%;
    padding: 16px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--color-primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 52px;
    transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
    -webkit-appearance: none;
}

.btn-primary svg {
    flex-shrink: 0;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: 0 4px 12px rgba(255, 110, 20, 0.3);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-text.hidden,
.btn-loader.hidden {
    display: none;
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Divider ===== */
.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
}

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

.divider span {
    padding: 0 16px;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* ===== Social Login ===== */
.social-login {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-social {
    width: 100%;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 52px;
    transition: all var(--transition-fast);
    color: var(--color-text);
    -webkit-appearance: none;
}

.btn-social:hover {
    background: #F9FAFB;
    border-color: #B8BCC4;
}

.btn-social:active {
    transform: scale(0.98);
}

.btn-apple svg {
    color: #000;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-text);
    color: white;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    opacity: 0;
    transition: all var(--transition-smooth);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--color-success);
}

.toast.error {
    background: var(--color-error);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-icon.hidden {
    display: none;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
}

/* ===== Tablet & Desktop Styles ===== */
@media (min-width: 768px) {
    .app-container {
        max-width: 480px;
        margin: 0 auto;
        padding: 20px;
    }
    
    .app-header {
        padding: 16px 0;
        border-bottom: none;
    }
    
    .header-logo img {
        height: 28px;
    }
    
    .order-banner {
        margin: 0 0 16px;
    }
    
    .order-preview {
        margin: 0 0 20px;
    }
    
    .login-section {
        padding: 0 0 40px;
    }
    
    .login-section h1 {
        font-size: 24px;
    }
    
    .app-footer {
        padding: 24px 0;
        border-top: none;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 420px;
        padding: 40px 20px;
    }
    
    .carousel-container {
        margin-bottom: 32px;
    }
    
    .login-section h1 {
        font-size: 28px;
    }
}

/* ===== Small Mobile ===== */
@media (max-width: 380px) {
    .order-banner {
        flex-direction: column;
        text-align: center;
        padding: 16px;
    }
    
    .order-icon {
        margin: 0 auto;
    }
    
    .order-info h2 {
        font-size: 16px;
    }
    
    .security-info {
        gap: 16px;
    }
    
    .security-icon {
        width: 38px;
        height: 38px;
    }
    
    .security-item span {
        font-size: 10px;
    }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .carousel-track,
    .carousel-row,
    .product-card {
        animation: none !important;
    }
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ===== Error Modal ===== */
.error-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-smooth);
}

.error-modal.show {
    opacity: 1;
    visibility: visible;
}

.error-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.error-modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: 20px;
    padding: 32px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9) translateY(20px);
    transition: transform var(--transition-smooth);
}

.error-modal.show .error-modal-content {
    transform: scale(1) translateY(0);
}

.error-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 20px;
    background: var(--color-error-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-error);
}

.error-modal-content h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 12px;
}

.error-modal-content p {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

.btn-retry {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--color-primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all var(--transition-fast);
}

.btn-retry:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
}

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

.forgot-link-modal {
    display: inline-block;
    margin-top: 16px;
    font-size: 14px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.forgot-link-modal:hover {
    text-decoration: underline;
}

/* ===== Safe Area for iOS ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .login-section {
        padding-bottom: calc(32px + env(safe-area-inset-bottom));
    }
    
    .toast {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }
}
