/* Dockhouse styles. Colours are CSS variables so the dark theme only has to
   redefine them. Layout: top bar, left sidebar, main content area. */

:root {
	--bg: #f8fafd;
	--surface: #ffffff;
	--surface-2: #f0f4f9;
	--hover: #e9eef6;
	--selected: #c2e7ff;
	--selected-text: #001d35;
	--border: #dde3ea;
	--text: #1f1f1f;
	--muted: #5f6368;
	--accent: #0b57d0;
	--accent-soft: #d3e3fd;
	--danger: #b3261e;
	--danger-soft: #f9dedc;
	--warn-soft: #ffefc9;
	--shadow: 0 1px 3px rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
	--radius: 16px;
	--folder: #5f6368;
	--image: #d93025;
	--video: #d93025;
	--audio: #e37400;
	--pdf: #ea4335;
	--text-file: #1a73e8;
	--code: #188038;
	--archive: #795548;
	--file: #80868b;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1b1b1f;
		--surface: #242428;
		--surface-2: #2d2e32;
		--hover: #34353a;
		--selected: #004a77;
		--selected-text: #c2e7ff;
		--border: #3c3d42;
		--text: #e3e3e3;
		--muted: #a8abb0;
		--accent: #a8c7fa;
		--accent-soft: #0842a0;
		--danger: #f2b8b5;
		--danger-soft: #601410;
		--warn-soft: #5c4400;
		--shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 4px 8px 3px rgba(0, 0, 0, .3);
		--folder: #c4c7c5;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
	font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 400; margin: 0; }
h2 { font-size: 16px; font-weight: 500; margin: 0 0 12px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.icon { width: 20px; height: 20px; flex: none; }
svg { display: inline-block; vertical-align: middle; }

/* ----- Buttons and form controls ----- */

.btn {
	display: inline-flex; align-items: center; gap: 8px;
	height: 40px; padding: 0 20px;
	border: 1px solid var(--border); border-radius: 20px;
	background: var(--surface); color: var(--accent);
	font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.danger-text { color: var(--danger); }
.btn.small { height: 32px; padding: 0 14px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .icon { width: 18px; height: 18px; }

.icon-btn {
	display: inline-grid; place-items: center;
	width: 40px; height: 40px; border: 0; border-radius: 50%;
	background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small .icon { width: 18px; height: 18px; }

input, select, textarea {
	font: inherit; color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border); border-radius: 8px;
	padding: 9px 12px; min-height: 40px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .icon-btn:focus-visible, .row:focus-visible {
	outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.stack-form label .hint { font-weight: 400; margin: 0; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form input, .inline-form select { flex: 1 1 240px; }
.form-error {
	background: var(--danger-soft); color: var(--danger);
	border-radius: 8px; padding: 10px 12px; margin: 0 0 16px;
}

/* ----- Auth and error pages ----- */

body.centered { display: grid; place-items: center; min-height: 100%; padding: 24px; }
.auth-card {
	width: 100%; max-width: 420px;
	background: var(--surface); border-radius: 28px; padding: 36px;
	box-shadow: var(--shadow);
}
.auth-card h1 { margin: 12px 0 8px; }
.auth-card > p { margin: 0 0 20px; }
.auth-logo { display: block; }

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

body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
	display: flex; align-items: center; gap: 12px;
	height: 64px; padding: 0 16px; flex: none;
}
.brand { display: flex; align-items: center; gap: 10px; width: 222px; color: var(--text); font-size: 20px; }
.brand:hover { text-decoration: none; }
.menu-toggle { display: none; }
.search {
	flex: 0 1 720px; min-width: 0; display: flex; align-items: center; gap: 10px;
	height: 48px; padding: 0 16px; border-radius: 24px; background: var(--surface-2);
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow); }
.search .icon { color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; padding: 0; min-height: 0; outline: none; }
.user-menu { margin-left: auto; position: relative; flex: none; }
.avatar {
	width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
	background: var(--accent); color: var(--surface); font-family: inherit; font-size: 16px; font-weight: 500;
}

.menu {
	position: absolute; z-index: 50; min-width: 220px; padding: 8px 0;
	background: var(--surface); border-radius: 8px; box-shadow: var(--shadow);
}
.user-menu .menu { right: 0; top: 44px; }
.menu a, .menu button {
	display: flex; align-items: center; gap: 12px; width: 100%;
	padding: 0 16px; height: 40px; border: 0; background: none;
	color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--hover); text-decoration: none; }
.menu .icon { color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
.menu-header { display: flex; flex-direction: column; padding: 8px 16px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.menu-header span { color: var(--muted); font-size: 13px; }

.shell { flex: 1; display: flex; min-height: 0; }
.sidebar {
	width: 256px; flex: none; display: flex; flex-direction: column;
	padding: 8px 12px 16px 8px; overflow-y: auto;
}
.new-btn {
	display: inline-flex; align-items: center; gap: 12px; align-self: flex-start;
	height: 56px; padding: 0 24px 0 18px; margin: 0 0 16px 4px;
	border: 0; border-radius: 16px; background: var(--surface); color: var(--text);
	box-shadow: var(--shadow); font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.new-btn:hover { background: var(--hover); }
.new-btn .icon { width: 24px; height: 24px; }
.nav-item {
	display: flex; align-items: center; gap: 14px;
	height: 34px; padding: 0 12px 0 16px; border-radius: 17px;
	color: var(--text); white-space: nowrap;
}
.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active { background: var(--selected); color: var(--selected-text); font-weight: 500; }
.nav-item .icon { color: var(--muted); }
.nav-item.active .icon { color: var(--selected-text); }
.nav-section { margin: 16px 0 4px 16px; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.nav-empty { margin: 4px 16px; color: var(--muted); font-size: 13px; }
.nav-bottom { margin-top: auto; padding-top: 16px; }
.nav-item.drop-target { background: var(--accent-soft); }

.content {
	flex: 1; min-width: 0; position: relative; overflow-y: auto;
	margin: 0 16px 16px 0; padding: 12px 24px 24px;
	background: var(--surface); border-radius: var(--radius);
}
.scrim { display: none; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; margin-bottom: 8px; flex-wrap: wrap; }

/* ----- Folder view ----- */

.toolbar { display: flex; align-items: center; gap: 8px; min-height: 56px; }
.breadcrumbs { flex: 1; display: flex; align-items: center; flex-wrap: wrap; min-width: 0; font-size: 22px; }
.crumb { padding: 2px 10px; border-radius: 18px; color: var(--text); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb:hover { background: var(--hover); text-decoration: none; }
.crumb.current { font-weight: 400; }
.crumb.drop-target { background: var(--accent-soft); }
.crumb-sep { color: var(--muted); }
.page-head .breadcrumbs { font-size: 22px; }
.toolbar-actions { display: flex; gap: 4px; }

.selection-bar {
	display: flex; align-items: center; gap: 8px;
	height: 48px; padding: 0 8px; margin-bottom: 8px;
	background: var(--surface-2); border-radius: 24px;
}
.selection-count { font-weight: 500; margin-right: auto; }
.selection-actions { display: flex; gap: 2px; }

.listing { user-select: none; }
.listing-head, .listing .row {
	display: grid; align-items: center; gap: 12px;
	grid-template-columns: 32px minmax(0, 1fr) 190px 100px 40px;
	padding: 0 8px;
}
.search-results .listing-head, .search-results .row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 190px 100px; padding-left: 16px; }
.listing-head { height: 48px; border-bottom: 1px solid var(--border); color: var(--muted); font-weight: 500; }
.listing .row {
	height: 48px; border-bottom: 1px solid var(--border);
	color: var(--text); cursor: default; outline-offset: -2px;
}
.listing a.row { cursor: pointer; }
.listing a.row:hover { text-decoration: none; }
.listing .row:hover { background: var(--hover); }
.listing .row.selected { background: var(--selected); color: var(--selected-text); }
.listing .row.drop-target { background: var(--accent-soft); outline: 2px solid var(--accent); }
.listing .row.highlight { animation: flash 2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } }
.check { display: grid; place-items: center; height: 100%; cursor: pointer; }
.col-name { display: flex; align-items: center; gap: 14px; min-width: 0; }
.col-name .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-modified, .col-size, .col-location { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.selected .col-modified, .row.selected .col-size { color: inherit; }
.col-more { opacity: 0; }
.row:hover .col-more, .row:focus-within .col-more, .row.selected .col-more { opacity: 1; }
.thumb { display: none; }

.ficon { width: 24px; height: 24px; flex: none; color: var(--file); }
.ficon-folder { color: var(--folder); }
.ficon-image { color: var(--image); }
.ficon-video { color: var(--video); }
.ficon-audio { color: var(--audio); }
.ficon-pdf { color: var(--pdf); }
.ficon-text { color: var(--text-file); }
.ficon-code { color: var(--code); }
.ficon-archive { color: var(--archive); }

/* Grid view: the same markup laid out as cards. */
.listing.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; padding-top: 8px; }
.listing.grid .listing-head { grid-column: 1 / -1; display: flex; border: 0; height: 32px; padding: 0 4px; }
.listing.grid .listing-head > :not(.check) { display: none; }
.listing.grid .listing-head::after { content: "Select all"; color: var(--muted); margin-left: 8px; }
.listing.grid .row {
	display: flex; flex-direction: column; align-items: stretch; gap: 0;
	height: auto; padding: 0; border: 0; border-radius: 12px;
	background: var(--surface-2); overflow: hidden; position: relative;
}
.listing.grid .row:hover { background: var(--hover); }
.listing.grid .row.selected { background: var(--selected); }
.listing.grid .check { position: absolute; top: 8px; left: 8px; height: auto; z-index: 1; opacity: 0; }
.listing.grid .row:hover .check, .listing.grid .row.selected .check, .listing.grid.selecting .check { opacity: 1; }
.listing.grid .col-name { flex-direction: column; align-items: stretch; gap: 0; }
.listing.grid .ficon { width: 64px; height: 64px; margin: 28px auto; }
.listing.grid .thumb { display: block; width: 100%; height: 120px; object-fit: cover; background: var(--surface); }
.listing.grid .thumb + .ficon { display: none; }
.listing.grid .name { padding: 10px 44px 10px 12px; font-weight: 500; }
.listing.grid .col-modified, .listing.grid .col-size { display: none; }
.listing.grid .col-more { position: absolute; right: 4px; bottom: 4px; opacity: 1; }

.drop-overlay {
	position: absolute; inset: 0; z-index: 20; display: grid; place-items: center;
	background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
	border: 2px dashed var(--accent); border-radius: var(--radius);
	text-align: center; font-size: 16px; pointer-events: none;
}
.drop-overlay .empty-icon { color: var(--accent); }

.empty { text-align: center; padding: 64px 16px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 18px; font-weight: 400; margin: 16px 0 8px; }
.empty p { max-width: 420px; margin: 0 auto 20px; }
.empty-icon { width: 96px; height: 96px; color: var(--border); }

/* ----- Home: share cards ----- */

.share-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.share-card {
	display: flex; align-items: center; gap: 16px; padding: 16px;
	border-radius: 12px; background: var(--surface-2); color: var(--text);
}
.share-card:hover { background: var(--hover); text-decoration: none; }
.share-card-icon { width: 40px; height: 40px; color: var(--folder); flex: none; }
.share-card-text { display: flex; flex-direction: column; min-width: 0; }
.share-card-text strong { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-card-text span { color: var(--muted); font-size: 13px; }

/* ----- Cards, tables (settings, trash, admin) ----- */

.cards { display: grid; gap: 16px; max-width: 760px; }
.card { background: var(--surface-2); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.cards .card { margin: 0; }
.card.danger { background: var(--danger-soft); }
.card > p { margin: 0 0 12px; }
.member-list {
	display: flex; flex-direction: column; max-height: 320px; overflow-y: auto;
	margin: 12px 0; background: var(--surface); border-radius: 8px; padding: 4px 0;
}
.member-list label { display: flex; align-items: center; gap: 12px; padding: 8px 14px; cursor: pointer; }
.member-list label:hover { background: var(--hover); }
.filter { width: 100%; }
.plain-list { margin: 0; padding-left: 20px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.card .table td, .card .table th { border-color: color-mix(in srgb, var(--border) 70%, transparent); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }
.name-cell > div { display: flex; align-items: center; gap: 12px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 10px; background: var(--accent-soft); font-size: 12px; font-weight: 500; }
.badge.warn { background: var(--warn-soft); }
.scan-report { margin: 12px 0 0; padding: 12px; background: var(--surface); border-radius: 8px; white-space: pre-wrap; font-size: 13px; }

/* ----- Dialogs ----- */

.dialog-backdrop {
	position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
	background: rgba(0, 0, 0, .4);
}
.dialog {
	width: 100%; max-width: 440px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
	background: var(--surface); border-radius: 28px; padding: 24px; box-shadow: var(--shadow);
}
.dialog h2 { font-size: 22px; font-weight: 400; margin: 0 0 16px; }
.dialog p { margin: 0 0 16px; overflow-wrap: anywhere; }
.dialog input[type=text], .dialog input:not([type]) { width: 100%; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.dialog-buttons .btn:not(.primary):not(.danger) { border-color: transparent; background: transparent; }
.dialog-buttons .btn:not(.primary):not(.danger):hover { background: var(--hover); }
.dialog .error { color: var(--danger); margin: 8px 0 0; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; font-family: ui-monospace, monospace; font-size: 13px; }

.picker { flex: 1; min-height: 240px; overflow-y: auto; margin: 0 -8px; }
.picker-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; min-height: 40px; font-weight: 500; }
.picker-item {
	display: flex; align-items: center; gap: 12px; width: 100%;
	height: 44px; padding: 0 12px; border: 0; border-radius: 8px;
	background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.picker-item:hover { background: var(--hover); }
.picker-item .icon:last-child { margin-left: auto; color: var(--muted); }
.picker-empty { color: var(--muted); padding: 12px; }

/* ----- Preview ----- */

.preview {
	position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column;
	background: #202124; color: #e3e3e3;
}
.preview-bar { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 12px; flex: none; }
.preview-bar .icon-btn { color: #e3e3e3; }
.preview-bar .icon-btn:hover { background: rgba(255, 255, 255, .1); }
.preview-title { flex: 1; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 64px 24px; position: relative; }
.preview-body img, .preview-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-body iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; }
.preview-body pre {
	width: 100%; max-width: 1000px; height: 100%; margin: 0; overflow: auto;
	padding: 20px; border-radius: 8px; background: #fff; color: #1f1f1f;
	font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.preview-body .no-preview { text-align: center; }
.preview-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.preview-nav.prev { left: 8px; }
.preview-nav.next { right: 8px; transform: translateY(-50%) scaleX(-1); }

/* ----- Uploads panel and toasts ----- */

.uploads {
	position: fixed; right: 24px; bottom: 24px; z-index: 80; width: 360px; max-width: calc(100vw - 32px);
	background: var(--surface); border-radius: 16px 16px 8px 8px; box-shadow: var(--shadow); overflow: hidden;
}
.uploads-head { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 8px 0 20px; background: var(--surface-2); font-weight: 500; }
.uploads-head span { flex: 1; }
.uploads-list { max-height: 280px; overflow-y: auto; }
.uploads.collapsed .uploads-list { display: none; }
.upload-item { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 16px; }
.upload-item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .status { color: var(--muted); font-size: 12px; }
.upload-item .status.error { color: var(--danger); }
.upload-item .status.done { color: var(--code); }
.upload-item progress { grid-column: 2 / 4; width: 100%; height: 4px; appearance: none; border: 0; border-radius: 2px; background: var(--surface-2); }
.upload-item progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 2px; }
.upload-item progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }
.upload-item progress::-moz-progress-bar { background: var(--accent); border-radius: 2px; }

.toasts { position: fixed; left: 24px; bottom: 24px; z-index: 110; display: flex; flex-direction: column; gap: 8px; }
.toast {
	max-width: 480px; padding: 14px 20px; border-radius: 8px;
	background: #303030; color: #f2f2f2; box-shadow: var(--shadow);
	animation: toast-in .15s ease-out;
}
.toast.error { background: #8c1d18; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.live-status {
	position: fixed; right: 16px; top: 72px; z-index: 30; padding: 4px 12px;
	border-radius: 12px; background: var(--warn-soft); font-size: 12px;
}

/* ----- Small screens ----- */

@media (max-width: 800px) {
	.topbar { gap: 8px; padding: 0 8px; }
	.menu-toggle { display: inline-grid; flex: none; }
	.brand { width: auto; flex: none; }
	.search { flex: 1 1 auto; padding: 0 12px; }
	.brand span { display: none; }
	.sidebar {
		position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
		background: var(--bg); box-shadow: var(--shadow); padding-top: 16px;
		transform: translateX(-100%); transition: transform .2s;
	}
	body.sidebar-open .sidebar { transform: none; }
	body.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .3); }
	.content { margin: 0 8px 8px; padding: 8px 12px 16px; }
	.listing-head, .listing .row { grid-template-columns: 32px minmax(0, 1fr) 40px; }
	.search-results .listing-head, .search-results .row { grid-template-columns: minmax(0, 1fr); }
	.col-modified, .col-size, .col-location { display: none; }
	.col-more { opacity: 1; }
	.breadcrumbs, .page-head .breadcrumbs { font-size: 18px; }
	.preview-body { padding: 0 8px 8px; }
	.preview-nav { display: none; }
	.uploads { right: 16px; bottom: 16px; }
}
