/**
 * AI LMS Survey Frontend Styles (REFACTORED)
 *
 * @package AI_LMS
 * @version 2.0.0 (Refactored) - Airbnb-inspired UI with BDE Brand
 */

/**
 * DESIGN SYSTEM - BDE Brand & Airbnb-Inspired
 * =============================================
 */

:root {
    /* BDE Brand Colors */
    --bde-primary: #F57C00;        /* Orange - Primary actions */
    --bde-primary-dark: #E65100;   /* Darker orange for hover */
    --bde-primary-light: #FFB74D;  /* Lighter orange for backgrounds */
    --bde-dark-blue: #0F2E5C;      /* Dark blue - Headings/text */
    --bde-accent-green: #059669;   /* Green - Success states */

    /* Neutral Palette (Airbnb-inspired) */
    --neutral-50: #F9FAFB;
    --neutral-100: #F3F4F6;
    --neutral-200: #E5E7EB;
    --neutral-300: #D1D5DB;
    --neutral-400: #9CA3AF;
    --neutral-600: #4B5563;
    --neutral-700: #374151;
    --neutral-800: #1F2937;
    --neutral-900: #111827;

    /* Semantic Colors */
    --success: #059669;
    --success-bg: #D1FAE5;
    --error: #DC2626;
    --error-bg: #FEE2E2;
    --warning: #F59E0B;
    --warning-bg: #FEF3C7;

    /* Spacing System */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Shadows (Airbnb-style) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
    --shadow-card: 0 2px 12px rgba(15, 46, 92, 0.08);

    /* Typography Scale */
    --text-xs: 12px;
    --text-sm: 14px;
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 30px;
    --text-4xl: 36px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/****** SURVEY CONTAINER ******/

.ailms-survey-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.ailms-survey-wrapper {
    background: #ffffff;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

.ailms-survey-loading {
    text-align: center;
    padding: 48px 24px;
    color: #666;
    font-size: 16px;
}

.ailms-survey-loading span {
    display: inline-block;
    animation: pulse 1.5s ease-in-out infinite;
}

/****** PROGRESS BAR ******/

.ailms-progress-section {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--bde-dark-blue) 0%, #1a3a6b 100%);
    padding: var(--space-lg) var(--space-xl);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.ailms-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    color: #ffffff;
}

.ailms-progress-text {
    font-size: var(--text-sm);
    font-weight: 500;
    opacity: 0.9;
}

.ailms-progress-counter {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--bde-primary-light);
}

.ailms-progress-bar-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.ailms-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--bde-primary) 0%, var(--bde-primary-light) 100%);
    border-radius: var(--radius-full);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(245, 124, 0, 0.5);
    position: relative;
}

.ailms-progress-bar-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Progress animation */
@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.ailms-progress-bar-fill.animating {
    animation: progressPulse 1s ease-in-out;
}

/****** SURVEY CONTENT ******/

.ailms-survey-content {
    padding: var(--space-2xl) var(--space-xl);
}

/****** SURVEY HEADER ******/

.ailms-survey-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--bde-dark-blue);
    margin: 0 0 var(--space-md) 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.ailms-survey-description {
    font-size: var(--text-base);
    color: var(--neutral-600);
    margin: 0 0 var(--space-2xl) 0;
    line-height: 1.6;
}

/****** SURVEY FORM ******/

.ailms-survey-form {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/****** SECTION HEADERS ******/

.ailms-question-section-header {
    margin: 24px 0 16px 0;
    padding: 12px 0;
    border-bottom: 2px solid #e2e8f0;
}

.ailms-section-title {
    font-size: 20px;
    font-weight: 600;
    color: #2d3748;
    margin: 0;
}

/****** QUESTION ITEM - CARD STYLE ******/

.ailms-question-item {
    background: var(--neutral-50);
    border: 2px solid var(--neutral-200);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    transition: all var(--transition-base);
    opacity: 0;
    transform: translateY(20px);
    animation: questionFadeIn 0.4s ease forwards;
}

.ailms-question-item:nth-child(1) { animation-delay: 0.1s; }
.ailms-question-item:nth-child(2) { animation-delay: 0.2s; }
.ailms-question-item:nth-child(3) { animation-delay: 0.3s; }
.ailms-question-item:nth-child(4) { animation-delay: 0.4s; }
.ailms-question-item:nth-child(5) { animation-delay: 0.5s; }

@keyframes questionFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ailms-question-item:hover {
    border-color: var(--neutral-300);
    box-shadow: var(--shadow-md);
}

.ailms-question-item.answered {
    background: #ffffff;
    border-color: var(--bde-primary);
}

.ailms-question-header {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    margin-bottom: var(--space-md);
    gap: var(--space-md);
}

.ailms-question-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 var(--space-sm);
    background: var(--bde-primary);
    color: #ffffff;
    font-size: var(--text-sm);
    font-weight: 700;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.ailms-question-item.answered .ailms-question-number {
    background: var(--bde-accent-green);
}

.ailms-question-label {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--bde-dark-blue);
    line-height: 1.4;
    flex: 1;
    display: block;
}

.ailms-required-mark {
    color: var(--error);
    margin-left: var(--space-xs);
}

.ailms-error-message {
    color: var(--error);
    font-size: var(--text-sm);
    font-weight: 500;
    margin-top: var(--space-sm);
    display: none;
}

.ailms-question-item.has-error .ailms-error-message {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.ailms-question-item.has-error {
    border-color: var(--error);
    animation: errorShake 0.5s ease;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/****** RATING SCALE - AIRBNB STYLE ******/

.ailms-rating-container {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    justify-content: center;
    padding: var(--space-md) 0;
}

.ailms-star {
    cursor: pointer;
    transition: transform var(--transition-fast), filter var(--transition-fast);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: relative;
}

.ailms-star:hover {
    transform: scale(1.2);
}

.ailms-star:active {
    transform: scale(0.95);
}

.ailms-star svg {
    width: 36px;
    height: 36px;
    fill: var(--neutral-200);
    stroke: none;
    transition: all var(--transition-base);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.ailms-star:hover svg,
.ailms-star.active svg,
.ailms-star.hovered svg {
    fill: var(--bde-primary);
    filter: drop-shadow(0 4px 8px rgba(245, 124, 0, 0.3));
}

/* Animated star burst effect on selection */
.ailms-star.just-selected {
    animation: starBurst 0.5s var(--transition-bounce);
}

@keyframes starBurst {
    0% { transform: scale(1); }
    50% { transform: scale(1.4) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Touch device support */
@media (hover: none) {
    .ailms-star {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/****** CHOICE OPTIONS - CARD STYLE ******/

.ailms-choices-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.ailms-choice-label {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: #ffffff;
    border: 2px solid var(--neutral-200);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

/* Hover effect */
.ailms-choice-label:hover {
    border-color: var(--bde-primary-light);
    background: #FFF9F0;
    transform: translateX(4px);
}

/* Selected state */
.ailms-choice-label:has(input:checked) {
    border-color: var(--bde-primary);
    background: linear-gradient(135deg, #FFF9F0 0%, #FFEDD5 100%);
    box-shadow: 0 4px 12px rgba(245, 124, 0, 0.15);
}

/* Selection indicator */
.ailms-choice-label::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--bde-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--transition-base);
}

.ailms-choice-label:has(input:checked)::before {
    transform: scaleX(1);
}

/* Custom radio/checkbox */
.ailms-choice-label input[type="radio"],
.ailms-choice-label input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: 2px solid var(--neutral-300);
    transition: all var(--transition-fast);
    position: relative;
}

.ailms-choice-label input[type="radio"] {
    border-radius: 50%;
}

.ailms-choice-label input[type="checkbox"] {
    border-radius: var(--radius-sm);
}

.ailms-choice-label input:checked {
    border-color: var(--bde-primary);
    background: var(--bde-primary);
}

/* Radio dot */
.ailms-choice-label input[type="radio"]:checked::before {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: radioScale 0.2s var(--transition-bounce) forwards;
}

@keyframes radioScale {
    to { transform: translate(-50%, -50%) scale(1); }
}

/* Checkbox checkmark */
.ailms-choice-label input[type="checkbox"]:checked::before {
    content: '';
    width: 6px;
    height: 12px;
    border: solid white;
    border-width: 0 2px 2px 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -65%) rotate(45deg) scale(0);
    animation: checkScale 0.2s var(--transition-bounce) forwards;
}

@keyframes checkScale {
    to { transform: translate(-50%, -65%) rotate(45deg) scale(1); }
}

.ailms-choice-text {
    flex: 1;
    font-size: var(--text-base);
    color: var(--neutral-800);
    line-height: 1.5;
    font-weight: 500;
}

/****** SUBMIT BUTTON - BDE BRAND ******/

.ailms-survey-submit-container {
    margin-top: var(--space-xl);
    padding-top: var(--space-xl);
    border-top: 2px solid var(--neutral-200);
}

.ailms-btn-submit {
    width: 100%;
    padding: var(--space-lg) var(--space-xl);
    font-size: var(--text-lg);
    font-weight: 700;
    background: linear-gradient(135deg, var(--bde-primary) 0%, var(--bde-primary-dark) 100%);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: 0 4px 12px rgba(245, 124, 0, 0.3);
    position: relative;
    overflow: hidden;
}

/* Shine effect */
.ailms-btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.ailms-btn-submit:hover::before {
    left: 100%;
}

.ailms-btn-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 124, 0, 0.4);
}

.ailms-btn-submit:active:not(:disabled) {
    transform: translateY(0);
}

.ailms-btn-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading state */
.ailms-btn-submit.loading {
    pointer-events: none;
}

.ailms-btn-submit.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    margin-left: var(--space-sm);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: buttonSpin 0.6s linear infinite;
}

@keyframes buttonSpin {
    to { transform: rotate(360deg); }
}

/****** SUCCESS MESSAGE ******/

.ailms-survey-success {
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    animation: successFadeIn 0.5s ease;
}

@keyframes successFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ailms-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    background: var(--success-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bde-accent-green);
    animation: successBounce 0.6s var(--transition-bounce);
}

@keyframes successBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.ailms-success-icon svg {
    width: 48px;
    height: 48px;
    stroke-width: 3;
}

.ailms-survey-success h3 {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--bde-dark-blue);
    margin: 0 0 var(--space-md) 0;
}

.ailms-survey-success p {
    font-size: var(--text-base);
    color: var(--neutral-600);
    margin: 0;
}

/****** ERROR MESSAGE ******/

.ailms-survey-error {
    padding: var(--space-lg);
    background: var(--error-bg);
    border-left: 4px solid var(--error);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    animation: errorShake 0.5s ease;
}

.ailms-survey-error p {
    margin: 0;
    font-size: var(--text-base);
    color: var(--error);
    font-weight: 500;
}

/****** ANIMATIONS ******/

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/****** RESPONSIVE BREAKPOINTS ******/

/* Tablet - 768px */
@media screen and (max-width: 768px) {
    :root {
        --space-xl: 24px;
        --space-2xl: 32px;
        --text-3xl: 26px;
    }

    .ailms-survey-content {
        padding: var(--space-xl) var(--space-lg);
    }

    .ailms-progress-section {
        padding: var(--space-md) var(--space-lg);
    }

    .ailms-question-label {
        font-size: var(--text-base);
    }

    .ailms-star svg {
        width: 32px;
        height: 32px;
    }
}

/* Mobile - 480px */
@media screen and (max-width: 480px) {
    :root {
        --space-lg: 16px;
        --space-xl: 20px;
        --space-2xl: 24px;
        --text-3xl: 22px;
    }

    .ailms-survey-container {
        padding: 0;
    }

    .ailms-survey-wrapper {
        border-radius: 0;
    }

    .ailms-survey-content {
        padding: var(--space-lg);
    }

    .ailms-progress-section {
        border-radius: 0;
        padding: var(--space-md) var(--space-lg);
    }

    .ailms-question-item {
        padding: var(--space-md);
    }

    .ailms-rating-container {
        gap: var(--space-xs);
    }

    .ailms-star {
        width: 44px;
        height: 44px;
    }

    .ailms-star svg {
        width: 28px;
        height: 28px;
    }

    .ailms-choice-label {
        padding: var(--space-md);
    }

    .ailms-btn-submit {
        padding: var(--space-md) var(--space-lg);
        font-size: var(--text-base);
    }
}

@media screen and (max-width: 480px) {
    .ailms-survey-container {
        padding: 12px;
    }

    .ailms-survey-title {
        font-size: 20px;
        margin-bottom: 12px;
    }

    .ailms-survey-description {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .ailms-rating-container {
        justify-content: space-between;
    }

    .ailms-star svg {
        width: 32px;
        height: 32px;
    }

    .ailms-btn-submit {
        font-size: 16px;
        padding: 14px 24px;
    }
}

/****** ACCESSIBILITY ******/

/* Focus states */
.ailms-star:focus {
    outline: 2px solid #3182ce;
    outline-offset: 2px;
    border-radius: 4px;
}

.ailms-choice-label:focus-within {
    outline: 2px solid #3182ce;
    outline-offset: 2px;
}

.ailms-btn:focus {
    outline: 2px solid #3182ce;
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .ailms-choice-label {
        border-width: 3px;
    }

    .ailms-star.active {
        color: #d97706;
    }

    .ailms-choice-label:has(input:checked) {
        border-color: #1e40af;
        background: #dbeafe;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ailms-star {
        transition: none;
    }

    .ailms-star:hover {
        transform: none;
    }

    .ailms-choice-label {
        transition: none;
    }

    .ailms-btn {
        transition: none;
    }

    .ailms-btn-primary:hover:not(:disabled) {
        transform: none;
    }

    @keyframes pulse {
        0%, 100% {
            opacity: 1;
        }
    }
}

/* Print styles */
@media print {
    .ailms-survey-submit-container {
        display: none;
    }

    .ailms-survey-container {
        box-shadow: none;
        border: 1px solid #000;
    }
}
