/* Main Styles - Matching Streamlit UI */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* Login Modal */
.modal {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: #1f77b4;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-content input {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.modal-content button {
    padding: 0.75rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.modal-content button:hover {
    background: #5568d3;
}

.error-message {
    color: #d32f2f;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.auth-toggle-text {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #555;
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    align-items: center;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: #667eea;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: underline;
}

.link-button:hover {
    color: #5568d3;
}

/* Main Header */
.main-header {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-align: center;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

/* Main Layout */
.main-layout {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 20px);
}

/* Email History Sidebar (Left - Minimizable) */
.email-history-sidebar {
    width: 300px;
    min-width: 300px;
    background: white;
    border-radius: 10px;
    padding: 1rem;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.email-history-sidebar.minimized {
    width: 50px;
    min-width: 50px;
    padding: 0.5rem;
}

.email-history-sidebar.minimized .sidebar-header h2,
.email-history-sidebar.minimized .email-history-list {
    display: none;
}

.email-history-sidebar.minimized .toggle-btn::after {
    content: "+";
}

.toggle-btn {
    padding: 0.25rem 0.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    background: #5568d3;
}

.email-history-list {
    margin-top: 1rem;
}

.email-history-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.email-history-item:hover {
    background: #e9ecef;
    border-left-color: #667eea;
}

.email-history-item.selected {
    background: #e7f3ff;
    border-left-color: #667eea;
}

.email-history-item-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
}

.email-history-item-meta {
    font-size: 0.75rem;
    color: #666;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.email-history-item-actions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.email-history-item-actions button {
    padding: 0.4rem;
    font-size: 0.75rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.email-history-item-actions button:active {
    transform: scale(0.95);
}

.email-history-item-actions button svg {
    width: 16px;
    height: 16px;
}

.btn-edit {
    background: #667eea;
    color: white;
}

.btn-edit:hover {
    background: #5568d3;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

/* Sidebar (Right - Email Preview) */
.sidebar {
    width: 70%;
    background: white;
    border-radius: 10px;
    padding: 1rem;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    color: #333;
}

.logout-btn {
    padding: 0.5rem 1rem;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.create-email-btn {
    padding: 0.5rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
}

.logout-btn:hover {
    background: #5a6268;
}

.email-preview {
    margin-top: 1rem;
}

.info-text {
    color: #666;
    font-style: italic;
}

.email-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: #f0f0f0;
    border-radius: 5px;
}

.email-day-header strong {
    font-size: 1rem;
    color: #333;
}

.variant-count {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.email-select {
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.email-iframe {
    width: 100%;
    height: 730px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin-bottom: 1rem;
}

.email-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.email-actions button {
    flex: 1;
    min-width: 0;
    padding: 0.5rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.validation-message {
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

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

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

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

/* Chat Area */
.chat-area {
    width: 30%;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1rem;
    overflow-y: auto;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 1rem;
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-bottom: 1rem;
}

.user-message {
    align-items: flex-end;
    text-align: right;
}

.assistant-message {
    align-items: flex-start;
    text-align: left;
}

.message-label {
    font-size: 0.75rem;
    color: #666;
    padding: 0 4px;
    margin-bottom: 4px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 70%;
    word-wrap: break-word;
    line-height: 1.6;
    display: inline-block;
}

.user-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    border-bottom-left-radius: 4px;
}

/* Loading Indicator */
.loading-container {
    margin-bottom: 1rem;
}

.loading-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Day Selection */
.day-selection {
    margin: 1rem 0;
}

.day-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.day-btn {
    flex: 1;
    min-width: 80px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
}

.day-btn:hover {
    background: #f0f0f0;
}

.day-btn.primary {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.day-btn.primary:hover {
    background: #5568d3;
}

/* Goal Selection */
.goal-selection {
    margin: 1rem 0;
}

.goal-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.goal-btn {
    flex: 1;
    min-width: 80px;
    padding: 0.75rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    text-align: center;
}

.goal-btn:hover {
    background: #f0f0f0;
}

.goal-btn.primary {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.goal-btn.primary:hover {
    background: #5568d3;
}

/* Chat Form */
.chat-form {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.input-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#userInput {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    width: 100%;
}

#userInput:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.btn-primary,
.btn-secondary {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

#skipBannerBtn {
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    width: 100%;
}

/* Email Confirmation */
.email-confirmation {
    margin: 1rem 0;
    padding: 1rem;
    background: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.confirmation-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Amplet Selection */
.amplet-selection {
    margin: 1rem 0;
    padding: 1rem;
    background: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.amplet-category {
    margin-bottom: 1.5rem;
}

.amplet-category h3 {
    margin-bottom: 0.5rem;
    color: #333;
}

.amplet-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.amplet-item input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Banner Upload UI */
.banner-upload {
    margin: 1rem 0;
    padding: 1rem;
    background: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.banner-upload h3 {
    margin-bottom: 1rem;
    color: #333;
}

.banner-options,
.banner-type,
.banner-source {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

.banner-options label,
.banner-type label,
.banner-source label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.banner-options input[type="radio"],
.banner-type input[type="radio"],
.banner-source input[type="radio"] {
    margin: 0;
}

#bannerUrl,
#bannerPrompt,
#bannerPromptCarousel {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin: 0.5rem 0;
    font-size: 1rem;
}

#bannerUrl {
    margin-bottom: 0.5rem;
}

#bannerJsonFile {
    margin: 0.5rem 0;
}

.banner-suggestions-list {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 5px;
}

.suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    margin: 0.5rem 0;
    background: white;
    border-radius: 5px;
}

.suggestion-item p {
    margin: 0;
    flex: 1;
}

.suggestion-item button {
    margin-left: 1rem;
    width: auto;
    min-width: 60px;
    max-width: 80px;
    padding: 0.5rem 0.75rem;
    flex: 0 0 auto;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar,
.sidebar::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #555;
}