/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --bg-color: #FFFFFF;
    --bg-secondary: #F7F9FC;
    --text-color: #262730;
    --text-secondary: #6B7280;
    --border-color: #E5E7EB;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --error-color: #EF4444;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-color);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg-color);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon {
    font-size: 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--bg-color);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.help-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

/* Stage Indicator */
.stage-indicator {
    margin-bottom: 1rem;
}

.stage {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.stage.active {
    background: var(--primary-color);
    color: white;
}

.stage-icon {
    font-size: 1.25rem;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    position: relative;
}

/* Instructions Panel */
.instructions-panel {
    background: #FEF3C7;
    border-left: 4px solid var(--warning-color);
    padding: 1.5rem;
    margin: 1rem;
    border-radius: 0.5rem;
    position: relative;
}

.instructions-panel .close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s;
}

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

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

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

.message.ai .message-avatar {
    background: var(--primary-color);
}

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

.message-content {
    flex: 1;
    max-width: 70%;
}

.message.user .message-content {
    text-align: right;
}

.message-bubble {
    display: inline-block;
    padding: 1rem 1.25rem;
    border-radius: 1rem;
    margin-bottom: 0.5rem;
}

.message.ai .message-bubble {
    background: var(--bg-secondary);
    border-bottom-left-radius: 0.25rem;
}

.message.user .message-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 0 0.5rem;
}

/* Input Container */
.input-container {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    background: var(--bg-color);
}

.input-container textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s;
}

.input-container textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Buttons */
button {
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
}

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

.btn-primary:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-color);
    padding: 0.75rem 1.5rem;
    width: 100%;
    margin-bottom: 0.5rem;
    text-align: left;
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-icon {
    background: transparent;
    font-size: 1.25rem;
    padding: 0.5rem;
    border-radius: 50%;
}

.btn-icon:hover {
    background: var(--bg-secondary);
}

.close-btn {
    background: transparent;
    font-size: 1.5rem;
    padding: 0.25rem 0.5rem;
    color: var(--text-secondary);
}

.close-btn:hover {
    color: var(--text-color);
}

/* Form Elements */
textarea,
input[type="text"],
input[type="password"],
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.875rem;
}

textarea:focus,
input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-group small a {
    color: var(--primary-color);
    text-decoration: none;
}

/* 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.show {
    display: flex;
}

.modal-content {
    background: var(--bg-color);
    border-radius: 1rem;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 999;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--bg-secondary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .message-content {
        max-width: 85%;
    }

    .logo h1 {
        font-size: 1.25rem;
    }
}

/* Markdown Formatting in Messages */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.message-bubble ul,
.message-bubble ol {
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.message-bubble p {
    margin-bottom: 0.5rem;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
}

.message-bubble blockquote {
    border-left: 3px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    opacity: 0.9;
}

/* Alert Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.badge-success {
    background: var(--success-color);
    color: white;
}

.badge-warning {
    background: var(--warning-color);
    color: white;
}

.badge-error {
    background: var(--error-color);
    color: white;
}
