/* =========================================================
   reclip admin — design system
   Based on DESIGN.md: industrial/utilitarian dark theme
   ========================================================= */

/* ----- CSS Custom Properties ----- */
:root {
  --bg-primary:   #0f0f1a;
  --bg-card:      #1a1a2e;
  --bg-sidebar:   #141425;
  --bg-hover:     #22223a;
  --text-primary: #e0e0e0;
  --text-secondary: #8888a0;
  --accent:       #ff6b35;
  --accent-hover: #ff8555;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --border:       #2a2a40;

  --sidebar-width: 200px;
  --sidebar-collapsed: 56px;
}

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

html, body {
  height: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.1s ease;
}

a:hover {
  color: var(--accent-hover);
}

/* ----- Hamburger (mobile only) ----- */
.hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 300;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  flex-direction: column;
  gap: 4px;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: background 0.1s ease;
}

.hamburger:hover span {
  background: var(--accent);
}

/* ----- Sidebar ----- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.1s ease, color 0.1s ease;
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  border-left-color: var(--accent);
  color: var(--accent);
  background: var(--bg-hover);
  font-weight: 500;
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg,
.nav-item:hover svg {
  opacity: 1;
}

.sidebar-bottom {
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 150;
}

.sidebar-overlay.visible {
  display: block;
}

/* ----- Main Content ----- */
.content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.content-inner {
  max-width: 1400px;
  padding: 32px;
  margin: 0 auto;
}

/* ----- Page title ----- */
.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
}

/* ----- KPI Grid ----- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  text-decoration: none;
  display: block;
  transition: border-color 0.1s ease;
}

.kpi-card:hover {
  border-color: var(--accent);
  color: inherit;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi-trend {
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-height: 1em;
}

.kpi-trend.up   { color: var(--success); }
.kpi-trend.down { color: var(--danger); }

/* Disk bar */
.disk-bar-wrap {
  height: 4px;
  background: var(--bg-hover);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.disk-bar {
  height: 100%;
  border-radius: 2px;
  background: var(--success);
  width: 0%;
  transition: width 0.4s ease-out, background 0.2s ease;
}

.disk-bar.amber { background: var(--warning); }
.disk-bar.red   { background: var(--danger); }

/* ----- Cards ----- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 24px;
}

.section-card {
  margin-bottom: 24px;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.table-card .card-header {
  padding: 16px 16px 0;
}

.card-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ----- Chart ----- */
.chart-wrap {
  height: 240px;
  position: relative;
}

.chart-wrap--short {
  height: 180px;
}

/* ----- Bottom grid ----- */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

/* ----- Range buttons ----- */
.range-buttons {
  display: flex;
  gap: 4px;
}

.range-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.range-btn:hover,
.range-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

/* ----- Data Tables ----- */
.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

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

/* Striped rows */
.data-table tbody tr:nth-child(even) td {
  background: var(--bg-card);
}

.data-table tbody tr:nth-child(odd) td {
  background: var(--bg-primary);
}

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

/* Column check */
.col-check {
  width: 36px;
  text-align: center !important;
}

input[type="checkbox"] {
  cursor: pointer;
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

/* ----- Info table (key-value) ----- */
.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

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

.info-key {
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 200px;
}

/* ----- Empty state ----- */
.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px 12px !important;
  font-style: italic;
}

.empty-state--success {
  color: var(--success);
  font-style: normal;
}

.empty-check {
  font-size: 1.1rem;
  margin-right: 6px;
}

/* ----- Badges ----- */
.badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  vertical-align: middle;
  line-height: 1.4;
  white-space: nowrap;
  background: rgba(136, 136, 160, 0.2);
  color: var(--text-secondary);
}

.badge-success {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.badge-platform {
  background: rgba(255, 107, 53, 0.2);
  color: var(--accent);
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-family: inherit;
  font-weight: 500;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg-primary);
}

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover {
  background: rgba(255, 107, 53, 0.1);
  color: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

/* ----- Filter bar ----- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.filter-input,
.filter-select {
  padding: 7px 10px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.1s ease;
}

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

.filter-select option {
  background: var(--bg-card);
}

/* ----- Results info ----- */
.results-info {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* ----- URL cell ----- */
.url-cell {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--accent);
  word-break: break-all;
}

/* ----- Error message cell ----- */
.error-message {
  color: var(--danger);
  font-size: 0.8125rem;
  max-width: 400px;
}

/* ----- Text utilities ----- */
.mono {
  font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
}

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

/* ----- Pagination ----- */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.page-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.1s ease, color 0.1s ease;
}

.page-num:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.page-num.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
  font-weight: 600;
}

.page-ellipsis {
  color: var(--text-secondary);
  padding: 0 4px;
}

/* ----- Disk summary ----- */
.disk-summary {
  display: flex;
  gap: 24px;
  font-size: 0.8125rem;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ----- Modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
}

.modal-card--danger {
  border-color: var(--danger);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.modal-body {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.6;
}

.modal-body strong {
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ----- Toasts ----- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-primary);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.2s ease-out;
}

.toast.toast-success { border-color: var(--success); }
.toast.toast-danger  { border-color: var(--danger); }
.toast.toast-warning { border-color: var(--warning); }

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.1s ease;
}

.toast-close:hover {
  color: var(--text-primary);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ----- Responsive: Tablet (768–1023px) ----- */
@media (max-width: 1023px) {
  .sidebar {
    width: var(--sidebar-collapsed);
  }

  .sidebar-logo {
    font-size: 0.875rem;
    padding: 16px 8px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: clip;
    /* Hide text, show first char only as icon */
  }

  .sidebar-logo::after {
    content: 'rc';
    font-size: 0.75rem;
  }

  .sidebar-logo {
    font-size: 0;
  }

  .sidebar-logo::after {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 700;
  }

  .nav-item {
    justify-content: center;
    padding: 12px 8px;
    gap: 0;
  }

  .nav-item span {
    display: none;
  }

  .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .content {
    margin-left: var(--sidebar-collapsed);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ----- Responsive: Mobile (≤767px) ----- */
@media (max-width: 767px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Restore full sidebar look on mobile overlay */
  .sidebar .sidebar-logo {
    font-size: 0;
  }

  .sidebar .sidebar-logo::after {
    font-size: 1.125rem;
    content: 'reclip';
  }

  .sidebar .nav-item {
    justify-content: flex-start;
    padding: 9px 16px;
    gap: 10px;
  }

  .sidebar .nav-item span {
    display: inline;
  }

  .content {
    margin-left: 0;
  }

  .content-inner {
    padding: 60px 16px 24px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .table-scroll {
    overflow-x: auto;
  }

  .data-table {
    min-width: 600px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-input,
  .filter-select {
    width: 100%;
  }
}

/* ----- Reduced motion ----- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
