:root {
    /* Light Theme Colors */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-hover: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #f4f5f6;
    --border-color: #e2e8f0;
    --message-user-bg: #6366f1;
    --message-user-text: #ffffff;
    --message-bot-bg: #f1f5f9;
    --message-bot-text: #1e293b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --message-user-bg: #6366f1;
    --message-user-text: #ffffff;
    --message-bot-bg: #1e293b;
    --message-bot-text: #f1f5f9;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-primary);
}

.chat-container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    max-height: 800px;
    background: var(--background);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
}

/* Header */
.chat-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.logo-text p {
    font-size: 13px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    color: var(--text-primary);
}

.btn-icon:hover {
    background: var(--surface-hover);
    transform: translateY(-1px);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--surface);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.welcome-message h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.welcome-message p {
    font-size: 15px;
    line-height: 1.6;
    max-width: 500px;
    margin: 0 auto 32px;
}

.suggestions-container {
    margin-top: 32px;
}

.suggestions-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.suggestion-chip {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.suggestion-chip:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
    max-width: 85%;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--message-user-bg);
}

.message.bot .message-avatar {
    background: var(--surface);
    border: 1px solid var(--border-color);
}

.message-content {
    background: var(--message-bot-bg);
    color: var(--message-bot-text);
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--message-user-bg);
    color: var(--message-user-text);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

/* Typing Indicator */
.typing-indicator {
    padding: 0 24px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

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

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.typing-text {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Input Area */
.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    background: var(--surface);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-wrapper textarea {
    width: 100%;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-primary);
    resize: none;
    min-height: 50px;
    max-height: 150px;
    transition: all 0.2s ease;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-send {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--background);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    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 h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.setting-item input[type="text"],
.setting-item select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--background);
    color: var(--text-primary);
}

.setting-item input[type="text"]:focus,
.setting-item select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.setting-item input[type="checkbox"] {
    margin-right: 8px;
}

.setting-item input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--background);
    color: var(--text-primary);
}

.setting-item input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.setting-hint {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-style: italic;
}

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .chat-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .message {
        max-width: 90%;
    }

    .logo-text h1 {
        font-size: 18px;
    }

    .logo-text p {
        font-size: 12px;
    }
}

/* Error Message */
.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin: 8px 0;
    border-left: 4px solid #dc2626;
    box-shadow: var(--shadow-sm);
    line-height: 1.5;
    word-wrap: break-word;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.error-message::before {
    content: "⚠️";
    font-size: 18px;
    flex-shrink: 0;
}

[data-theme="dark"] .error-message {
    background: #7f1d1d;
    color: #fecaca;
    border-left-color: #ef4444;
}

/* Settings Section */
.settings-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.child-info-item {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.child-info-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.child-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.child-fields .setting-item {
    margin-bottom: 0;
}

.child-fields .setting-item label {
    font-size: 13px;
    margin-bottom: 6px;
}

.child-fields .setting-item input,
.child-fields .setting-item select {
    font-size: 13px;
    padding: 8px 10px;
}

