/* Legal QA - iilaw.ru style */
:root {
    --radius: 0.625rem;
    --background: 240 20% 4%;
    --foreground: 210 40% 98%;
    --card: 240 20% 6%;
    --card-foreground: 210 40% 98%;
    --popover: 240 20% 6%;
    --popover-foreground: 210 40% 98%;
    --primary: 239 84% 67%;
    --primary-foreground: 0 0% 100%;
    --secondary: 240 20% 12%;
    --secondary-foreground: 210 40% 98%;
    --muted: 240 20% 12%;
    --muted-foreground: 215 20% 65%;
    --accent: 263 70% 66%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 84% 60%;
    --destructive-foreground: 0 0% 100%;
    --border: 240 15% 18%;
    --input: 240 15% 18%;
    --ring: 239 84% 67%;
}

* {
    border-color: hsl(var(--border));
}

body {
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    margin: 0;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #08080c;
}
::-webkit-scrollbar-thumb {
    background: #272735;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #6467f2;
}

/* Utility classes */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 40px 0 30px;
    border-bottom: 1px solid hsl(var(--border));
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--accent)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

header p {
    color: hsl(var(--muted-foreground));
    font-size: 1.1rem;
}

.nav-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

.nav-links a {
    color: hsl(var(--primary));
    text-decoration: none;
    padding: 8px 20px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--card));
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.nav-links a:hover {
    background: hsl(var(--secondary));
    border-color: hsl(var(--primary));
}

.nav-links a.active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}

/* Panels */
.panel {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 30px;
}

.panel h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: hsl(var(--foreground));
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, hsl(var(--card)), hsl(var(--secondary)));
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    text-align: center;
}

.stat-card .value {
    font-size: 2.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--accent)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .label {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin-top: 8px;
}

/* Upload area */
.upload-area {
    border: 2px dashed hsl(var(--border));
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: hsl(var(--card));
}

.upload-area:hover,
.upload-area.dragover {
    border-color: hsl(var(--primary));
    background: hsl(var(--secondary));
}

.upload-area i {
    font-size: 3rem;
    display: block;
    margin-bottom: 15px;
}

.upload-area input {
    display: none;
}

/* Form elements */
.form-group {
    margin: 20px 0;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: hsl(var(--input));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--accent)));
    color: hsl(var(--primary-foreground));
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px hsl(var(--primary) / 0.3);
}

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

.btn.secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.btn.secondary:hover {
    background: hsl(var(--muted));
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    color: hsl(var(--muted-foreground));
    font-size: 0.9rem;
}

.checkbox-label input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: hsl(var(--primary));
}

/* Auto detect info */
.auto-detect-info {
    background: hsl(var(--primary) / 0.1);
    border: 1px solid hsl(var(--primary) / 0.3);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
}

.auto-detect-info strong {
    color: hsl(var(--primary));
}

/* Progress bar */
.progress-bar {
    height: 4px;
    background: hsl(var(--muted));
    border-radius: 2px;
    margin-top: 15px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--accent)));
    transition: width 0.3s;
}

/* Documents list */
.documents-list {
    margin-top: 20px;
    max-height: 500px;
    overflow-y: auto;
}

.document-item {
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s;
}

.document-item:hover {
    border-color: hsl(var(--primary) / 0.5);
}

.document-item .header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.document-item .name {
    font-weight: 600;
    color: hsl(var(--foreground));
    word-break: break-word;
    font-size: 0.95rem;
}

.document-item .meta {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.document-item .meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.document-item .meta-item .label {
    color: hsl(var(--muted-foreground) / 0.7);
    font-size: 0.75rem;
}

.document-item .badge {
    display: inline-block;
    padding: 3px 10px;
    background: hsl(var(--primary) / 0.2);
    color: hsl(var(--primary));
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 10px;
}

/* Document type badges - different colors */
.document-item .badge[data-type="federal_law"] {
    background: hsl(239 84% 67% / 0.2);
    color: hsl(239 84% 67%);
    border: 1px solid hsl(239 84% 67% / 0.3);
}

.document-item .badge[data-type="regional_law"] {
    background: hsl(263 70% 66% / 0.2);
    color: hsl(263 70% 66%);
    border: 1px solid hsl(263 70% 66% / 0.3);
}

.document-item .badge[data-type="gost"] {
    background: hsl(142 76% 36% / 0.2);
    color: hsl(142 76% 36%);
    border: 1px solid hsl(142 76% 36% / 0.3);
}

.document-item .badge[data-type="decree"] {
    background: hsl(38 92% 66% / 0.2);
    color: hsl(38 92% 66%);
    border: 1px solid hsl(38 92% 66% / 0.3);
}

.document-item .badge[data-type="resolution"] {
    background: hsl(280 65% 60% / 0.2);
    color: hsl(280 65% 60%);
    border: 1px solid hsl(280 65% 60% / 0.3);
}

.document-item .badge[data-type="code"] {
    background: hsl(346 84% 60% / 0.2);
    color: hsl(346 84% 60%);
    border: 1px solid hsl(346 84% 60% / 0.3);
}

.document-item .badge[data-type="order"] {
    background: hsl(199 89% 48% / 0.2);
    color: hsl(199 89% 48%);
    border: 1px solid hsl(199 89% 48% / 0.3);
}

.document-item .badge[data-type="other"] {
    background: hsl(215 20% 65% / 0.2);
    color: hsl(215 20% 65%);
    border: 1px solid hsl(215 20% 65% / 0.3);
}

.document-item .delete-btn {
    background: hsl(var(--destructive) / 0.2);
    color: hsl(var(--destructive));
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.document-item .delete-btn:hover {
    background: hsl(var(--destructive) / 0.3);
}

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

.document-item .edit-btn {
    background: hsl(var(--primary) / 0.15);
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--primary) / 0.3);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.document-item .edit-btn:hover {
    background: hsl(var(--primary) / 0.25);
    border-color: hsl(var(--primary));
}

/* Sort buttons */
.sort-controls .sort-btn {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.sort-controls .sort-btn:hover {
    background: hsl(var(--muted));
    border-color: hsl(var(--ring));
}

.sort-controls .sort-btn.active {
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--accent)));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--ring));
}

/* Filter checkboxes */
.filter-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.filter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: hsl(var(--primary));
}

.filter-checkbox span {
    font-size: 0.85rem;
    color: hsl(var(--foreground));
    font-weight: 500;
}

/* Filter checkbox colors by type */
.filter-checkbox input[value="federal_law"] {
    accent-color: hsl(239 84% 67%);
}

.filter-checkbox input[value="regional_law"] {
    accent-color: hsl(263 70% 66%);
}

.filter-checkbox input[value="gost"] {
    accent-color: hsl(142 76% 36%);
}

.filter-checkbox input[value="decree"] {
    accent-color: hsl(38 92% 66%);
}

.filter-checkbox input[value="resolution"] {
    accent-color: hsl(280 65% 60%);
}

.filter-checkbox input[value="code"] {
    accent-color: hsl(346 84% 60%);
}

.filter-checkbox input[value="order"] {
    accent-color: hsl(199 89% 48%);
}

.filter-checkbox input[value="other"] {
    accent-color: hsl(215 20% 65%);
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 650px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    margin-bottom: 20px;
}

.message {
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: var(--radius);
    max-width: 85%;
    line-height: 1.6;
}

.message.user {
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--accent)));
    color: hsl(var(--primary-foreground));
    margin-left: auto;
}

.message.assistant {
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
}

.message.assistant strong {
    color: hsl(var(--accent));
}

.message .sources {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid hsl(var(--border));
    font-size: 0.85rem;
}

.message .sources h4 {
    color: hsl(var(--primary));
    margin-bottom: 10px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.source-item {
    background: hsl(var(--card));
    padding: 12px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    border-left: 3px solid hsl(var(--accent));
}

.source-item .citation {
    color: hsl(var(--accent));
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.85rem;
}

.source-item .relevance {
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

.source-item .preview {
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
    margin-top: 5px;
    line-height: 1.4;
}

/* Chat input */
.chat-input-container {
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    background: hsl(var(--input));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 14px 18px;
    color: hsl(var(--foreground));
    font-size: 0.95rem;
    resize: none;
    font-family: inherit;
    min-height: 50px;
    max-height: 150px;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: hsl(var(--ring));
}

.send-btn {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Options row */
.options-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: center;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: hsl(var(--muted-foreground));
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.3;
    display: block;
}

/* History */
.history-panel {
    margin-top: 20px;
}

.history-item {
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: hsl(var(--muted));
    border-color: hsl(var(--primary) / 0.3);
    transform: translateX(4px);
}

.history-item .question {
    color: hsl(var(--primary));
    font-size: 0.9rem;
    margin-bottom: 5px;
    font-weight: 500;
}

.history-item .answer-preview {
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
    line-height: 1.4;
}

.history-item .date {
    color: hsl(var(--muted-foreground) / 0.7);
    font-size: 0.75rem;
    margin-top: 8px;
}

/* Loading */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid hsl(var(--muted));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-content {
    text-align: center;
    padding: 40px;
    background: hsl(var(--card));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

.loading-content .spinner {
    width: 50px;
    height: 50px;
    border: 3px solid hsl(var(--muted));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

/* Responsive */
.main-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
}

@media (max-width: 900px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .stats {
        grid-template-columns: 1fr;
    }
}

/* Gradient text effect */
.gradient-text {
    background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--accent)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Glass effect */
.glass {
    background: hsl(var(--card) / 0.8);
    backdrop-filter: blur(12px);
}
