/**
 * Cursor-Style Chat Interface
 * Dark theme chat interface inspired by Cursor IDE
 */

/* Dark Theme Variables */
:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252525;
    --bg-tertiary: #2d2d2d;
    --bg-input: #3c3c3c;
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;
    --border-color: #404040;
    --border-hover: #555555;
    --accent-primary: #007acc;
    --accent-secondary: #4fc3f7;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    --shadow-heavy: rgba(0, 0, 0, 0.7);
}

/* Main Chat Container */
.cursor-chat-container {
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--shadow-heavy);
    height: 100vh;
    max-height: 800px;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Chat Header - Enhanced */
.cursor-chat-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-title {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.chat-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin: 0;
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Messages Area */
.cursor-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-primary);
    scroll-behavior: smooth;
}

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

.cursor-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

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

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

/* Message Styles */
.cursor-message {
    margin-bottom: 24px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.cursor-message.user {
    display: flex;
    justify-content: flex-end;
}

.cursor-message.bot {
    display: flex;
    justify-content: flex-start;
}

/* User Message */
.user-message-content {
    background: var(--accent-primary);
    color: white;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    max-width: 70%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px var(--shadow-light);
}

/* Bot Message */
.bot-message-content {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: 18px 18px 18px 4px;
    max-width: 85%;
    word-wrap: break-word;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow-light);
    position: relative;
}

.bot-message-content::before {
    content: '';
    position: absolute;
    top: 12px;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid var(--bg-secondary);
}

/* Bot Avatar */
.bot-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
    animation: botBounce 2s ease-in-out infinite;
}

@keyframes botBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

/* Step Display Container */
.cursor-step-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 16px 0;
    overflow: hidden;
    box-shadow: 0 4px 16px var(--shadow-medium);
}

.step-header {
    background: var(--bg-secondary);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.step-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.step-counter {
    color: var(--text-muted);
    font-size: 14px;
    background: var(--bg-input);
    padding: 4px 8px;
    border-radius: 12px;
}

.step-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.step-toggle:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.step-toggle.expanded {
    transform: rotate(180deg);
}

/* Step Items */
.step-items {
    padding: 16px 20px;
}

.step-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.step-item:last-child {
    border-bottom: none;
}

.step-item:hover {
    background: var(--bg-secondary);
    margin: 0 -20px;
    padding: 12px 20px;
    border-radius: 8px;
}

.step-item.completed {
    opacity: 0.8;
}

.step-item.current {
    background: rgba(0, 122, 204, 0.1);
    border-left: 3px solid var(--accent-primary);
    margin: 0 -20px;
    padding: 12px 20px;
}

.step-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    margin-top: 2px;
}

.step-icon.pending {
    background: var(--bg-input);
    color: var(--text-muted);
}

.step-icon.current {
    background: var(--accent-primary);
    color: white;
    animation: stepPulse 1.5s ease-in-out infinite;
}

.step-icon.completed {
    background: var(--success-color);
    color: white;
}

.step-icon.failed {
    background: var(--error-color);
    color: white;
}

@keyframes stepPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.step-content {
    flex: 1;
}

.step-text {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.step-description {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.4;
}

/* Progress Bar */
.step-progress {
    margin: 16px 0;
    padding: 0 20px;
}

.progress-bar-container {
    background: var(--bg-input);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 3px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: progressShimmer 2s ease-in-out infinite;
}

@keyframes progressShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Chat Input - Modern Gemini Style */
.cursor-chat-input-container {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 24px 24px 20px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    position: relative;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    padding: 12px 20px;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    min-height: 56px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.15), 0 4px 12px rgba(0, 0, 0, 0.15);
    background: var(--bg-tertiary);
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.chat-input-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.chat-input-action-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.chat-input-action-btn.active {
    background: var(--accent-primary);
    color: white;
}

.cursor-chat-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 200px;
    padding: 4px 0;
    width: 100%;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.cursor-chat-input::placeholder {
    color: var(--text-muted);
    font-size: 15px;
}

.send-button {
    background: var(--accent-primary);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 122, 204, 0.3);
}

.send-button:hover {
    background: var(--accent-secondary);
    transform: scale(1.08);
    box-shadow: 0 4px 8px rgba(0, 122, 204, 0.4);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Tools Dropdown */
.tools-dropdown {
    position: relative;
}

.tools-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tools-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.tools-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.tools-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 220px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.tools-dropdown.active .tools-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tools-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tools-dropdown-item:hover {
    background: var(--bg-input);
}

.tools-dropdown-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

/* Model Selector */
.model-selector {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.model-selector:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.model-selector-icon {
    font-size: 10px;
    opacity: 0.7;
}

/* Recording State */
.chat-input-action-btn.recording {
    animation: pulseRecording 1.5s ease-in-out infinite;
    color: #f44336 !important;
}

@keyframes pulseRecording {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Responsive improvements for chat input */
@media (max-width: 768px) {
    .chat-input-wrapper {
        flex-wrap: wrap;
        gap: 6px;
        padding: 10px 16px;
        min-height: 48px;
    }
    
    .chat-input-actions {
        gap: 6px;
    }
    
    .tools-btn span {
        display: none;
    }
    
    .model-selector {
        font-size: 11px;
        padding: 5px 10px;
    }
    
    .cursor-chat-input {
        font-size: 14px;
    }
    
    .send-button {
        width: 36px;
        height: 36px;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: 18px 18px 18px 4px;
    max-width: 85%;
    margin-bottom: 24px;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingDot 1.4s ease-in-out infinite;
}

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

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

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-8px);
    }
}

/* File Display */
.file-display {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.file-icon {
    color: var(--accent-primary);
}

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

.file-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.file-action:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Status Bar */
.status-bar {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-icon {
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cursor-chat-container {
        height: 100vh;
        border-radius: 0;
    }
    
    .cursor-chat-header {
        padding: 12px 16px;
    }
    
    .cursor-chat-messages {
        padding: 16px;
    }
    
    .cursor-chat-input-container {
        padding: 12px 16px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .chat-input-wrapper {
        width: 100%;
        box-sizing: border-box;
    }
    
    .cursor-chat-input {
        width: 100%;
        box-sizing: border-box;
    }
    
    .user-message-content,
    .bot-message-content {
        max-width: 90%;
    }
    
    .step-header {
        padding: 12px 16px;
    }
    
    .step-items {
        padding: 12px 16px;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* Loading States */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success/Error States */
.message-success {
    border-left: 4px solid var(--success-color);
}

.message-error {
    border-left: 4px solid var(--error-color);
}

.message-warning {
    border-left: 4px solid var(--warning-color);
}

/* Tooltip */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}
