/* --- AI Interview Prep Pro Styles --- */
.ai-interview-prep-container {
    max-width: 900px;
    margin: 40px auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

/* --- Header --- */
.ai-question-header {
    background: linear-gradient(135deg, #6d28d9, #8b5cf6); /* Purple Gradient */
    color: white;
    padding: 30px 35px;
    text-align: center;
    border-bottom: 5px solid #5b21b6; /* Darker purple accent */
}

.ai-question-header h2 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.ai-question-header .ai-icon {
    font-size: 24px;
    line-height: 1;
}

.ai-subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 17px;
}

/* --- Login Notice --- */
.ai-prep-login-notice {
    background-color: #fffbeb; /* Light yellow */
    color: #b45309; /* Amber */
    padding: 15px 25px;
    margin: 25px 35px 0;
    border-radius: 8px;
    border: 1px solid #fde68a;
    text-align: center;
    font-size: 15px;
}
.ai-prep-login-notice .dashicons {
    margin-right: 8px;
    vertical-align: middle;
}


/* --- Upload Section --- */
.ai-prep-upload-section {
    padding: 35px;
}

#ai-prep-form {
    margin-top: 25px;
}

.ai-prep-form-grid {
    display: grid;
    grid-template-columns: 1fr; /* Default single column */
    gap: 25px;
    margin-bottom: 30px;
}

/* Make grid 2 columns on wider screens */
@media (min-width: 768px) {
    .ai-prep-form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
     /* Span file upload across columns if needed, or adjust layout */
    .file-upload-container {
       grid-column: span 2; /* Example: span full width */
       /* or grid-column: auto; to keep it in one column */
    }
}


.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
    color: #374151; /* Darker gray */
    align-items: center;
    gap: 8px;
    font-size: 16px;
}
.form-group label .dashicons {
    color: #8b5cf6; /* Purple icon */
}

.form-group input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #d1d5db; /* Gray border */
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

.form-group input[type="text"]:focus {
    border-color: #8b5cf6;
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2); /* Purple focus ring */
}

/* --- File Upload Styling (Adapted from ATS) --- */
.file-upload-wrapper {
    border: 2px dashed #a78bfa; /* Lighter Purple dashed */
    border-radius: 8px;
    padding: 25px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f5f3ff; /* Very light purple */
    text-align: center;
}
.file-upload-wrapper.dragging,
.file-upload-wrapper:hover {
    border-color: #6d28d9; /* Darker purple */
    background-color: #ede9fe; /* Slightly darker light purple */
}
.upload-icon svg {
    width: 40px;
    height: 40px;
    stroke: #8b5cf6; /* Purple */
    margin-bottom: 10px;
}
.upload-text {
    display: block;
    color: #5b21b6; /* Dark purple text */
    font-size: 16px;
    margin-bottom: 5px;
    font-weight: 500;
}
.file-name {
    display: block;
    color: #6d28d9;
    font-weight: bold;
    font-size: 14px;
    margin-top: 8px;
    min-height: 20px;
    word-break: break-all;
}
.file-format-info {
    display: block;
    margin-top: 8px;
    color: #6b7280; /* Gray */
    font-size: 13px;
}

/* --- Main Button --- */
.ai-prep-button {
    display: inline-flex; /* Use inline-flex for icon alignment */
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%; /* Full width for primary action */
    padding: 14px 25px;
    background: linear-gradient(135deg, #6d28d9, #8b5cf6); /* Purple Gradient */
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.2);
}
.ai-prep-button .dashicons {
    font-size: 20px;
    line-height: 1;
}
.ai-prep-button:hover {
    background: linear-gradient(135deg, #5b21b6, #7c3aed); /* Darker Gradient */
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.3);
}
.ai-prep-button:active {
    transform: translateY(0);
}

/* Secondary Button Style */
.ai-prep-button.secondary {
    background: #f5f3ff; /* Light purple background */
    color: #6d28d9; /* Purple text */
    border: 1px solid #c4b5fd; /* Light purple border */
    box-shadow: none;
    width: auto; /* Auto width for secondary */
    font-weight: 500;
}
.ai-prep-button.secondary:hover {
    background: #ede9fe;
    border-color: #a78bfa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.1);
}

/* --- Loader (Adapted from ATS) --- */
.ai-prep-loader {
    position: relative;
    margin: 40px auto;
    padding: 50px 20px;
    text-align: center;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #f9fafb; /* Light gray background */
}
.loader-message {
    margin-top: 25px;
    color: #6d28d9; /* Purple */
    font-size: 18px;
    font-weight: 500;
    animation: pulse 1.5s infinite ease-in-out;
}
.loader-animation {
    position: relative;
    width: 80px;
    height: 80px;
}
.loader-animation div {
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #c4b5fd); /* Lighter purple gradient */
    animation: loader-animation 1.2s linear infinite;
}
/* Loader animation keyframes and nth-child positioning (same as ATS) */
.loader-animation div:nth-child(1) { top: 8px; left: 8px; animation-delay: 0s; }
.loader-animation div:nth-child(2) { top: 8px; left: 32px; animation-delay: -0.4s; }
.loader-animation div:nth-child(3) { top: 8px; left: 56px; animation-delay: -0.8s; }
.loader-animation div:nth-child(4) { top: 32px; left: 8px; animation-delay: -0.4s; }
.loader-animation div:nth-child(5) { top: 32px; left: 32px; animation-delay: -0.8s; }
.loader-animation div:nth-child(6) { top: 32px; left: 56px; animation-delay: -1.2s; }
.loader-animation div:nth-child(7) { top: 56px; left: 8px; animation-delay: -0.8s; }
.loader-animation div:nth-child(8) { top: 56px; left: 32px; animation-delay: -1.2s; }
.loader-animation div:nth-child(9) { top: 56px; left: 56px; animation-delay: -1.6s; }

@keyframes loader-animation {
    0%, 100% { opacity: 1; transform: scale(1.2); }
    50% { opacity: 0.5; transform: scale(0.8); }
}
/* Loading progress bar (same as ATS) */
.loading-progress {
    width: 250px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    margin-top: 25px;
    overflow: hidden;
    position: relative;
}
.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8b5cf6, #a78bfa); /* Purple gradient for progress */
    border-radius: 4px;
    position: absolute;
    transition: width 0.5s ease;
    animation: progress-animation 2s infinite linear; /* Linear animation */
}
@keyframes progress-animation {
    0% { width: 0%; left: 0%; }
    50% { width: 100%; left: 0%; }
    100% { width: 0%; left: 100%;}
}
@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}


/* --- Results Section --- */
.ai-prep-results-section {
    padding: 0 35px 35px; /* No top padding, handled by header */
}
.ai-response-header {
    padding: 20px 0;
    margin-bottom: 25px;
    border-bottom: 2px solid #ede9fe; /* Light purple border */
}
.ai-response-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    color: #5b21b6; /* Dark Purple */
    font-weight: 600;
}
.ai-response-header h3 .dashicons {
    color: #16a34a; /* Green checkmark */
}
#result-role-title {
    font-style: italic;
    color: #374151;
}

/* Question Sections */
.question-section {
    margin-bottom: 35px;
}
.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb; /* Gray border */
}
.section-header h3 {
    margin: 0;
    font-size: 19px;
    color: #4b5563; /* Medium Gray */
    font-weight: 600;
}
.section-header .dashicons {
    color: #8b5cf6; /* Purple icon */
    font-size: 22px;
}

/* Individual Questions (Accordion Style) */
.question-item {
    margin-bottom: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden; /* Keep this to clip content during transition */
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.04);
    background-color: #fff;
    transition: box-shadow 0.3s ease;
}
.question-item:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.07);
}

.question-header {
    display: flex;
    align-items: center;
    padding: 18px 20px;
    background: #f9fafb; /* Very light gray */
    cursor: pointer;
    transition: background-color 0.3s;
}
.question-header:hover {
    background: #f3f4f6; /* Slightly darker gray */
}

.question-number {
    background: #8b5cf6; /* Purple */
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
    margin-right: 18px;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

.question-text {
    margin: 0;
    flex-grow: 1;
    font-weight: 500;
    color: #374151; /* Dark Gray */
    line-height: 1.5;
    font-size: 16px;
}

.toggle-icon {
    margin-left: 18px;
    color: #9ca3af; /* Medium Gray icon */
    transition: transform 0.3s ease-out;
    font-size: 22px;
}
.toggle-icon.open {
    transform: rotate(180deg);
    color: #6d28d9; /* Purple when open */
}

/* Answer Container */
.answer-container {
    background: white;
    padding: 0 20px 0 68px; /* Collapse padding vertically */
    max-height: 0; /* Collapse height */
    overflow: hidden; /* Hide content when collapsed */
    transition: max-height 0.4s ease-out, padding-top 0.4s ease-out, padding-bottom 0.4s ease-out, opacity 0.4s ease-out; /* Smooth transition for height, padding and opacity */
    border-top: 1px solid transparent; /* Start with transparent border */
    opacity: 0;
    box-sizing: border-box;
    
}
.answer-container.open {
    /* max-height is set by JS based on scrollHeight */
    padding-top: 20px; /* Expand vertical padding */
    padding-bottom: 20px; /* Expand vertical padding */
    opacity: 1; /* Fade in */
    border-top-color: #e5e7eb; /* Fade in border */
    /* overflow: hidden; SHOULD REMAIN hidden to ensure max-height transition works smoothly */
}
.answer-container p {
    margin: 0;
    color: #4b5563; /* Medium Gray */
    line-height: 1.7;
    font-size: 15px;
    /* Allow text wrapping */
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word; /* Ensure long words break */
}
.answer-container p strong {
     color: #5b21b6; /* Dark Purple for 'Answer:' */
     margin-right: 5px;
}

/* --- Results Actions --- */
.results-actions {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: space-between; /* Space out groups */
    align-items: center;
    gap: 20px; /* Gap between items */
}

.export-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap; /* Allow buttons to wrap */
}

#analyze-new-btn {
    width: auto; /* Adjust width as needed */
}

/* --- Error Message --- */
.ai-prep-error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 30px;
    margin: 35px;
    background: #fef2f2; /* Light red */
    border-radius: 8px;
    border: 1px solid #fecaca; /* Lighter red border */
    color: #b91c1c; /* Dark red text */
}
.ai-prep-error-message .dashicons {
    font-size: 48px;
    margin-bottom: 15px;
    color: #ef4444; /* Brighter red */
}
#error-text {
    font-size: 17px;
    margin-bottom: 25px;
    line-height: 1.6;
}
#error-try-again-btn {
    width: auto; /* Auto width for try again */
}


/* --- Print Styles --- */
@media print {
    body * {
        visibility: hidden;
    }
    .ai-interview-prep-container, .ai-interview-prep-container * {
        visibility: visible;
    }
     .ai-interview-prep-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        box-shadow: none;
        border: none;
    }
    .ai-prep-upload-section,
    .ai-prep-loader,
    .results-actions,
    .ai-prep-error-message,
    .toggle-icon {
        display: none !important; /* Hide non-content */
    }
    .ai-prep-results-section {
        padding: 0;
    }
    .question-header {
        background: none;
        padding: 10px 0; /* Adjust padding */
        cursor: default;
    }
     .question-number {
        background: #ccc; /* Simple gray for print */
        color: #000;
        box-shadow: none;
     }
    .answer-container {
        max-height: none !important; /* Ensure answers are visible */
        height: auto !important; /* Ensure height is auto */
        overflow: visible !important; /* Ensure overflow is visible */
        padding: 10px 0 10px 48px !important; /* Adjust padding */
        border-top: 1px solid #ccc;
        opacity: 1 !important;
        background: none;
    }
     .question-item {
         border: none;
         box-shadow: none;
         page-break-inside: avoid; /* Try to keep question/answer together */
         margin-bottom: 10px;
     }
     .section-header {
         border-bottom: 1px solid #999;
         padding-bottom: 5px;
         margin-bottom: 10px;
     }
     .ai-response-header {
         border-bottom: 2px solid #000;
         padding-bottom: 10px;
         margin-bottom: 15px;
     }
     .ai-response-header h3 { font-size: 18pt; }
     .section-header h3 { font-size: 14pt; }
     .question-text { font-size: 12pt; }
     .answer-container p { font-size: 11pt; }
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .ai-interview-prep-container {
        margin: 20px;
    }
    .ai-question-header { padding: 25px 20px; }
    .ai-question-header h2 { font-size: 24px; }
    .ai-subtitle { font-size: 16px; }
    .ai-prep-upload-section, .ai-prep-results-section, .ai-prep-error-message { padding: 25px; margin: 20px; }

    .question-number { width: 26px; height: 26px; font-size: 13px; margin-right: 12px; }
    .question-text { font-size: 15px; }
    .toggle-icon { margin-left: 12px; font-size: 20px; }
    .answer-container { padding-left: 50px; padding-right: 15px; } /* Adjust padding */
    .answer-container.open { padding-left: 50px; padding-right: 15px; }

     .results-actions {
         flex-direction: column; /* Stack actions vertically */
         align-items: stretch; /* Stretch items full width */
     }
     .export-options {
         justify-content: center; /* Center export buttons */
         width: 100%;
     }
     #analyze-new-btn {
         width: 100%; /* Make analyze new full width */
     }
}

@media (max-width: 480px) {
    .ai-prep-form-grid {
        gap: 20px;
    }
     .file-upload-wrapper { padding: 20px 15px; }
     .upload-icon svg { width: 35px; height: 35px; }
     .upload-text { font-size: 15px; }

     .question-header { padding: 15px; }
     .answer-container { padding-left: 45px; padding-right: 10px; } /* Further adjust padding */
     .answer-container.open { padding-left: 45px; padding-right: 10px; }
     .answer-container p { font-size: 14px; }
}