/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --color-bg:            #f8fafc;
  --color-surface:       #ffffff;
  --color-border:        #e2e8f0;
  --color-border-input:  #cbd5e1;
  --color-primary:       #1d4ed8;
  --color-primary-hover: #1e40af;
  --color-primary-light: rgba(29, 78, 216, 0.08);
  --color-text:          #0f172a;
  --color-text-muted:    #64748b;
  --color-text-subtle:   #94a3b8;
  --color-link:          #1d4ed8;
  --color-error:         #dc2626;
  --sidebar-bg:          #0f172a;
  --sidebar-border:      rgba(255, 255, 255, 0.07);
  --sidebar-text:        rgba(248, 250, 252, 0.65);
  --sidebar-text-active: #f8fafc;
  --sidebar-hover-bg:    rgba(255, 255, 255, 0.06);
  --sidebar-active-bg:   rgba(255, 255, 255, 0.10);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --radius:    0.25rem;
  --radius-lg: 0.5rem;
  --shadow:    0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
}

/* ─── App shell ──────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 180px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.sidebar-header {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--sidebar-text-active);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}

.sidebar-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

/* ─── Main wrap ──────────────────────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  flex-shrink: 0;
}

/* Search */
.topbar-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.topbar-search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--color-text-subtle);
  pointer-events: none;
}

.topbar-search-input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  padding: 0.375rem 0.75rem 0.375rem 2rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}

.topbar-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}

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

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
}

.topbar-icon-btn {
  background: none;
  border: none;
  padding: 0.375rem;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
}

.topbar-icon-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.topbar-icon-btn svg { width: 20px; height: 20px; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.25rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.875rem;
  color: var(--color-text);
}

/* ─── Main content ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  background: var(--color-bg);
}

/* ─── Bootstrap overrides: buttons ──────────────────────────────────────── */
.btn {
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
}

.btn-primary {
  --bs-btn-bg:                  var(--color-primary);
  --bs-btn-border-color:        var(--color-primary);
  --bs-btn-hover-bg:            var(--color-primary-hover);
  --bs-btn-hover-border-color:  var(--color-primary-hover);
  --bs-btn-active-bg:           var(--color-primary-hover);
  --bs-btn-active-border-color: var(--color-primary-hover);
  --bs-btn-focus-shadow-rgb:    29, 78, 216;
}

.btn-outline-primary {
  --bs-btn-color:               var(--color-primary);
  --bs-btn-border-color:        var(--color-primary);
  --bs-btn-hover-bg:            var(--color-primary);
  --bs-btn-hover-border-color:  var(--color-primary);
  --bs-btn-active-bg:           var(--color-primary);
  --bs-btn-active-border-color: var(--color-primary);
  --bs-btn-focus-shadow-rgb:    29, 78, 216;
}

.btn-outline-secondary {
  --bs-btn-color:              var(--color-text-muted);
  --bs-btn-border-color:       var(--color-border-input);
  --bs-btn-hover-bg:           var(--color-bg);
  --bs-btn-hover-border-color: var(--color-text-muted);
  --bs-btn-hover-color:        var(--color-text);
}

.btn-outline-danger {
  --bs-btn-color:              var(--color-error);
  --bs-btn-border-color:       var(--color-error);
  --bs-btn-hover-bg:           var(--color-error);
  --bs-btn-hover-border-color: var(--color-error);
}

/* ─── Bootstrap overrides: form controls ────────────────────────────────── */
.form-control,
.form-select {
  border-color: var(--color-border-input);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15);
}

/* ─── Bootstrap overrides: alerts ───────────────────────────────────────── */
.alert-danger {
  --bs-alert-bg:           #fee2e2;
  --bs-alert-border-color: #fca5a5;
  --bs-alert-color:        #991b1b;
}

/* ─── Storage overview ───────────────────────────────────────────────────── */
.storage-overview {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.storage-overview-header {
  margin-bottom: 0.875rem;
}

.storage-overview-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.storage-overview-title svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.storage-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.storage-bar-row:last-child { margin-bottom: 0; }

.storage-bar-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  width: 36px;
  flex-shrink: 0;
}

.storage-progress {
  flex: 1;
  height: 6px;
  border-radius: 9999px;
  background: var(--color-border);
  overflow: hidden;
}

.storage-progress-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.storage-progress-bar--used {
  background: #f59e0b;
}

.storage-bar-value {
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  color: var(--color-text);
  font-weight: 500;
  width: 72px;
  text-align: right;
  flex-shrink: 0;
}

/* ─── Files section ──────────────────────────────────────────────────────── */
.files-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

.files-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.files-section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.files-section-title svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.files-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

.files-breadcrumb-link {
  color: var(--color-text-muted);
  text-decoration: none;
}

.files-breadcrumb-link:hover { color: var(--color-link); }

.files-breadcrumb-sep { color: var(--color-text-subtle); }

/* ─── Files tools (embedded in Files section) ────────────────────────────── */
.files-tools {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.search-form,
.inline-form,
.action-row {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 260px;
}

.search-icon {
  position: absolute;
  left: 0.625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--color-text-subtle);
  pointer-events: none;
}

.search-input-wrap .form-control { padding-left: 2.125rem; }

.search-form .form-select { max-width: 130px; }

.folder-name-input { flex: 1; max-width: 300px; }

/* ─── Table shell ────────────────────────────────────────────────────────── */
.table-shell { overflow-x: auto; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.file-table,
.audit-table {
  margin-bottom: 0;
}

.file-table thead th,
.audit-table thead th {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  padding: 0.5rem 0.875rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.file-table tbody tr,
.audit-table tbody tr {
  border-bottom: 1px solid var(--color-bg);
}

.file-table tbody tr:last-child,
.audit-table tbody tr:last-child {
  border-bottom: none;
}

.file-table tbody tr:hover,
.audit-table tbody tr:hover {
  background: #f8faff;
}

.file-table tbody td,
.audit-table tbody td {
  padding: 0 0.875rem;
  vertical-align: middle;
}

.file-table tbody tr  { height: 48px; }
.audit-table tbody tr { height: 40px; }

.file-table tbody td:nth-child(3),
.file-table tbody td:nth-child(4) {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.audit-table tbody td:nth-child(1),
.audit-table tbody td:nth-child(6) {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ─── File name ──────────────────────────────────────────────────────────── */
.file-name {
  color: var(--color-link);
  display: block;
  font-weight: 500;
  text-decoration: none;
}

.file-name:hover { text-decoration: underline; }

.item-count {
  color: var(--color-text-subtle);
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

/* ─── Actions column ─────────────────────────────────────────────────────── */
.actions-column { min-width: 180px; }

.action-row { margin-bottom: 0; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  color: var(--color-border-input);
  margin-bottom: 0.875rem;
}

.empty-state-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.empty-state-sub {
  font-size: 0.8125rem;
  color: var(--color-text-subtle);
}

/* ─── Method labels ──────────────────────────────────────────────────────── */
.method {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
}

.method--get    { color: #1d4ed8; }
.method--post   { color: var(--color-text); }
.method--put    { color: #b45309; }
.method--patch  { color: #b45309; }
.method--delete { color: #dc2626; }

/* ─── Status badges ──────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.5rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge--success  { background: #dcfce7; color: #166534; }
.status-badge--redirect { background: #f1f5f9; color: #475569; }
.status-badge--warning  { background: #fef3c7; color: #92400e; }
.status-badge--error    { background: #fee2e2; color: #991b1b; }

/* ─── Audit section ──────────────────────────────────────────────────────── */
.audit-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

.audit-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.audit-header-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
}

.audit-header-title svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.audit-path {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  max-width: 420px;
  overflow-wrap: anywhere;
}

.audit-error {
  color: var(--color-error);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  max-width: 280px;
  overflow-wrap: anywhere;
}

/* ─── Preview modal ──────────────────────────────────────────────────────── */
.metadata-list {
  display: grid;
  gap: 0.25rem 0.75rem;
  grid-template-columns: 64px minmax(0, 1fr);
  margin-bottom: 1rem;
}

.metadata-list dt {
  color: var(--color-text-muted);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding-top: 0.125rem;
  text-transform: uppercase;
}

.metadata-list dd {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}

.preview-image {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  max-height: 520px;
  max-width: 100%;
}

.preview-frame {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  height: 520px;
  width: 100%;
}

.text-preview {
  background: #0f1117;
  border-radius: var(--radius);
  color: #e4e6f0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1.65;
  max-height: 520px;
  overflow: auto;
  padding: 1rem;
  white-space: pre-wrap;
}

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login-page {
  align-items: center;
  background: var(--color-bg);
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.login-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.07);
  max-width: 400px;
  padding: 2rem;
  width: 100%;
}

.login-panel h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.25rem;
}
