* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0px;
}

.container {
    width: 100%;
    max-width: 800px;
    height: 90vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 25px 30px;
    text-align: center;
}

.header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.header p {
    opacity: 0.9;
    font-size: 1rem;
}

/* Configuration Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
    color: #1f2937;
    margin-bottom: 15px;
    text-align: center;
}

.modal-content p {
    color: #6b7280;
    margin-bottom: 20px;
    text-align: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #374151;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: #4f46e5;
}

/* Custom Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    user-select: none;
}

.checkbox-label input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 0;
    height: 0;
}

.checkmark {
    height: 20px;
    width: 20px;
    background-color: #eee;
    border-radius: 4px;
    margin-right: 12px;
    position: relative;
    border: 2px solid #d1d5db;
    transition: all 0.2s;
}

.checkbox-label:hover input ~ .checkmark {
    background-color: #ccc;
}

.checkbox-label input:checked ~ .checkmark {
    background-color: #4f46e5;
    border-color: #4f46e5;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-label input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-label .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

#save-config {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#save-config:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 70, 229, 0.3);
}

.instructions {
    margin-top: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 4px solid #4f46e5;
}

.instructions p {
    font-size: 0.9rem;
    color: #6b7280;
    text-align: left;
    margin: 0;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 80%;
    padding: 15px 20px;
    border-radius: 18px;
    animation: fadeIn 0.3s ease-out;
    position: relative;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

.assistant-message {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 5px;
}

.message-content {
    line-height: 1.5;
    word-wrap: break-word;
}

.message-timestamp {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 8px;
    text-align: right;
}

.input-area {
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#message-input {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    resize: none;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
    max-height: 150px;
}

#message-input:focus {
    border-color: #4f46e5;
}

#message-input:disabled {
    background: #f9fafb;
    cursor: not-allowed;
}

#send-button {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 15px 30px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

#send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 70, 229, 0.3);
}

#send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 768px) {
    .input-container {
        gap: 8px; /* Smaller gap on mobile */
    }
    
    #message-input {
        padding: 12px 16px; /* Slightly smaller padding on mobile */
        flex: 1 1 auto; /* Allow flexible sizing */
    }
    
    #send-button {
        flex-shrink: 0; /* Prevent button from shrinking */
        min-width: 80px; /* Fixed width for send button on mobile */
        padding: 12px 16px;
    }
}



.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 0 5px;
    color: #6b7280;
    font-size: 0.9rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #6b7280;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Citations styling */
.citations {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #d1d5db;
}

.citation-item {
    background: #fffbeb;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
    font-size: 0.9rem;
}

.citation-title {
    font-weight: 600;
    color: #92400e;
    margin-bottom: 5px;
}

.citation-pages {
    color: #b45309;
    font-size: 0.85rem;
}

.error-message {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
}

@media (max-width: 768px) {
    .container {
        height: 100vh;
        border-radius: 0;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .chat-container {
        padding: 15px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .modal-content {
        padding: 20px;
        margin: 20px;
    }
}