/**
 * Chat-First UI стили
 * Главный интерфейс UrAIst
 */

/* === Layout === */
.chat-body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* === Sidebar === */
.chat-sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid rgba(148, 163, 184, 0.1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.chat-sidebar.hidden {
    transform: translateX(-100%);
    position: absolute;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-new-chat {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-new-chat:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.sidebar-search {
    padding: 0.75rem 1rem;
}

.sidebar-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.8);
    color: #f8fafc;
    font-size: 0.875rem;
}

.sidebar-search input::placeholder {
    color: #64748b;
}

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.chat-item {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-item:hover {
    background: rgba(59, 130, 246, 0.1);
}

.chat-item.active {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.chat-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-preview {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.btn-logout {
    width: 100%;
    padding: 0.5rem;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: transparent;
    color: #ef4444;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* === Main Chat Area === */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    backdrop-filter: blur(10px);
}

.btn-toggle-sidebar {
    display: none;
    background: none;
    border: none;
    color: #f8fafc;
    font-size: 1.25rem;
    cursor: pointer;
}

.chat-header h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
    flex: 1;
}

.btn-full-audit {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-full-audit:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-show-audit {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-show-audit:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

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

.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    padding: 2rem;
}

.welcome-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.chat-welcome h2 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.chat-welcome p {
    color: #94a3b8;
    margin: 0 0 1.5rem;
}

.welcome-hints {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.hint {
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 999px;
    font-size: 0.85rem;
    color: #93c5fd;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 16px;
    animation: fadeIn 0.3s ease;
}

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

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
}

.message.system .spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #94a3b8;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

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

.message.system.done {
    color: #34d399;
}

.message.system.done::before {
    content: '✓ ';
}

/* Role Selector Widget */
.role-selector {
    align-self: center;
    max-width: 90%;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 16px;
    padding: 1.25rem;
    text-align: center;
}

.role-selector-title {
    font-size: 0.9rem;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.role-selector-question {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.role-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.role-button {
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.role-button:hover:not(:disabled) {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3b82f6;
}

.role-button.selected {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border-color: transparent;
}

.role-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Input Area === */
.chat-input-area {
    padding: 1rem 1.5rem;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.file-chips:empty {
    display: none;
}

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 999px;
    font-size: 0.8rem;
    color: #93c5fd;
}

.file-chip-remove {
    background: none;
    border: none;
    color: #93c5fd;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.file-chip-remove:hover {
    opacity: 1;
}

.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 16px;
    padding: 0.5rem;
}

.btn-attach {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-attach:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.chat-form textarea {
    flex: 1;
    resize: none;
    border: none;
    background: transparent;
    color: #f8fafc;
    font-size: 0.95rem;
    padding: 0.5rem;
    max-height: 120px;
    line-height: 1.4;
}

.chat-form textarea::placeholder {
    color: #64748b;
}

.chat-form textarea:focus {
    outline: none;
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

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

.btn-send:not(:disabled):hover {
    transform: scale(1.05);
}

/* === Responsive === */
@media (max-width: 768px) {
    .chat-sidebar {
        position: absolute;
        z-index: 100;
        height: 100%;
    }

    .chat-sidebar.hidden {
        transform: translateX(-100%);
    }

    .btn-toggle-sidebar {
        display: block;
    }
}

/* === Scrollbar === */
.chat-messages::-webkit-scrollbar,
.sidebar-list::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb,
.sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.sidebar-list::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}

/* === Audit Modal === */
.audit-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audit-modal.hidden {
    display: none;
}

.audit-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.audit-modal-content {
    position: relative;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

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

.audit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.audit-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.audit-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.audit-score {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
}

.audit-score.score-high {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.audit-score.score-medium {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.audit-score.score-low {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.audit-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.audit-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.audit-summary {
    padding: 1rem 1.5rem;
    color: #94a3b8;
    font-size: 0.95rem;
    line-height: 1.5;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.audit-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.audit-tab {
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.audit-tab:hover {
    color: #f8fafc;
}

.audit-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}

.audit-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.audit-empty {
    text-align: center;
    color: #94a3b8;
    padding: 2rem;
    font-size: 0.95rem;
}

/* Audit Cards */
.audit-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px;
    padding: 1rem 1.25rem;
}

.audit-card.severity-high {
    border-left: 4px solid #ef4444;
}

.audit-card.severity-medium {
    border-left: 4px solid #f59e0b;
}

.audit-card.severity-low {
    border-left: 4px solid #22c55e;
}

.audit-card.importance-critical {
    border-left: 4px solid #ef4444;
}

.audit-card.importance-recommended {
    border-left: 4px solid #f59e0b;
}

.audit-card.importance-optional {
    border-left: 4px solid #3b82f6;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.severity-badge,
.importance-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.severity-badge.severity-high,
.importance-badge.importance-critical {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.severity-badge.severity-medium,
.importance-badge.importance-recommended {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.severity-badge.severity-low,
.importance-badge.importance-optional {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.card-category,
.card-type {
    font-size: 0.8rem;
    color: #64748b;
}

.card-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #f8fafc;
}

.card-description {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: #cbd5e1;
    line-height: 1.5;
}

.card-recommendation {
    padding: 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    color: #93c5fd;
    margin-top: 0.75rem;
}

.card-fix {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    color: #86efac;
}

.card-fix pre {
    margin: 0.5rem 0 0;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: pre-wrap;
    color: #f8fafc;
}

/* Quotes */
.quotes-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.quote-item {
    border-radius: 8px;
    padding: 0.75rem;
}

.quote-item.quote-risk {
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid #ef4444;
}

.quote-item.quote-warning {
    background: rgba(245, 158, 11, 0.08);
    border-left: 3px solid #f59e0b;
}

.quote-item.quote-info {
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid #3b82f6;
}

.quote-source {
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 0.4rem;
}

.quote-text {
    margin: 0;
    font-size: 0.85rem;
    color: #cbd5e1;
    font-style: italic;
    line-height: 1.4;
}

/* Recommendations List */
.recommendations-list {
    margin: 0;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.recommendations-list li {
    font-size: 0.9rem;
    color: #cbd5e1;
    line-height: 1.5;
}

/* Scrollbar for audit body */
.audit-body::-webkit-scrollbar {
    width: 6px;
}

.audit-body::-webkit-scrollbar-track {
    background: transparent;
}

.audit-body::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 3px;
}

.audit-body::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.5);
}