:root {
    --bg-color: #f7fafd;
    --container-bg: #fff;
    --header-bg: #1976d2;
    --text-color: #222;
    --border-color: #e3e7ef;
    --input-bg: #fff;
    --user-bubble-bg: #1976d2;
    --user-bubble-color: #fff;
    --ai-bubble-bg: #fff;
    --ai-bubble-color: #222;
    --modal-bg: rgba(0, 0, 0, 0.5);
    --modal-content-bg: #fff;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --container-bg: #2d2d2d;
    --header-bg: #1976d2;
    --text-color: #e0e0e0;
    --border-color: #404040;
    --input-bg: #404040;
    --user-bubble-bg: #1976d2;
    --user-bubble-color: #fff;
    --ai-bubble-bg: #404040;
    --ai-bubble-color: #e0e0e0;
    --modal-bg: rgba(0, 0, 0, 0.7);
    --modal-content-bg: #2d2d2d;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    height: 100vh;
    width: 100vw;
    background: var(--bg-color);
    transition: background-color 0.3s ease;
}

.chat-container {
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    max-width: none;
    max-height: none;
    box-shadow: none;
    border: none;
    display: flex;
    flex-direction: column;
    background: var(--container-bg);
    transition: background-color 0.3s ease;
}

.chat-header {
    background: var(--header-bg);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.3rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
}

.chat-icon {
    font-size: 1.6rem;
    margin-right: 10px;
}

.chat-title {
    font-size: 1.2rem;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-btn, .theme-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.control-btn:hover, .theme-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.control-icon, .theme-icon {
    font-size: 1.2rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--modal-content-bg);
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: var(--border-color);
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    padding: 24px;
    max-height: 400px;
    overflow-y: auto;
}

.avatar-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: background-color 0.2s;
    border: 2px solid transparent;
}

.avatar-option:hover {
    background-color: var(--border-color);
}

.avatar-option.selected {
    border-color: var(--user-bubble-bg);
    background-color: rgba(25, 118, 210, 0.1);
}

.avatar-option img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 5px;
}

.avatar-option span {
    font-size: 0.8rem;
    color: var(--text-color);
    text-align: center;
}

.chat-body {
    flex: 1;
    padding: 24px 16px 16px 16px;
    overflow-y: auto;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    gap: 18px;
    transition: background-color 0.3s ease;
}

.chat-row {
    display: flex;
    align-items: flex-end;
    margin-bottom: 2px;
}

.chat-row.ai {
    flex-direction: row;
    align-items: flex-start;
}

.chat-row.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    margin: 0 10px 0 0;
    object-fit: cover;
    border: 2px solid var(--container-bg);
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.08);
}

.chat-row.user .avatar {
    display: none;
}

.chat-bubble {
    max-width: 70%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.04);
    margin-bottom: 2px;
    position: relative;
    word-break: break-word;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.ai-bubble {
    background: var(--ai-bubble-bg);
    color: var(--ai-bubble-color);
    border-top-left-radius: 0;
    border: 1px solid var(--border-color);
}

.user-bubble {
    background: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    border-top-right-radius: 0;
    margin-left: auto;
    border: 1px solid var(--user-bubble-bg);
}

.chat-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.chat-action-btn {
    background: var(--ai-bubble-bg);
    color: var(--user-bubble-bg);
    border: 1.5px solid var(--user-bubble-bg);
    border-radius: 22px;
    padding: 7px 18px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.chat-action-btn:hover {
    background: var(--user-bubble-bg);
    color: var(--user-bubble-color);
}

.chat-input-area {
    display: flex;
    padding: 16px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    gap: 10px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.upload-btn {
    background: var(--ai-bubble-bg);
    color: var(--text-color);
    border: 1.5px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.upload-btn:hover {
    background: var(--border-color);
    border-color: var(--user-bubble-bg);
}

.upload-icon {
    font-size: 1.2rem;
}

#userInput {
    flex: 1;
    padding: 10px 14px;
    border-radius: 22px;
    border: 1.5px solid var(--border-color);
    font-size: 1rem;
    outline: none;
    background: var(--input-bg);
    color: var(--text-color);
    transition: border 0.2s, background-color 0.3s ease, color 0.3s ease;
}

#userInput:focus {
    border: 1.5px solid var(--user-bubble-bg);
}

#userInput::placeholder {
    color: #888;
}

#sendBtn {
    background: var(--user-bubble-bg);
    color: var(--user-bubble-color);
    border: none;
    border-radius: 22px;
    padding: 10px 22px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

#sendBtn:hover {
    background: #1251a3;
}

.chat-subtext {
    display: block;
    margin-top: 4px;
    color: #888;
    font-size: 0.98rem;
}

.loading-dots {
    color: var(--text-color);
}

/* File upload related styles */
.file-message {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(25, 118, 210, 0.1);
    border: 1px solid rgba(25, 118, 210, 0.3);
    border-radius: 8px;
    margin-bottom: 8px;
}

.file-icon {
    font-size: 1.5rem;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
}

.file-size {
    font-size: 0.8rem;
    color: #888;
}

.upload-progress {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.upload-progress-bar {
    height: 100%;
    background: var(--user-bubble-bg);
    width: 0%;
    transition: width 0.3s ease;
}

.upload-status {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-top: 4px;
}

.upload-error {
    color: #d32f2f;
}

.upload-success {
    color: #2e7d32;
}
