/* Global: ensure [hidden] always works regardless of display property */
[hidden] { display: none !important; }

/* ==========================================================================
   Архивариус — app.css
   Professional dark theme for document management
   ========================================================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16213e;
    --bg-hover: #1c2940;
    --bg-input: #0d1117;
    --border: #30363d;
    --border-light: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #484f58;
    --accent-blue: #0f3460;
    --accent-blue-light: #1a5276;
    --accent-blue-bright: #58a6ff;
    --accent-red: #e94560;
    --accent-red-dim: #a93a4a;
    --accent-green: #3fb950;
    --accent-green-dim: #238636;
    --accent-yellow: #d29922;
    --accent-yellow-dim: #9e6a03;
    --accent-purple: #bc8cff;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    --transition: 150ms ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent-blue-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn 300ms ease forwards;
    max-width: 380px;
}

.toast.toast-success { border-left: 4px solid var(--accent-green); }
.toast.toast-error { border-left: 4px solid var(--accent-red); }
.toast.toast-info { border-left: 4px solid var(--accent-blue-bright); }

.toast.toast-out {
    animation: toastOut 300ms ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* --- Header --- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon { flex-shrink: 0; }

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-status {
    font-size: 10px;
    color: var(--accent-green);
    line-height: 1;
}
.header-status.disconnected { color: var(--accent-red); }

/* --- Stats Bar --- */
.stats-bar {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.stat-card {
    flex: 1;
    min-width: 120px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stat-card-recent {
    flex: 2;
    text-align: left;
}

.stat-recent {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Search Section --- */
.search-section {
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 12px;
    transition: border-color var(--transition);
}

.search-bar:focus-within {
    border-color: var(--accent-blue-bright);
}

.search-icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    padding: 10px 0;
    outline: none;
}

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

.search-semantic-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.search-semantic-toggle:hover {
    border-color: var(--accent-blue-bright);
    color: var(--accent-blue-bright);
}

.search-semantic-toggle.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue-bright);
    color: var(--accent-blue-bright);
}

.search-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-blue-bright);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.search-spinner.visible { display: block; }

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

/* --- Filters Bar --- */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-select,
.filter-date {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 7px 10px;
    outline: none;
    transition: border-color var(--transition);
    cursor: pointer;
}

.filter-select:focus,
.filter-date:focus {
    border-color: var(--accent-blue-bright);
}

.filter-select {
    padding-right: 28px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b949e' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.filter-date {
    width: 140px;
}

.filter-date::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
}

.filter-date-sep {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.filter-reset {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8rem;
    padding: 7px 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.filter-reset:hover {
    color: var(--accent-red);
    border-color: var(--accent-red-dim);
}

/* --- Upload Section --- */
.upload-section {
    padding: 16px 24px;
}

.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--accent-blue-bright);
    background: rgba(15, 52, 96, 0.15);
}

.upload-dropzone.dragover {
    background: rgba(15, 52, 96, 0.25);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 8px;
}

.upload-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.upload-link {
    color: var(--accent-blue-bright);
    cursor: pointer;
    text-decoration: underline;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.upload-progress {
    margin-top: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    height: 32px;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-blue-bright));
    width: 0%;
    transition: width 300ms ease;
    border-radius: var(--radius-md);
}

.upload-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* --- Documents Section --- */
.documents-section {
    flex: 1;
    padding: 0 24px 24px;
}

.documents-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 12px;
}

.documents-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.documents-sort {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sort-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 4px;
}

.sort-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    padding: 4px 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.sort-btn:hover {
    color: var(--text-primary);
    border-color: var(--border);
}

.sort-btn.active {
    color: var(--accent-blue-bright);
    border-color: var(--accent-blue);
    background: rgba(15, 52, 96, 0.3);
}

/* --- Documents Table --- */
.documents-table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.documents-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.documents-table thead {
    background: var(--bg-tertiary);
}

.documents-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.documents-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.documents-table tbody tr {
    cursor: pointer;
    transition: background var(--transition);
}

.documents-table tbody tr:hover {
    background: var(--bg-hover);
}

.documents-table tbody tr:last-child td {
    border-bottom: none;
}

.col-date { width: 100px; }
.col-type { width: 90px; }
.col-status { width: 110px; }
.col-org { width: 140px; }
.col-counter { width: 180px; }

/* Cell styles */
.cell-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

.cell-name {
    font-weight: 500;
    color: var(--text-primary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-counter {
    color: var(--text-secondary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Type badges */
.badge-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-type-contract { background: rgba(15, 52, 96, 0.5); color: var(--accent-blue-bright); }
.badge-type-invoice { background: rgba(188, 140, 255, 0.15); color: var(--accent-purple); }
.badge-type-letter { background: rgba(139, 148, 158, 0.2); color: var(--text-secondary); }
.badge-type-act { background: rgba(63, 185, 80, 0.15); color: var(--accent-green); }
.badge-type-statement { background: rgba(210, 153, 34, 0.15); color: var(--accent-yellow); }
.badge-type-other { background: rgba(72, 79, 88, 0.3); color: var(--text-muted); }

/* Org badges */
.badge-org {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-org-flora { background: rgba(63, 185, 80, 0.12); color: var(--accent-green); }
.badge-org-ip { background: rgba(88, 166, 255, 0.12); color: var(--accent-blue-bright); }
.badge-org-shared { background: rgba(210, 153, 34, 0.12); color: var(--accent-yellow); }
.badge-org-personal { background: rgba(188, 140, 255, 0.12); color: var(--accent-purple); }

/* Status badges */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-status-done { color: var(--accent-green); }
.badge-status-done::before { background: var(--accent-green); }

.badge-status-processing { color: var(--accent-yellow); }
.badge-status-processing::before { background: var(--accent-yellow); animation: pulse 1.5s infinite; }

.badge-status-error { color: var(--accent-red); }
.badge-status-error::before { background: var(--accent-red); }

.badge-status-pending { color: var(--text-muted); }
.badge-status-pending::before { background: var(--text-muted); }

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

/* --- Empty & Loading states --- */
.documents-empty,
.documents-loading {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.documents-empty svg,
.documents-loading svg {
    margin-bottom: 12px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-blue-bright);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 16px 0;
}

.pagination button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 6px 12px;
    cursor: pointer;
    transition: all var(--transition);
    min-width: 36px;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--accent-blue-bright);
    color: var(--accent-blue-bright);
}

.pagination button.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue-bright);
    color: var(--accent-blue-bright);
    font-weight: 600;
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.pagination .page-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 8px;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 720px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 200ms ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100% - 40px);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

/* Modal metadata grid */
.modal-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.meta-item {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.meta-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.meta-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    word-break: break-word;
}

/* Modal sections */
.modal-section {
    margin-bottom: 16px;
}

.modal-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.modal-section-toggle {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.modal-section-toggle:hover {
    color: var(--text-primary);
}

.modal-summary {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.modal-ocr {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
}

.modal-log {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-log-entry {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
}

.modal-log-entry:last-child { border-bottom: none; }

.modal-log-time {
    color: var(--text-muted);
    white-space: nowrap;
    font-family: monospace;
    font-size: 0.78rem;
}

.modal-log-msg {
    color: var(--text-secondary);
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue-light);
    color: var(--accent-blue-bright);
}

.btn-primary:hover {
    background: var(--accent-blue-light);
    text-decoration: none;
}

/* --- Search highlights --- */
mark {
    background: rgba(233, 69, 96, 0.3);
    color: var(--text-primary);
    padding: 1px 2px;
    border-radius: 2px;
}

/* --- Footer --- */
.app-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

/* --- Confidence bar --- */
.confidence-bar {
    width: 60px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
}

.confidence-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 300ms ease;
}

.confidence-high .confidence-bar-fill { background: var(--accent-green); }
.confidence-mid .confidence-bar-fill { background: var(--accent-yellow); }
.confidence-low .confidence-bar-fill { background: var(--accent-red); }

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-header { padding: 0 12px; }
    .stats-bar { padding: 12px; gap: 8px; }
    .stat-card { min-width: 90px; padding: 8px 10px; }
    .stat-number { font-size: 1.3rem; }
    .stat-card-recent { display: none; }
    .search-section { padding: 12px; }
    .search-semantic-toggle span { display: none; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filter-group { width: 100%; }
    .filter-select, .filter-date { width: 100%; }
    .upload-section { padding: 12px; }
    .upload-dropzone { padding: 24px 16px; }
    .documents-section { padding: 0 12px 16px; }
    .documents-header { flex-direction: column; gap: 8px; align-items: flex-start; }
    .col-org, .col-counter { display: none; }
    .documents-table td, .documents-table th { padding: 8px 10px; }
    .modal { margin: 16px; }
    .modal-meta { grid-template-columns: 1fr; }
    .app-footer { padding: 10px 12px; }
}

@media (max-width: 480px) {
    .logo-text { font-size: 1.05rem; }
    .stat-card { min-width: 70px; }
    .sort-label { display: none; }
    .col-status { display: none; }
}

/* ==========================================================================
   Login Screen
   ========================================================================== */

.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 9999;
}

.login-card {
    text-align: center;
    padding: 48px 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 380px;
    width: 100%;
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.login-card.login-success {
    border-color: var(--accent-green);
    box-shadow: 0 0 30px rgba(63, 185, 80, 0.15);
}

.login-logo {
    margin-bottom: 16px;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-input {
    width: 100%;
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5em;
    padding: 16px 12px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    caret-color: var(--accent-blue-bright);
}

.login-input::placeholder {
    color: var(--text-muted);
    letter-spacing: 0.3em;
    font-weight: 400;
}

.login-input:focus {
    border-color: var(--accent-blue-bright);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.login-submit {
    width: 100%;
    padding: 12px;
    background: var(--accent-blue);
    border: 1px solid var(--accent-blue-light);
    border-radius: var(--radius-md);
    color: var(--accent-blue-bright);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.login-submit:hover:not(:disabled) {
    background: var(--accent-blue-light);
}

.login-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    margin-top: 12px;
    padding: 10px 16px;
    background: rgba(233, 69, 96, 0.1);
    border: 1px solid var(--accent-red-dim);
    border-radius: var(--radius-sm);
    color: var(--accent-red);
    font-size: 0.85rem;
}

.login-hint {
    margin-top: 20px;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Shake animation for login errors */
@keyframes loginShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
    20%, 40%, 60%, 80% { transform: translateX(6px); }
}

.login-card.login-shake {
    animation: loginShake 0.5s ease;
}

/* Header logout button */
.header-logout {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.header-logout:hover {
    color: var(--accent-red);
    border-color: var(--accent-red-dim);
}

/* Responsive login */
@media (max-width: 480px) {
    .login-card {
        padding: 32px 24px;
        margin: 0 16px;
    }
    .login-input {
        font-size: 1.6rem;
        letter-spacing: 0.35em;
        padding: 14px 8px;
    }
}

/* Fix: hidden attribute must override display:flex on login-container */
.login-container[hidden] {
    display: none !important;
}

/* Fix: hidden attribute must work on modal overlay */
.modal-overlay[hidden] {
    display: none !important;
}

/* Preview button in modal footer */
.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Archivarius v2.0: Tags, Related Documents ─────────────────── */

.tag-badge {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 12px;
    font-size: 0.78rem;
    background: rgba(233, 69, 96, 0.12);
    color: var(--accent);
    border: 1px solid rgba(233, 69, 96, 0.25);
}

.modal-related {
    margin-top: 8px;
}

.related-doc-item {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    margin-bottom: 6px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.related-doc-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.related-doc-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.related-doc-info {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.related-doc-strength {
    font-weight: 600;
    color: var(--accent);
    min-width: 36px;
}

.related-doc-type {
    opacity: 0.7;
}

.related-doc-date {
    margin-left: auto;
}

/* ── Archivarius v2.0: Tags, Related Documents ─────────────────── */

.tag-badge {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px;
    border-radius: 12px;
    font-size: 0.78rem;
    background: rgba(233, 69, 96, 0.12);
    color: var(--accent);
    border: 1px solid rgba(233, 69, 96, 0.25);
}

.modal-related {
    margin-top: 8px;
}

.related-doc-item {
    display: flex;
    flex-direction: column;
    padding: 10px 14px;
    margin-bottom: 6px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.related-doc-item:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.related-doc-name {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.related-doc-info {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.related-doc-strength {
    font-weight: 600;
    color: var(--accent);
    min-width: 36px;
}

.related-doc-type {
    opacity: 0.7;
}

.related-doc-date {
    margin-left: auto;
}
