/* Base Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    color: #333;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: #007bff;
    color: white;
    padding: 1rem;
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.env-badge {
    background: #dc2626;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 8px;
    vertical-align: middle;
    letter-spacing: 0.05em;
}

.env-badge.demo-badge {
    background: #f59e0b;
}

/* Demo Banner */
.demo-banner {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    text-align: center;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 0.95rem;
}

/* Demo Admin Link Button */
.demo-admin-link {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white !important;
    text-decoration: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-left: auto;
    box-shadow: 0 2px 12px rgba(245, 158, 11, 0.5);
    transition: transform 0.2s, box-shadow 0.2s;
}

.demo-admin-link:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.7);
}

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Chat Bubbles */
.message {
    max-width: 80%;
    padding: 0.8rem 1.2rem;
    border-radius: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.user-message {
    align-self: flex-end;
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 0.2rem;
}

.ai-message {
    align-self: flex-start;
    background-color: white;
    border: 1px solid #ddd;
    border-bottom-left-radius: 0.2rem;
}

.ai-content {
    overflow-x: auto;
}

.ai-content pre {
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 0.8rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-size: 0.9rem;
}

.ai-content code {
    font-family: 'Consolas', 'Courier New', monospace;
}

.ai-content p code {
    background-color: #eee;
    padding: 0.1rem 0.3rem;
    border-radius: 0.2rem;
    font-size: 0.9em;
}

.ai-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.ai-content th,
.ai-content td {
    border: 1px solid #ddd;
    padding: 0.4rem 0.6rem;
    text-align: left;
}

.ai-content th {
    background-color: #f0f0f0;
    font-weight: bold;
}

/* Collapsible Sections (References & Debug) */
.collapsible-section {
    margin-top: 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    overflow: hidden;
}

.collapsible-section summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0;
    user-select: none;
}

.collapsible-section summary::-webkit-details-marker {
    display: none;
}

.collapsible-section summary::before {
    content: '▶';
    font-size: 0.6rem;
    color: #999;
    transition: transform 0.2s;
}

.collapsible-section[open] summary::before {
    transform: rotate(90deg);
}

.section-tag {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.ref-tag {
    background-color: #e8f0fe;
    color: #1a73e8;
    border: 1px solid #c5d9f7;
}

.debug-tag {
    background-color: #fef3e0;
    color: #e65100;
    border: 1px solid #f5d0a0;
}

.section-count {
    font-size: 0.7rem;
    color: #999;
}

.collapsible-body {
    padding: 0.5rem 0.6rem;
    margin-top: 0.3rem;
    background-color: #f9f9f9;
    border-radius: 0.4rem;
    border: 1px solid #eee;
    color: #555;
}

.reference-item {
    margin-bottom: 0.3rem;
    border-left: 3px solid #1a73e8;
    padding-left: 0.5rem;
}

/* Input Area */
#input-area {
    background-color: white;
    padding: 1rem;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 0.5rem;
}

#message-input {
    flex: 1;
    padding: 0.8rem;
    border: 1px solid #ccc;
    border-radius: 0.5rem;
    font-size: 1rem;
    resize: none;
    height: 2.5rem;
    /* Initial height */
}

#send-button {
    padding: 0 1.5rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

#send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#send-button:hover:not(:disabled) {
    background-color: #0056b3;
}

/* Responsive */
@media (max-width: 600px) {
    .message {
        max-width: 90%;
    }
}

/* Feedback Button */
.feedback-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: #fff;
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    margin-top: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.feedback-btn:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgb(0, 0, 0);
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#feedback-input {
    width: 100%;
    height: 100px;
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    resize: vertical;
    box-sizing: border-box;
}

#submit-feedback {
    background-color: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

#submit-feedback:hover {
    background-color: #218838;
}

#feedback-preview-btn {
    background-color: #007bff;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

#feedback-preview-btn:hover {
    background-color: #0056b3;
}

.feedback-preview-box {
    margin: 15px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #007bff;
}

.feedback-preview-box pre {
    background-color: #fff;
    padding: 10px;
    border-radius: 5px;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 8px 0 0;
}

.feedback-confirm-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.feedback-confirm-actions .secondary {
    background-color: #6c757d;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

.feedback-confirm-actions .secondary:hover {
    background-color: #545b62;
}

#feedback-done-phase {
    text-align: center;
    padding: 20px 0;
}

.note {
    font-size: 0.8rem;
    color: #666;
    margin-top: 10px;
}