/* ==========================================================================
   KBS MEDIA PORTAL — dashboard layout & file manager
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

/* ------------------------------- sidebar ------------------------------- */

.sidebar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 18px 14px;
  border-inline-end: 1px solid var(--border);
  background: var(--bg-2);
  overflow-y: auto;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-inline: 4px;
}

.sidebar-close {
  display: none;
}

.nav {
  display: grid;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-item .icon {
  width: 17px;
  height: 17px;
}

.nav-item:hover {
  background: var(--card);
  color: var(--text);
}

.nav-item.is-active {
  background: rgba(99, 102, 241, 0.14);
  color: var(--text);
}

.nav-item.is-active .icon {
  color: #a5b4fc;
}

[data-theme='light'] .nav-item.is-active .icon {
  color: var(--primary);
}

.nav-item .nav-count {
  margin-inline-start: auto;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.nav-group-label {
  margin: 16px 11px 6px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 3px;
}

.nav-item-button {
  font-size: 13px;
}

.nav-item-button:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.08);
}

.nav-item-button:hover .icon {
  color: var(--error);
}

.sidebar-backdrop {
  display: none;
}

/* -------------------------------- main --------------------------------- */

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.85);
  backdrop-filter: blur(14px);
}

[data-theme='light'] .topbar {
  background: rgba(255, 255, 255, 0.88);
}

.topbar-menu {
  display: none;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-box .icon {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 12px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  height: 38px;
  padding-inline: 38px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
}

.notif {
  position: relative;
}

.notif-dot {
  position: absolute;
  inset-block-start: 6px;
  inset-inline-end: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  border: 1.5px solid var(--bg);
}

.notif-menu {
  position: absolute;
  inset-block-start: calc(100% + 10px);
  inset-inline-end: 0;
  width: min(340px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 50;
}

.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  font-size: 12.5px;
}

.notif-head span {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.notif-list {
  display: grid;
  gap: 2px;
  max-height: 320px;
  overflow: auto;
}

.notif-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 9px;
  transition: background-color 0.15s ease;
}

.notif-item:hover {
  background: var(--card-hover);
}

.notif-item .notif-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
}

[data-theme='light'] .notif-item .notif-icon {
  color: var(--primary);
}

.notif-item .notif-icon .icon {
  width: 15px;
  height: 15px;
}

.notif-item-body {
  min-width: 0;
  flex: 1;
}

.notif-item-title {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif-item-meta {
  color: var(--muted);
  font-size: 11px;
}

.notif-empty {
  padding: 18px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-inline-start: 8px;
  margin-inline-start: 4px;
  border-inline-start: 1px solid var(--border);
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.profile-meta {
  display: grid;
  line-height: 1.35;
}

.profile-meta strong {
  font-size: 12.5px;
  font-weight: 600;
}

.profile-meta span {
  color: var(--muted);
  font-size: 10.5px;
}

.content {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding: 26px 24px 56px;
  flex: 1;
}

/* -------------------------------- stats -------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(172px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.stat-label .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.stat-value {
  font-size: 23px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  color: var(--muted);
  font-size: 11px;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 14px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 13.5px;
  font-weight: 700;
}

.panel-lead {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
}

.panel-body {
  padding: 16px 18px 18px;
  flex: 1;
}

.panel-note {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.storage-list {
  display: grid;
  gap: 13px;
}

.storage-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.storage-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.storage-name .icon {
  width: 14px;
  height: 14px;
}

.bar {
  height: 7px;
  border-radius: 99px;
  background: var(--bg-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.35s ease;
}

.bar-fill[data-kind='video'] {
  background: #6366f1;
}
.bar-fill[data-kind='image'] {
  background: #10b981;
}
.bar-fill[data-kind='document'] {
  background: #3b82f6;
}
.bar-fill[data-kind='archive'] {
  background: #f59e0b;
}
.bar-fill[data-kind='other'] {
  background: #64748b;
}

.storage-value {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.recent-list {
  display: grid;
  gap: 2px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 9px;
  transition: background-color 0.15s ease;
}

.recent-item:hover {
  background: var(--card-hover);
}

.recent-thumb {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--muted);
  overflow: hidden;
}

.recent-thumb img,
.recent-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recent-thumb .icon {
  width: 15px;
  height: 15px;
}

.recent-body {
  min-width: 0;
  flex: 1;
}

.recent-title {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-meta {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-side {
  color: var(--muted);
  font-size: 10.5px;
  white-space: nowrap;
}

/* ------------------------------- toolbar ------------------------------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-inline {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-inline .icon {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 11px;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.search-inline input {
  width: 100%;
  height: 36px;
  padding-inline: 34px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
}

.search-inline input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}

.segmented button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.segmented button .icon {
  width: 15px;
  height: 15px;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  background: var(--bg-2);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.toolbar-info {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  margin-inline-start: auto;
}

/* ------------------------------- files --------------------------------- */

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 13px;
}

.file-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.17s ease, transform 0.17s ease, box-shadow 0.17s ease;
}

.file-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 18px 32px -26px rgba(0, 0, 0, 0.8);
}

.file-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.file-thumb img,
.file-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumb .thumb-fallback {
  position: relative;
  z-index: 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
}

.file-thumb .thumb-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumb .thumb-fallback .icon {
  width: 26px;
  height: 26px;
}

.thumb-ext {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.thumb-badge {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: 2;
}

.thumb-count {
  position: absolute;
  inset-block-end: 8px;
  inset-inline-end: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(6, 8, 14, 0.72);
  color: #e2e8f0;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(4px);
}

.thumb-open {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.file-body {
  display: grid;
  gap: 7px;
  padding: 12px 13px 13px;
  flex: 1;
  align-content: start;
}

.file-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.file-name {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: start;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.file-meta .icon {
  width: 12px;
  height: 12px;
}

.file-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.file-actions .icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.file-actions .icon-btn .icon {
  width: 15px;
  height: 15px;
}

.file-actions .danger:hover {
  color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.file-actions .spacer {
  flex: 1;
}

/* list mode */

.files-list {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
}

.list-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 2.2fr) minmax(0, 1.1fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.15s ease;
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row:hover {
  background: var(--card-hover);
}

.list-thumb {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-2);
  color: var(--muted);
  overflow: hidden;
}

.list-thumb img,
.list-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-thumb .icon {
  width: 16px;
  height: 16px;
}

.list-main {
  min-width: 0;
}

.list-title {
  font-size: 12.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-sub {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: start;
}

.list-cell {
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.list-actions .icon-btn {
  width: 30px;
  height: 30px;
}

.list-actions .icon-btn .icon {
  width: 15px;
  height: 15px;
}

/* ----------------------------- pagination ------------------------------ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.pagination-info {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ------------------------------ preview -------------------------------- */

.preview-modal {
  max-height: calc(100vh - 40px);
}

.preview-body {
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 0;
  overflow: hidden;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 380px;
  padding: 18px;
  background: #05070c;
  overflow: auto;
}

.preview-stage img {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  border-radius: 8px;
  transform-origin: center;
  transition: transform 0.18s ease;
  cursor: grab;
}

.preview-stage video {
  width: 100%;
  max-height: calc(100vh - 220px);
  border-radius: 8px;
  background: #000;
}

.preview-stage iframe {
  width: 100%;
  height: calc(100vh - 240px);
  min-height: 360px;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

.preview-stage .preview-fallback {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.preview-stage .preview-fallback .icon {
  width: 42px;
  height: 42px;
  color: var(--primary);
}

.preview-stage .preview-fallback strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.preview-stage .preview-fallback span {
  font-size: 12px;
  max-width: 34ch;
}

.preview-tools {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 12px;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(8, 11, 18, 0.72);
  backdrop-filter: blur(6px);
}

.preview-tools .icon-btn {
  width: 30px;
  height: 30px;
  color: #cbd5e1;
}

.preview-tools .icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.preview-side {
  display: flex;
  flex-direction: column;
  border-inline-start: 1px solid var(--border);
  overflow: auto;
}

.preview-side-inner {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.meta-list {
  display: grid;
  gap: 11px;
}

.meta-item {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.meta-label {
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.meta-value {
  font-size: 12.5px;
  word-break: break-word;
  line-height: 1.7;
}

.meta-value.ltr {
  direction: ltr;
  text-align: start;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: 11.5px;
}

.meta-note {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.preview-side-actions {
  display: grid;
  gap: 8px;
}

.detail-files {
  display: grid;
  gap: 6px;
}

.detail-file {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-2);
  font-size: 11.5px;
}

.detail-file .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.detail-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: start;
  flex: 1;
}

.detail-file small {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ settings ------------------------------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-of-type {
  border-bottom: 0;
}

.settings-row .select {
  width: auto;
  min-width: 130px;
}

.kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}

.kv:last-child {
  border-bottom: 0;
}

.kv span:first-child {
  color: var(--muted);
}

.kv span:last-child {
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
}

.status-pill .icon {
  width: 13px;
  height: 13px;
}

.status-online {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
}

[data-theme='light'] .status-online {
  color: #15803d;
}

.status-offline {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}

[data-theme='light'] .status-offline {
  color: #b91c1c;
}

.settings-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.8;
}

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
