/* THRESHOLD Assessment CSS */

.threshold-assessment-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box; /* Ensure consistent box model */
}

/* Loading Styles */
.threshold-loading {
    text-align: center;
    padding: 40px;
}

.threshold-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.threshold-spinner-small {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #fff; /* White for button context */
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Header Styles */
.threshold-header {
    text-align: center;
    margin-bottom: 30px;
}

.threshold-header h2 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 2rem;
}

.threshold-header p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

/* Progress Bar */
.threshold-progress {
    background-color: #ecf0f1;
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

.threshold-progress-bar {
    background: linear-gradient(90deg, #3498db, #2980b9);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.threshold-progress-mini {
    background-color: #ecf0f1;
    border-radius: 4px;
    height: 4px;
    overflow: hidden;
    margin-top: 10px;
}

/* Question Card */
.threshold-question-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 30px;
    margin-bottom: 30px;
}

.threshold-domain-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.threshold-domain-icon {
    font-size: 1.5rem;
}

.threshold-domain-name {
    font-weight: 600;
    color: #2c3e50;
}

.threshold-question-text {
    color: #2c3e50;
    line-height: 1.6;
    margin-bottom: 25px;
    font-size: 1.1rem;
}

/* Answer Styles */
.threshold-answers {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.threshold-answer {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.threshold-answer:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
}

.threshold-answer.selected {
    border-color: #3498db;
    background-color: #e3f2fd;
}

.threshold-answer input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.threshold-answer-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.threshold-answer-letter {
    font-weight: 600;
    color: #3498db;
    min-width: 20px; /* Ensure letter takes consistent space */
}

.threshold-answer-text {
    color: #2c3e50;
    line-height: 1.5;
    flex: 1;
}

.threshold-other-input {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box; /* Include padding/border in element's total width/height */
}

.threshold-other-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

/* Navigation Buttons */
.threshold-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.threshold-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    flex: 1; /* Make buttons take equal width */
    text-align: center;
    text-decoration: none; /* For links styled as buttons */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.threshold-btn-primary {
    background: linear-gradient(45deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}

.threshold-btn-primary:hover:not(:disabled) {
    background: linear-gradient(45deg, #2980b9, #3498db);
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.4);
}

.threshold-btn-secondary {
    background-color: #ecf0f1;
    color: #34495e;
    border: 1px solid #bdc3c7;
}

.threshold-btn-secondary:hover:not(:disabled) {
    background-color: #dbe4e8;
    border-color: #aeb6bb;
}

.threshold-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

/* Results Page Styles */
.threshold-results {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    padding: 30px;
    margin-bottom: 30px;
    text-align: center;
}

.threshold-results-header h2 {
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 10px;
}

.threshold-results-header p {
    color: #7f8c8d;
    margin-bottom: 30px;
}

/* Email Collection */
.threshold-email-collection {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 30px;
    text-align: center;
}

.threshold-email-collection h3 {
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.threshold-email-collection p {
    color: #555;
    margin-bottom: 20px;
}

.threshold-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    justify-content: center;
}

.threshold-form-row input[type="text"],
.threshold-form-row input[type="email"] {
    flex: 1;
    min-width: 200px; /* Ensure inputs don't get too small */
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
}

.threshold-form-row input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

/* Top Three Priority Areas */
.threshold-top-three {
    margin-bottom: 30px;
}

.threshold-top-three h3 {
    color: #2c3e50;
    font-size: 1.6rem;
    margin-bottom: 25px;
}

.threshold-priority-card {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: left;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.threshold-priority-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.threshold-priority-info h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.2rem;
}

.threshold-score {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Score interpretation colors */
.threshold-red { color: #e74c3c; }
.threshold-orange { color: #f39c12; }
.threshold-yellow { color: #f1c40f; }
.threshold-green { color: #2ecc71; }

.threshold-priority-description {
    color: #555;
    line-height: 1.6;
    margin-bottom: 15px;
}

/* AI Prompt Section */
.threshold-ai-prompt {
    background-color: #eaf7ff; /* Light blue background */
    border: 1px solid #a7d9ff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    text-align: left;
}

.threshold-ai-prompt h5 {
    color: #2980b9;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.threshold-prompt-box {
    background-color: #f0f8ff; /* Lighter blue for code box */
    border: 1px dashed #b3e0ff;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    color: #333;
    white-space: pre-wrap; /* Preserve whitespace and wrap text */
    word-break: break-word; /* Break long words */
}

.threshold-btn-small {
    padding: 8px 15px;
    font-size: 0.9rem;
    background-color: #6c757d; /* Darker grey for copy button */
    color: white;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.threshold-btn-small:hover:not(:disabled) {
    background-color: #5a6268;
}

/* Complete Overview Grid */
.threshold-complete-overview {
    margin-bottom: 30px;
}

.threshold-complete-overview h3 {
    color: #2c3e50;
    font-size: 1.6rem;
    margin-bottom: 25px;
}

.threshold-domain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    text-align: left;
}

.threshold-domain-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.threshold-domain-card .threshold-domain-header {
    margin-bottom: 10px;
    padding: 0;
    background: none;
    border-radius: 0;
}

.threshold-domain-card .threshold-domain-header h4 {
    font-size: 1rem;
    margin: 0;
}

.threshold-domain-card .threshold-domain-header p {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Next Steps */
.threshold-next-steps {
    margin-bottom: 30px;
}

.threshold-next-steps h3 {
    color: #2c3e50;
    font-size: 1.6rem;
    margin-bottom: 25px;
}

.threshold-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    text-align: left;
}

.threshold-step {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.threshold-step-number {
    background-color: #3498db;
    color: white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.threshold-step h4 {
    margin-top: 0;
    margin-bottom: 5px;
    color: #2c3e50;
}

.threshold-step p {
    color: #555;
    line-height: 1.5;
    margin-bottom: 0;
}

/* Action Buttons at the bottom */
.threshold-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
}

/* Message Box Styles */
.threshold-message {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    animation: fadeIn 0.5s ease-out;
}

.threshold-message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.threshold-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.threshold-message-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* NEW: AI Chat Modal Styles */
.threshold-ai-chat-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000; /* High z-index to be on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6); /* Semi-transparent black background */
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.threshold-ai-chat-modal.active {
    display: flex; /* Show when active */
}

.threshold-chat-content {
    background-color: #fefefe;
    margin: auto;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    width: 90%;
    max-width: 600px;
    height: 80vh; /* Max height for chat content */
    overflow: hidden;
}

.threshold-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #3498db;
    color: white;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.threshold-chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.threshold-close-chat {
    color: white;
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.threshold-close-chat:hover,
.threshold-close-chat:focus {
    color: #ddd;
    text-decoration: none;
    outline: none;
}

.threshold-chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #eef2f7; /* Light background for messages */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.threshold-message-bubble {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.5;
}

.threshold-message-bubble p {
    margin: 0;
}

.user-bubble {
    background-color: #dcf8c6; /* Light green for user messages */
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.ai-bubble {
    background-color: #ffffff; /* White for AI messages */
    align-self: flex-start;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 2px;
}

.threshold-chat-input-area {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background-color: #fefefe;
    gap: 10px;
}

.threshold-chat-input-area textarea {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-size: 1rem;
    font-family: inherit;
    box-sizing: border-box;
}

.threshold-chat-input-area textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.25);
}

.threshold-chat-input-area .threshold-btn-primary {
    padding: 10px 20px;
    font-size: 1rem;
    flex-shrink: 0;
}


/* WordPress Theme Compatibility */
.threshold-assessment-wrapper * {
    box-sizing: border-box;
}

.threshold-assessment-wrapper h1,
.threshold-assessment-wrapper h2,
.threshold-assessment-wrapper h3,
.threshold-assessment-wrapper h4,
.threshold-assessment-wrapper h5 {
    margin-top: 0;
}

.threshold-assessment-wrapper button:focus,
.threshold-assessment-wrapper input:focus,
.threshold-assessment-wrapper textarea:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .threshold-navigation,
    .threshold-email-collection,
    .threshold-actions,
    .threshold-ai-chat-modal { /* Hide chat modal when printing */
        display: none !important;
    }
    .threshold-assessment-wrapper {
        box-shadow: none;
        max-width: none;
        margin: 0;
        padding: 0;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .threshold-assessment-wrapper {
        padding: 15px;
    }
    
    .threshold-header h2 {
        font-size: 1.8rem;
    }
    
    .threshold-question-card {
        padding: 20px;
    }
    
    .threshold-btn {
        width: 100%;
        min-width: unset;
    }
    
    .threshold-navigation {
        flex-direction: column;
    }
    
    .threshold-form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .threshold-priority-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .threshold-step {
        flex-direction: column;
        text-align: center;
    }
    
    .threshold-step-number {
        margin: 0 auto 10px; /* Center number above text on small screens */
    }

    .threshold-chat-content {
        width: 95%;
        height: 90vh;
    }
}

@media (max-width: 480px) {
    .threshold-assessment-wrapper {
        padding: 10px;
    }
    
    .threshold-question-card {
        padding: 15px;
    }
    
    .threshold-answer {
        padding: 12px;
    }
    
    .threshold-domain-header {
        padding: 8px 12px;
    }
    
    .threshold-priority-card {
        padding: 16px;
    }
    
    .threshold-domain-grid {
        grid-template-columns: 1fr; /* Stack domains on very small screens */
    }
}
