/* Variables & Design System */
:root {
    --lac-primary: #007aff;
    --lac-primary-hover: #0056b3;
    --lac-bg-glass: rgba(255, 255, 255, 0.7);
    --lac-border-glass: rgba(255, 255, 255, 0.5);
    --lac-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --lac-radius: 20px;
    --lac-text-main: #1d1d1f;
    --lac-text-secondary: #86868b;
    --lac-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#linkedin-ai-coach-wrapper {
    font-family: var(--lac-font);
    max-width: 1000px;
    margin: 40px auto;
    padding: 20px;
    color: var(--lac-text-main);
}

.lac-container {
    background: var(--lac-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--lac-border-glass);
    border-radius: var(--lac-radius);
    padding: 40px;
    box-shadow: var(--lac-shadow);
    min-height: 400px;
    transition: all 0.3s ease;
}

.lac-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    background: linear-gradient(135deg, #1d1d1f 0%, #434344 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lac-textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 16px;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
    margin-bottom: 20px;
    resize: vertical;
}

#lac-draft-input {
    height: 300px;
}

.lac-buttons-row {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.lac-textarea:focus {
    outline: none;
    border-color: var(--lac-primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.lac-button {
    background: var(--lac-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 99px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    display: block;
    margin: 0 auto;
}

.lac-button:hover {
    background: var(--lac-primary-hover);
    transform: scale(1.02);
}

.lac-button:active {
    transform: scale(0.98);
}

/* Steps & Visibility */
.hidden {
    display: none !important;
}

/* Step 2: Coaching */
.lac-question-group {
    background: rgba(255, 255, 255, 0.4);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.lac-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--lac-text-main);
}

/* Step 3: Results Grid */
.lac-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.lac-post-card {
    background: #fff;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.lac-card-header h3 {
    margin-top: 0;
    font-size: 18px;
    color: var(--lac-primary);
    margin-bottom: 15px;
}

.lac-post-content {
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    margin-bottom: 20px;
    white-space: pre-wrap;
    margin-bottom: 20px;
    white-space: pre-wrap;
    /* Preserves key layout */
}

/* Back Button */
.lac-buttonui-back {
    display: inline-block;
}

.lac-button-secondary {
    background: transparent;
    color: var(--lac-text-secondary);
    border: 1px solid var(--lac-border-glass);
    margin: 0 0 20px 0;
    padding: 8px 16px;
    font-size: 14px;
}
.lac-button-secondary:hover {
    background: rgba(0,0,0,0.05);
    color: var(--lac-text-main);
    transform: none;
}

/* ============================================
   PREMIUM LOADER - Apple-Inspired Animations
   ============================================ */

#lac-loader {
    text-align: center;
    padding: 40px 20px;
    min-height: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lac-loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    max-width: 400px;
}

/* Icon Stage - Central animated element */
.lac-icon-stage {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lac-icon-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 122, 255, 0.3) 0%, transparent 70%);
    animation: glowPulse 3s ease-in-out infinite;
}

.lac-mode-generation .lac-icon-glow {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.3) 0%, rgba(59, 130, 246, 0.2) 50%, transparent 70%);
}

.lac-icon-main {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--lac-primary) 0%, #5856d6 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    animation: iconFloat 4s ease-in-out infinite;
    box-shadow: 0 10px 40px rgba(0, 122, 255, 0.3);
}

.lac-mode-generation .lac-icon-main {
    background: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.3);
}

.lac-icon-svg {
    width: 28px;
    height: 28px;
    color: white;
    position: absolute;
    transition: opacity 0.3s ease;
}

/* Show/hide icons based on mode */
.lac-icon-coaching {
    opacity: 0;
    animation: iconPulse 2s ease-in-out infinite;
}

.lac-icon-generation {
    opacity: 0;
    animation: iconWrite 1.5s ease-in-out infinite;
}

.lac-mode-coaching .lac-icon-coaching {
    opacity: 1;
}

.lac-mode-generation .lac-icon-generation {
    opacity: 1;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes iconWrite {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.lac-icon-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 2px solid rgba(0, 122, 255, 0.3);
    border-radius: 50%;
    animation: ringExpand 2.5s ease-out infinite;
}

.lac-icon-ring-2 {
    animation-delay: 1.25s;
}

.lac-mode-generation .lac-icon-ring {
    border-color: rgba(16, 185, 129, 0.3);
}

/* Progress Steps */
.lac-progress-steps {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 20px 10px;
    overflow-x: auto;
    max-width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.lac-progress-steps::-webkit-scrollbar {
    display: none;
}

.lac-step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0.4;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.lac-step-indicator.active {
    opacity: 1;
}

.lac-step-indicator.completed {
    opacity: 0.7;
}

.lac-step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--lac-text-secondary);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.lac-step-indicator.active .lac-step-dot {
    background: var(--lac-primary);
    transform: scale(1.3);
    box-shadow: 0 0 20px rgba(0, 122, 255, 0.5);
}

.lac-mode-generation .lac-step-indicator.active .lac-step-dot {
    background: linear-gradient(135deg, #10b981, #3b82f6);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.lac-step-indicator.completed .lac-step-dot {
    background: #34c759;
}

.lac-step-indicator.completed .lac-step-dot::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    color: white;
    font-weight: bold;
}

.lac-step-label {
    font-size: 10px;
    color: var(--lac-text-secondary);
    font-weight: 500;
    white-space: nowrap;
    max-width: 60px;
    text-align: center;
    transition: color 0.3s ease;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lac-step-indicator.active .lac-step-label {
    color: var(--lac-text-main);
    font-weight: 600;
}

.lac-step-connector {
    width: 20px;
    min-width: 20px;
    height: 2px;
    background: var(--lac-text-secondary);
    opacity: 0.3;
    margin: 0 3px;
    margin-bottom: 20px;
    transition: all 0.5s ease;
    position: relative;
    overflow: hidden;
}

.lac-step-connector.filling::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--lac-primary);
    animation: connectorFill 1s ease-out forwards;
}

.lac-mode-generation .lac-step-connector.filling::after {
    background: linear-gradient(90deg, #10b981, #3b82f6);
}

.lac-step-connector.filled {
    background: #34c759;
    opacity: 0.7;
}

/* Les étapes non utilisées sont cachées par défaut via JS */
.lac-step-indicator:not(.visible),
.lac-step-indicator:not(.visible) + .lac-step-connector {
    display: none;
}

/* Main Text */
.lac-loader-text {
    font-size: 22px;
    color: var(--lac-text-main);
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
    animation: textFadeIn 0.6s ease-out;
    text-align: center;
    width: 100%;
}

.lac-loader-subtext {
    font-size: 14px;
    color: var(--lac-text-secondary);
    margin: 0;
    animation: textFadeIn 0.6s ease-out 0.2s both;
    text-align: center;
    width: 100%;
    line-height: 1.5;
}

/* Keyframe Animations */
@keyframes glowPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-5px) rotate(1deg); }
    75% { transform: translateY(5px) rotate(-1deg); }
}

@keyframes iconRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes ringExpand {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes connectorFill {
    from { width: 0%; }
    to { width: 100%; }
}

@keyframes textFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Text change animation */
.lac-loader-text.changing,
.lac-loader-subtext.changing {
    animation: textChange 0.4s ease-out;
}

@keyframes textChange {
    0% { opacity: 1; transform: translateY(0); }
    50% { opacity: 0; transform: translateY(-10px); }
    51% { transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Mobile Responsive - Loader */
@media (max-width: 600px) {
    #lac-loader {
        padding: 30px 15px;
        min-height: 400px;
    }

    .lac-icon-stage {
        width: 80px;
        height: 80px;
    }

    .lac-icon-main {
        width: 50px;
        height: 50px;
        border-radius: 14px;
    }

    .lac-icon-svg {
        width: 24px;
        height: 24px;
    }

    .lac-icon-glow {
        width: 100px;
        height: 100px;
    }

    .lac-icon-ring {
        width: 65px;
        height: 65px;
    }

    .lac-progress-steps {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 15px 10px;
        justify-content: flex-start;
        max-width: 100%;
    }

    .lac-step-connector {
        width: 20px;
        min-width: 20px;
    }

    .lac-step-label {
        font-size: 10px;
        max-width: 55px;
    }

    .lac-loader-text {
        font-size: 18px;
        padding: 0 10px;
    }

    .lac-loader-subtext {
        font-size: 13px;
        padding: 0 15px;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .lac-grid {
        grid-template-columns: 1fr;
        /* Scroll horizontal for mobile experience as per request */
        display: flex;
        overflow-x: auto;
        padding-bottom: 20px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch; /* iOS smooth scrolling */
        scrollbar-width: none; /* Firefox */
    }
    .lac-grid::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

    .lac-post-card {
        min-width: 85vw;
        scroll-snap-align: center;
        margin-right: 15px;
    }

    .lac-container {
        padding: 20px;
    }
}