/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #f8f9fc;
    --bg-grid: #e8ecf4;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #5c5c7a;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --accent-blue: #6366f1;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: all 0.2s ease;
    --bg-elevated: #f1f3f8;
    --accent-purple: #8b5cf6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    --radius-xl: 20px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-grid: #1a1a2e;
    --bg-card: #1e1e2e;
    --text-primary: #ffffff;
    --text-secondary: #e2e2e8;
    --text-muted: #9ca3af;
    --border-color: #3f3f5a;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.5);
    --bg-elevated: #252538;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
    z-index: 100;
}

.theme-toggle:hover {
    background: var(--border-color);
    transform: scale(1.05);
}

.theme-toggle .icon-sun {
    display: block;
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

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

html,
body {
    height: 100%;
}

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

/* ===== Background Grid ===== */
.background-grid {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: -1;
}

/* ===== Main Container ===== */
.container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: 1rem;
}

/* ===== Header ===== */
.header {
    text-align: center;
    max-width: 600px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logo-icon {
    color: var(--text-primary);
    opacity: 0.9;
}

.logo-text {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #1a1a2e 0%, #4a4a6a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-theme="dark"] .logo-text {
    background: linear-gradient(135deg, #ffffff 0%, #b8b8d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 480px;
    margin: 0 auto;
}

/* ===== Search Container ===== */
.search-container {
    width: 100%;
    max-width: 720px;
}

.search-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-hover), 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ===== Settings Row ===== */
.settings-row {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.setting-group {
    flex: 1;
    min-width: 200px;
}

.setting-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.api-key-input,
.model-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.api-key-input:focus,
.model-select:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.api-key-input::placeholder {
    color: var(--text-muted);
}

.model-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.model-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ===== Search Input ===== */
.search-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.search-icon {
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.prompt-indicator {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-weight: 600;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: transparent;
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* ===== Search Controls ===== */
.search-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Model Selector */
.model-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: var(--transition);
}

.model-selector:hover {
    background: var(--bg-grid);
    border-color: var(--text-muted);
}

.model-icon {
    font-size: 0.75rem;
}

.model-name {
    font-weight: 500;
}

.chevron {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.model-selector:hover .chevron {
    transform: translateY(1px);
}

/* Icon Button */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-grid);
    border-color: var(--text-muted);
    color: var(--text-primary);
}

/* Response Toggle */
.response-toggle {
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-secondary);
    transition: var(--transition);
}

.response-toggle:hover {
    background: var(--bg-grid);
    border-color: var(--text-muted);
}

.response-toggle.active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: white;
}

/* Submit Button */
.submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--text-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: white;
    transition: var(--transition);
}

.submit-btn:hover {
    opacity: 0.85;
    transform: translateX(2px);
}

.submit-btn:active {
    transform: translateX(0);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem;
    }

    .logo-text {
        font-size: 1.75rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .search-box {
        padding: 0.875rem 1rem;
    }

    .search-controls {
        flex-wrap: wrap;
    }

    .controls-left {
        order: 2;
        width: 100%;
        justify-content: flex-start;
        margin-top: 0.5rem;
    }

    .controls-right {
        order: 1;
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 480px) {
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }

    .model-selector .model-name {
        display: none;
    }
}

/* ===== Preview Container ===== */
.preview-container {
    margin-top: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.preview-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.preview-title svg {
    color: var(--accent-blue);
}

.continue-btn {
    padding: 0.5rem 1rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.continue-btn:hover {
    opacity: 0.9;
    transform: translateX(2px);
}

.preview-content {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    line-height: 1.7;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.preview-content h1 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.preview-content h2 {
    font-size: 1.25rem;
    margin: 1rem 0 0.5rem;
    color: var(--text-primary);
}

.preview-content h3 {
    font-size: 1.1rem;
    margin: 0.875rem 0 0.375rem;
    color: var(--text-primary);
}

.preview-content p {
    margin-bottom: 0.75rem;
}

.preview-content ul,
.preview-content ol {
    margin: 0.5rem 0 0.75rem 1.5rem;
}

.preview-content li {
    margin-bottom: 0.25rem;
}

/* Typing cursor animation */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--accent-blue);
    margin-left: 2px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* Loading state for search box */
.search-box.loading {
    opacity: 0.7;
    pointer-events: none;
}

.search-box.loading .submit-btn {
    background: var(--accent-blue);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===== View Transitions ===== */
.view-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ===== Editor Container ===== */
.editor-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    height: 100vh;
    gap: 0;
}

/* ===== Panel Base ===== */
.chat-panel,
.document-panel {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ===== Panel Header ===== */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    min-height: 60px;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.panel-title svg {
    color: var(--accent-blue);
}

/* ===== Chat Panel ===== */
.chat-panel {
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
}

.clear-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.clear-chat-btn:hover {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

/* ===== Chat Messages ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-secondary);
}

.welcome-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border-radius: var(--radius-lg);
    color: white;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-glow);
}

.welcome-message h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-message p {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.example-commands {
    width: 100%;
}

.example-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.chip {
    padding: 0.375rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.chip:hover {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 90%;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    padding: 0 0.5rem;
}

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: fit-content;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

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

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

@keyframes typing {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

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

.settings-compact {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.setting-inline {
    flex: 1;
}

.setting-label-sm {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-sm,
.select-sm {
    width: 100%;
    padding: 0.5rem 0.625rem;
    font-size: 0.75rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.input-sm:focus,
.select-sm:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.input-sm::placeholder {
    color: var(--text-muted);
}

.select-sm {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.5rem;
}

.chat-input-box {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem;
    transition: var(--transition);
}

.chat-input-box:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.command-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text-primary);
    resize: none;
    min-height: 24px;
    max-height: 120px;
    padding: 0.25rem 0.5rem;
}

.command-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: white;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

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

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

/* ===== Document Panel ===== */
.document-panel {
    background: var(--bg-primary);
}

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

.action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    transition: var(--transition);
}

.action-btn:hover:not(:disabled) {
    background: var(--bg-card);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

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

.upload-btn:hover:not(:disabled) {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.download-btn:hover:not(:disabled) {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

/* ===== Document Wrapper ===== */
.document-wrapper {
    flex: 1;
    overflow: hidden;
    padding: 1.5rem;
}

.document-content {
    height: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

/* ===== Upload Zone ===== */
.upload-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    cursor: pointer;
    transition: var(--transition);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    margin: 1rem;
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.05);
}

.upload-zone.drag-over {
    background: rgba(99, 102, 241, 0.1);
}

.upload-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
}

.upload-icon {
    color: var(--accent-blue);
    margin-bottom: 1rem;
    opacity: 0.8;
}

.upload-zone-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.upload-zone-content p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.file-types {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-elevated);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
}

/* ===== Document Preview ===== */
.document-preview {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 2rem 3rem;
}

.document-preview.active {
    display: block;
}

.document-preview::-webkit-scrollbar {
    width: 8px;
}

.document-preview::-webkit-scrollbar-track {
    background: transparent;
}

.document-preview::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.document-preview::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Document Content Styles */
.document-preview h1,
.document-preview h2,
.document-preview h3,
.document-preview h4,
.document-preview h5,
.document-preview h6 {
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.document-preview h1 {
    font-size: 2rem;
}

.document-preview h2 {
    font-size: 1.5rem;
}

.document-preview h3 {
    font-size: 1.25rem;
}

.document-preview h4 {
    font-size: 1.1rem;
}

.document-preview p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.document-preview ul,
.document-preview ol {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.document-preview li {
    margin-bottom: 0.25rem;
}

.document-preview table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.document-preview th,
.document-preview td {
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.document-preview th {
    background: var(--bg-elevated);
    font-weight: 600;
}

.document-preview img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.document-preview a {
    color: var(--accent-blue);
    text-decoration: underline;
}

.document-preview blockquote {
    border-left: 3px solid var(--accent-blue);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-style: italic;
}

/* ===== Status Notifications ===== */
.status-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-hover);
    font-size: 0.875rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: var(--transition-smooth);
}

.status-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.status-toast.success {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.status-toast.error {
    background: var(--error-color);
    border-color: var(--error-color);
    color: white;
}

/* ===== Highlighting Animation ===== */
@keyframes highlight {

    0%,
    100% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(99, 102, 241, 0.2);
    }
}

.highlight-change {
    animation: highlight 1s ease 2;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .editor-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

/* ===== Swift Mode Styles ===== */
.swift-mode-toggle .toggle-text {
    color: var(--accent-purple);
    font-weight: 500;
}

.swift-mode-toggle .toggle-text svg {
    color: var(--warning-color);
}

.swift-execution-log {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.swift-log-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-purple);
}

.swift-log-header svg {
    color: var(--warning-color);
}

.swift-status {
    margin-left: auto;
    font-weight: 500;
    font-size: 0.7rem;
    padding: 0.125rem 0.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-full);
    color: var(--text-muted);
}

.swift-status.active {
    background: var(--accent-purple);
    color: white;
    animation: pulse 1.5s infinite;
}

.swift-status.complete {
    background: var(--success-color);
    color: white;
}

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

.swift-log-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.swift-agent-step {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    transition: var(--transition);
}

.swift-agent-step.active {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

.swift-agent-step.complete {
    border-color: var(--success-color);
    opacity: 0.8;
}

.swift-agent-step.error {
    border-color: var(--error-color);
}

.swift-agent-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.swift-agent-info {
    flex: 1;
    min-width: 0;
}

.swift-agent-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.75rem;
}

.swift-agent-model {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.swift-agent-status {
    font-size: 0.65rem;
    color: var(--text-muted);
    padding: 0.125rem 0.5rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    flex-shrink: 0;
    white-space: nowrap;
}

.swift-agent-step.active .swift-agent-status {
    background: var(--accent-purple);
    color: white;
    animation: pulse 1.5s infinite;
}

.swift-agent-step.complete .swift-agent-status {
    background: var(--success-color);
    color: white;
}

.swift-agent-step.error .swift-agent-status {
    background: var(--error-color);
    color: white;
}

.swift-log-details {
    border-top: 1px solid var(--border-color);
    padding: 0.625rem 0.875rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
    max-height: 100px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    line-height: 1.5;
    display: none;
}

.swift-log-details.active {
    display: block;
}

.swift-log-details::-webkit-scrollbar {
    width: 4px;
}

.swift-log-details::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.swift-log-entry {
    margin-bottom: 0.25rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-color);
}

.swift-log-entry.tool-call {
    border-left-color: var(--accent-blue);
}

.swift-log-entry.thinking {
    border-left-color: var(--accent-purple);
    font-style: italic;
    opacity: 0.8;
}

.swift-log-entry.edit {
    border-left-color: var(--success-color);
}

/* Swift mode spinner animation */
@keyframes swift-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.swift-spinner {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: swift-spin 0.8s linear infinite;
    margin-right: 0.25rem;
}

/* Tool call indicator */
.swift-tool-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.375rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
    color: var(--accent-blue);
    margin-left: 0.25rem;
}

/* Page selection indicator */
.swift-page-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.125rem;
    padding: 0.125rem 0.375rem;
    background: rgba(245, 158, 11, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
    color: var(--warning-color);
    font-weight: 500;
}

/* Edit preview in Swift mode */
.swift-edit-preview {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-color);
}

.swift-edit-preview-header {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.375rem;
}

.swift-edit-old {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.65rem;
    text-decoration: line-through;
    margin-bottom: 0.25rem;
}

.swift-edit-new {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 0.65rem;
}