/* =============================================================================
   SENTINO AI - CHAT PAGE
   Premium Zapier-inspired chat interface
   ============================================================================= */

/* =============================================================================
   PAGE LAYOUT
   ============================================================================= */

.chat-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
}

.chat-page h1 {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 400;
    color: var(--fg);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.view-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* =============================================================================
   CHAT CONTAINER - TWO COLUMN LAYOUT
   ============================================================================= */

.chat-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 220px);
    min-height: 500px;
}

/* =============================================================================
   DOCUMENT PANEL (SIDEBAR)
   ============================================================================= */

.document-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(32, 21, 21, 0.04);
}

.document-panel h2 {
    font-family: var(--font-primary);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Upload button */
.upload-btn-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.upload-btn-wrapper input[type=file] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Progress bar */
.progress {
    height: 4px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 0.75rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
}

/* Document list */
.document-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.document-item {
    background: var(--background-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-item:hover {
    border-color: var(--border-hover);
    background: var(--surface-hover);
}

.document-item.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.document-item-content {
    display: flex;
    align-items: center;
    flex: 1;
    overflow: hidden;
}

.document-item-content i {
    color: var(--primary-color);
    margin-right: 0.625rem;
    font-size: 1rem;
    flex-shrink: 0;
}

.document-name {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-actions {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.document-item:hover .document-actions {
    opacity: 1;
}

.delete-document {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.delete-document:hover {
    color: var(--error);
    background: var(--error-light);
}

/* Empty state */
.empty-documents {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1rem;
}

.empty-documents i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-documents p {
    font-size: 0.875rem;
    margin: 0.25rem 0;
}

/* =============================================================================
   CHAT CONTENT AREA
   ============================================================================= */

.chat-content {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(32, 21, 21, 0.04);
}

/* Chat header */
.chat-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-color);
}

.document-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    background: var(--background-color);
}

.no-document-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.no-document-message i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

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

.no-document-message p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* =============================================================================
   MESSAGES - Claude Style
   ============================================================================= */

.message {
    margin-bottom: 1.25rem;
    max-width: 85%;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* User messages - right aligned, orange gradient */
.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #FD7E14 0%, #FF922B 100%);
    color: white;
    border-radius: 16px 16px 4px 16px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 8px rgba(253, 126, 20, 0.15);
}

/* Assistant messages - left aligned, clean style */
.message.assistant {
    align-self: flex-start;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 16px 16px 16px 4px;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(32, 21, 21, 0.04);
}

.message.assistant a {
    color: var(--primary-color);
    text-decoration: none;
}

.message.assistant a:hover {
    text-decoration: underline;
}

.message.assistant code {
    background: var(--background-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.875em;
}

.message.assistant pre {
    background: var(--background-secondary);
    padding: 0.875rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 0.625rem 0;
    border: 1px solid var(--border-color);
}

.message.assistant pre code {
    background: none;
    padding: 0;
}

/* System messages */
.message.system {
    align-self: center;
    background: var(--background-secondary);
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
    max-width: 90%;
}

/* =============================================================================
   CHAT INPUT
   ============================================================================= */

.chat-input {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
}

.chat-input form {
    margin: 0;
}

.chat-input .input-container {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.chat-input textarea {
    flex: 1;
    border: 1.5px solid var(--border-color);
    background: var(--background-color);
    color: var(--text-primary);
    border-radius: 12px;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    padding: 0.875rem 1.125rem;
    font-family: var(--font-primary);
    font-size: 0.9375rem;
    line-height: 1.5;
    transition: var(--transition-normal);
}

.chat-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(253, 126, 20, 0.08);
    background: var(--surface-color);
}

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

.chat-input button {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(253, 126, 20, 0.2);
}

.chat-input button:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(253, 126, 20, 0.3);
}

.chat-input button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* =============================================================================
   THINKING INDICATOR
   ============================================================================= */

.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.75rem;
}

.thinking-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: bounce 1.4s infinite ease-in-out;
}

.thinking-indicator span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes bounce {

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

    30% {
        transform: translateY(-6px);
    }
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideIn 0.2s ease;
    max-width: 320px;
    min-width: 240px;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--error);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.toast-content i {
    font-size: 1rem;
}

.toast-content i.fa-check-circle {
    color: var(--success);
}

.toast-content i.fa-exclamation-circle {
    color: var(--error);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    transition: var(--transition-fast);
}

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

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

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

/* =============================================================================
   FOOTER
   ============================================================================= */

footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    margin-top: auto;
}

.footer-left {
    display: none;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
}

.copyright {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    transition: var(--transition-fast);
}

.footer-link:hover {
    color: var(--primary-color);
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
    .chat-page {
        padding: 1rem;
    }

    .chat-page h1 {
        font-size: 1.5rem;
    }

    .chat-container {
        grid-template-columns: 1fr;
        height: calc(100vh - 180px);
    }

    .document-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        border-radius: 0;
        display: none;
    }

    .document-panel.mobile-open {
        display: flex;
    }

    .document-panel h2 {
        margin-top: 3rem;
    }

    .chat-content {
        height: 100%;
        border-radius: var(--radius-lg);
    }

    .message {
        max-width: 90%;
    }

    .footer-left {
        display: block;
    }

    .footer-right {
        margin-left: 0;
    }

    footer {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
}

/* =============================================================================
   ALERTS
   ============================================================================= */

.alert {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    background: var(--warning-light);
    color: var(--warning);
}

.alert i {
    flex-shrink: 0;
}

.alert a {
    color: inherit;
    font-weight: 500;
}