/* 302 DMS — shared stylesheet */

:root {
	--bg: #f1f5f9;
	--surface: #ffffff;
	--sidebar-bg: #0f172a;
	--sidebar-text: #cbd5e1;
	--sidebar-text-active: #ffffff;
	--sidebar-active-bg: #1d4ed8;
	--primary: #2563eb;
	--primary-dark: #1d4ed8;
	--primary-light: #dbeafe;
	--text: #0f172a;
	--text-muted: #64748b;
	--border: #e2e8f0;
	--success: #16a34a;
	--success-light: #dcfce7;
	--danger: #dc2626;
	--danger-light: #fee2e2;
	--warning: #d97706;
	--warning-light: #fef3c7;
	--radius: 10px;
	--radius-sm: 6px;
	--shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
	--shadow-md: 0 4px 16px rgba(15, 23, 42, 0.12);
	--sidebar-w: 240px;
	--topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body {
	height: 100%;
}

body {
	margin: 0;
	font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	font-size: 14px;
	line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 600; }
p { margin: 0 0 8px; }

button, input, select, textarea { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* ---------- Buttons ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	padding: 9px 16px;
	border-radius: var(--radius-sm);
	cursor: pointer;
	font-weight: 500;
	transition: background 0.15s, border-color 0.15s, transform 0.05s;
	white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.btn-danger {
	background: var(--surface);
	border-color: var(--danger);
	color: var(--danger);
}
.btn-danger:hover { background: var(--danger-light); }

.btn-warning {
	background: var(--surface);
	border-color: var(--warning);
	color: var(--warning);
}
.btn-warning:hover { background: var(--warning-light); }

.btn-ghost {
	background: transparent;
	border-color: transparent;
}
.btn-ghost:hover { background: #f1f5f9; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

/* ---------- Forms ---------- */

.field { margin-bottom: 16px; }
.field label {
	display: block;
	font-weight: 600;
	font-size: 12.5px;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.03em;
	margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="date"],
.field input[type="search"],
.field select,
.field textarea {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--text);
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
	border-color: var(--primary);
	box-shadow: 0 0 0 3px var(--primary-light);
}
.field textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 16px; height: 16px; }

/* ---------- Login page ---------- */

.login-page {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 55%, #2563eb 100%);
	padding: 24px;
}
.login-card {
	width: 100%;
	max-width: 380px;
	background: var(--surface);
	border-radius: 14px;
	box-shadow: var(--shadow-md);
	padding: 36px 32px;
}
.login-brand {
	text-align: center;
	margin-bottom: 28px;
}
.login-brand .logo-mark {
	width: 52px;
	height: 52px;
	margin: 0 auto 12px;
	border-radius: 12px;
	background: var(--primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 20px;
}
.login-brand h1 { font-size: 20px; }
.login-brand p { color: var(--text-muted); font-size: 13px; }

.login-error {
	background: var(--danger-light);
	color: var(--danger);
	border-radius: var(--radius-sm);
	padding: 10px 12px;
	font-size: 13px;
	margin-bottom: 16px;
}

.demo-hint {
	margin-top: 18px;
	padding: 12px 14px;
	background: #f8fafc;
	border: 1px dashed var(--border);
	border-radius: var(--radius-sm);
	font-size: 12.5px;
	color: var(--text-muted);
}
.demo-hint strong { color: var(--text); }

/* ---------- App shell ---------- */

.app-shell {
	display: flex;
	min-height: 100vh;
}

.sidebar {
	width: var(--sidebar-w);
	background: var(--sidebar-bg);
	color: var(--sidebar-text);
	display: flex;
	flex-direction: column;
	flex-shrink: 0;
	position: fixed;
	top: 0;
	bottom: 0;
	left: 0;
}
.sidebar-brand {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 18px 20px;
	border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .logo-mark {
	width: 34px;
	height: 34px;
	border-radius: 8px;
	background: var(--primary);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 14px;
	flex-shrink: 0;
}
.sidebar-brand .brand-text { font-weight: 700; font-size: 15px; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-text span { display: block; font-weight: 400; font-size: 11px; color: #94a3b8; }

.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-section-label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	color: #64748b;
	padding: 14px 10px 6px;
}
.nav-link {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: var(--radius-sm);
	color: var(--sidebar-text);
	font-size: 13.5px;
	font-weight: 500;
	margin-bottom: 2px;
	cursor: pointer;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); }
.nav-link .icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-link .badge-count {
	margin-left: auto;
	background: rgba(255,255,255,0.12);
	color: #fff;
	font-size: 11px;
	padding: 1px 7px;
	border-radius: 999px;
}

.sidebar-footer {
	padding: 14px 16px;
	border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user .avatar {
	width: 32px; height: 32px; border-radius: 50%;
	background: #334155; color: #fff;
	display: flex; align-items: center; justify-content: center;
	font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.sidebar-user .who { min-width: 0; }
.sidebar-user .who .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .role { font-size: 11px; color: #94a3b8; }

.main-area {
	margin-left: var(--sidebar-w);
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.topbar {
	height: var(--topbar-h);
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 24px;
	position: sticky;
	top: 0;
	z-index: 5;
}
.topbar h2 { font-size: 16px; }
.topbar-breadcrumb { font-size: 12.5px; color: var(--text-muted); }

.content { padding: 24px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------- Cards / surfaces ---------- */

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}
.card-header {
	padding: 16px 20px;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}
.card-header h3 { font-size: 14.5px; }
.card-body { padding: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 18px 20px;
	box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

.menu-tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.menu-tile {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 22px 20px;
	box-shadow: var(--shadow);
	cursor: pointer;
	transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
	display: block;
}
.menu-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: #cbd5e1; text-decoration: none; }
.menu-tile .tile-icon {
	width: 40px; height: 40px; border-radius: 10px;
	background: var(--primary-light); color: var(--primary);
	display: flex; align-items: center; justify-content: center;
	margin-bottom: 14px;
}
.menu-tile h3 { color: var(--text); font-size: 15px; }
.menu-tile p { color: var(--text-muted); font-size: 12.5px; margin: 0; }

/* ---------- Dropzone / upload ---------- */

.dropzone {
	border: 2px dashed #cbd5e1;
	border-radius: var(--radius);
	padding: 44px 20px;
	text-align: center;
	background: #f8fafc;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s;
}
.dropzone.drag-over { border-color: var(--primary); background: var(--primary-light); }
.dropzone .dz-icon { color: var(--primary); margin-bottom: 10px; }
.dropzone h3 { font-size: 15px; margin-bottom: 4px; }
.dropzone p { color: var(--text-muted); font-size: 12.5px; }
.dropzone .browse-link { color: var(--primary); font-weight: 600; text-decoration: underline; }

.file-queue { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.file-row {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
}
.file-row .file-type-icon {
	width: 36px; height: 36px; border-radius: 8px;
	background: var(--primary-light); color: var(--primary);
	display: flex; align-items: center; justify-content: center;
	flex-shrink: 0; font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.file-row .file-meta { flex: 1; min-width: 0; }
.file-row .file-name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-row .file-size { font-size: 11.5px; color: var(--text-muted); }
.file-row .progress-track { width: 120px; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
.file-row .progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.25s; }
.file-row .progress-fill.done { background: var(--success); }
.file-row .remove-btn { color: var(--text-muted); background: transparent; border: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 4px; flex-shrink: 0; }
.file-row .remove-btn:hover { color: var(--danger); }
.file-row .status-label { font-size: 11.5px; color: var(--success); font-weight: 600; flex-shrink: 0; width: 70px; text-align: right; }

/* ---------- Classify layout ---------- */

.classify-layout { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.doc-list { display: flex; flex-direction: column; gap: 8px; max-height: 640px; overflow-y: auto; padding: 4px; }
.doc-list-item {
	display: flex; align-items: center; gap: 10px;
	padding: 10px 12px;
	border: 1px solid var(--border);
	border-radius: var(--radius-sm);
	background: var(--surface);
	cursor: pointer;
}
.doc-list-item:hover { border-color: #cbd5e1; }
.doc-list-item.active { border-color: var(--primary); background: var(--primary-light); }
.doc-list-item .file-type-icon { width: 30px; height: 30px; font-size: 10px; }
.doc-list-item .dli-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.doc-list-item .dli-status { flex-shrink: 0; }

.preview-pane { display: flex; flex-direction: column; gap: 16px; }
.preview-box {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 24px;
	display: flex;
	align-items: center;
	gap: 20px;
	box-shadow: var(--shadow);
}
.preview-thumb {
	width: 96px; height: 96px; border-radius: 10px;
	background: var(--primary-light); color: var(--primary);
	display: flex; align-items: center; justify-content: center;
	font-size: 13px; font-weight: 700; text-transform: uppercase;
	flex-shrink: 0; overflow: hidden;
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }
.preview-info h3 { font-size: 15px; word-break: break-word; }
.preview-info .meta-line { font-size: 12px; color: var(--text-muted); }

.doc-preview-media {
	width: 100%;
	max-height: 560px;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	display: block;
}
.doc-preview-media.doc-preview-image { object-fit: contain; background: #f8fafc; }
.doc-preview-frame { width: 100%; height: 560px; border: 1px solid var(--border); border-radius: var(--radius); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { color: #cbd5e1; margin-bottom: 12px; }
.empty-state h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ---------- Badges ---------- */

.badge {
	display: inline-flex; align-items: center; gap: 4px;
	padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-green { background: var(--success-light); color: #15803d; }
.badge-amber { background: var(--warning-light); color: #b45309; }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }

/* ---------- Table ---------- */

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
	text-align: left; padding: 10px 14px; background: #f8fafc;
	color: var(--text-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em;
	border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:hover { background: #f8fafc; }
table.data-table td.doc-name-cell { display: flex; align-items: center; gap: 10px; max-width: 260px; }
table.data-table td.doc-name-cell .fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.narration-snippet { color: var(--text-muted); font-size: 12px; max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.actions-cell { display: flex; gap: 6px; }

/* ---------- Search filter bar ---------- */

.search-bar-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 4px; }
.search-bar-row .field { margin-bottom: 0; min-width: 150px; }
.search-bar-row .field.grow { flex: 1; min-width: 220px; }

.results-toolbar { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 10px; }
.results-toolbar .selected-info { font-size: 12.5px; color: var(--text-muted); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0 4px; }
.pager .selected-info { font-size: 12.5px; color: var(--text-muted); }

/* ---------- Modal ---------- */

.modal-overlay {
	position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
	display: flex; align-items: center; justify-content: center;
	z-index: 100; padding: 20px;
}
.modal-box {
	background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-md);
	width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal-box.modal-wide { max-width: 620px; }
.modal-box.modal-viewer { max-width: 1100px; }
.modal-header h3 { word-break: break-word; }
.viewer-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.viewer-preview { min-width: 0; }
.viewer-preview .doc-preview-frame { height: 65vh; }
.viewer-preview .doc-preview-image { max-height: 65vh; }
.viewer-meta p { word-break: break-word; white-space: pre-wrap; }
.doc-preview-text {
	max-height: 65vh; overflow: auto; margin: 0; padding: 14px;
	border: 1px solid var(--border); border-radius: var(--radius); background: #f8fafc;
	font-size: 12.5px; white-space: pre-wrap; word-break: break-word;
}
@media (max-width: 860px) {
	.viewer-layout { grid-template-columns: 1fr; }
}
.modal-header {
	display: flex; align-items: center; justify-content: space-between;
	padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15.5px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Toast ---------- */

.toast-stack {
	position: fixed; bottom: 20px; right: 20px; z-index: 200;
	display: flex; flex-direction: column; gap: 10px; align-items: flex-end;
}
.toast {
	background: #0f172a; color: #fff; padding: 12px 16px; border-radius: var(--radius-sm);
	font-size: 13px; box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px;
	animation: toast-in 0.2s ease-out;
	max-width: 320px;
}
.toast.toast-success { background: #15803d; }
.toast.toast-error { background: #b91c1c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Tabs (admin) ---------- */

.tab-strip { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
	padding: 10px 16px; border: none; background: none; cursor: pointer;
	font-weight: 600; font-size: 13px; color: var(--text-muted);
	border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Misc ---------- */

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.flex-row { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin: 0 0 12px; }

@media (max-width: 860px) {
	:root { --sidebar-w: 0px; }
	.sidebar { display: none; }
	.main-area { margin-left: 0; }
	.classify-layout { grid-template-columns: 1fr; }
}
