/* Global Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.5;
    min-height: 100vh;
}

body.embed-page-body {
    background: #e9ecef !important;
    padding: 2rem;
}

.chat-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    text-align: center;
    padding: 1rem 0;
    border-bottom: 1px solid #e1e5eb;
    margin-bottom: 1rem;
}

.header h1 {
    font-size: 1.25rem;
    color: #0066cc;
    font-weight: 600;
}

.header p {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Turnstile Container */
.turnstile-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.turnstile-container p {
    margin-bottom: 1rem;
    color: #555;
}

#session-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Questionnaire / Form */
.qa-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

.question-form {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.question-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.question-form textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e1e5eb;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.2s;
}

.question-form textarea:focus {
    border-color: #0066cc;
}

.form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

.char-count {
    font-size: 0.75rem;
    color: #888;
}

.question-form button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.question-form button:hover {
    background: #0055aa;
}

.question-form button:disabled {
    background: #99c2e8;
    cursor: not-allowed;
}

/* Loading Indicator */
.loading-indicator {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 1rem;
}

.loading-indicator.htmx-request {
    display: flex;
}

.htmx-request .question-form {
    opacity: 0.6;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e1e5eb;
    border-top-color: #0066cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 0.75rem;
}

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

.loading-indicator span {
    color: #666;
    font-size: 0.9rem;
}

/* Answer / Message Container */
.answer-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.question-display {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.question-display .label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.question-display p {
    margin-top: 0.25rem;
    font-weight: 500;
}

.answer-box {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.answer-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.answer-content {
    padding: 1rem;
    line-height: 1.6;
}

.answer-notice {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.answer-notice svg {
    flex-shrink: 0;
    margin-top: 1px;
}

.answer-notice span {
    line-height: 1.4;
}

.answer-text {
    line-height: 1.6;
}

/* Response Types Styling */
.answer-box.nivio_answer .answer-header {
    background: #fff3cd;
    color: #856404;
}

.answer-box.nivio_answer .answer-notice {
    background: #fffbf0;
    color: #856404;
}

.answer-box.nivio_answer_with_expert .answer-header {
    background: #a9d7ff;
    color: #151557;
}

.answer-box.nivio_answer_with_expert .answer-notice {
    background: #a9d7ff;
    color: #151557;
}

.answer-box.off_topic .answer-header {
    background: #e2e3e5;
    color: #495057;
}

.answer-box.off_topic .answer-content {
    color: #6c757d;
}

.answer-box.medical_disclaimer .answer-header {
    background: #f8d7da;
    color: #721c24;
}

.answer-box.medical_disclaimer .answer-content {
    color: #721c24;
}

.answer-box.error .answer-header {
    background: #f8d7da;
    color: #721c24;
}

/* Expert FAQ */
.expert-box {
    margin: 0 1rem 1rem;
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.875rem;
}

.expert-box .expert-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 0.5rem;
    padding: 0;
    background: none;
}

.expert-question {
    margin-bottom: 0.5rem;
    color: #333;
}

.expert-answer {
    color: #555;
    line-height: 1.5;
}

/* Buttons */
.next-question-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem;
    background: #0066cc;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 0.5rem;
}

.next-question-btn:hover {
    background: #0055aa;
}

/* Image Gallery */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 0 1rem 1rem;
}

.gallery-item {
    display: flex;
    flex-direction: column;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    background: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.gallery-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    object-position: center;
    background: #f5f5f5;
    display: block;
}

.gallery-caption {
    padding: 0.5rem;
    font-size: 0.75rem;
    color: #666;
    background: #fff;
    border-top: 1px solid #eee;
    line-height: 1.3;
}

/* Button Gallery */
.button-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0 1rem 1rem;
}

.gallery-button {
    display: inline-block;
    padding: 0.6rem 1rem;
    background: white;
    color: #0066cc;
    border: 1px solid #0066cc;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}


.gallery-button:hover {
    background: #f0f7ff;
    border-color: #0055aa;
    color: #0055aa;
    transform: translateY(-1px);
}

.gallery-button:active {
    transform: translateY(0);
}

.gallery-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f5f5f5 !important;
    border-color: #ddd !important;
    color: #888 !important;
}


/* Errors */
.error-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8d7da;
    color: #721c24;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    font-size: 0.875rem;
}

/* Embed Example Styles */
.embed-container {
    max-width: 1200px;
    margin: 0 auto;
}

.embed-wrapper {
    background: white;
    margin: 0 auto;
    padding: 1rem;
    border-radius: 12px;
    max-width: 700px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

iframe {
    width: 100%;
    height: 700px;
    border: none;
    border-radius: 8px;
}

.demo-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.embed-page-body h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #0066cc;
}

.demo-btn {
    padding: 10px 20px;
    background-color: #0066cc;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.demo-btn:hover {
    background-color: #0055aa;
}

/* Policy Pages */
.policy-page {
    background: #f5f7fa;
    padding: 2rem 1rem;
}

.policy-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.policy-container .header {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #666;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: #0066cc;
}

.policy-content {
    line-height: 1.7;
    color: #444;
}

.policy-content h2 {
    margin: 1.5rem 0 1rem;
    font-size: 1.25rem;
    color: #333;
}

.policy-content p {
    margin-bottom: 1rem;
}

.policy-content ul {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.policy-content li {
    margin-bottom: 0.5rem;
}

/* Footer & Legal */
.combined-footer {
    text-align: center;
    padding: 1rem;
    border-top: 1px solid #e1e5eb;
    margin-top: auto;
    background: transparent;
}

.legal-links a {
    color: #888;
    text-decoration: none;
}

.legal-links a:hover {
    text-decoration: underline;
}

.footer-disclaimer {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.footer-disclaimer svg {
    vertical-align: middle;
    margin-right: 0.25rem;
}

.legal-links {
    font-size: 11px;
    color: #aaa;
}

.footer-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.acceptance-notice {
    font-size: 10px;
    color: #999;
    display: block;
}

.acceptance-notice a {
    color: #777;
    text-decoration: underline;
}