/* ==========================================================================
   DGDrive — Swiss & High-Contrast Design System
   Fonts: Outfit (UI) + IBM Plex Mono (data)
   Accent: International Klein Blue (#002CFF)
   ========================================================================== */

:root {
  /* Color System */
  --bg-base: #F7F7F5;
  --bg-surface: #FFFFFF;
  --bg-inset: #F0F0EC;
  --text-main: #0A0A0A;
  --text-muted: #6B6B6B;
  --text-faint: #9A9A94;

  --brand-primary: #002CFF;
  --brand-primary-hover: #001FCC;
  --brand-primary-light: rgba(0, 44, 255, 0.06);
  --brand-primary-ring: rgba(0, 44, 255, 0.18);

  --danger: #E32400;
  --danger-hover: #C11E00;
  --danger-light: rgba(227, 36, 0, 0.08);

  --success: #0B7A3B;
  --success-light: rgba(11, 122, 59, 0.08);

  --border-light: #E5E5E1;
  --border-medium: #D4D4CE;
  --border-dark: #1A1A1A;

  /* Typography */
  --font-ui: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-md: 0 6px 20px rgba(10, 10, 10, 0.05), 0 1px 3px rgba(10, 10, 10, 0.04);
  --shadow-lg: 0 20px 48px rgba(10, 10, 10, 0.08), 0 2px 6px rgba(10, 10, 10, 0.04);
  --shadow-focus: 0 0 0 4px var(--brand-primary-ring);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
*::selection { background: var(--brand-primary); color: #fff; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
}

/* Subtle grain texture on body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Layout ---------- */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 64px;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-ui);
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  font-weight: 500;
}
h3 { font-size: 1.125rem; font-weight: 500; }

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 18px 0 8px;
}

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

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

/* ---------- Brand ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  color: var(--text-main);
  text-decoration: none;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 5px;
  background: var(--text-main);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(10, 10, 10, 0.18);
  flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand span { font-weight: 700; letter-spacing: -0.02em; }

/* Big brand mark for login hero */
.brand-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}
.brand-hero .brand-mark {
  width: 68px;
  height: 68px;
  padding: 10px;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(10, 10, 10, 0.22), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  position: relative;
  animation: markPulse 3.6s ease-in-out infinite;
}
.brand-hero .brand-mark::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  background: radial-gradient(closest-side, rgba(140, 255, 251, 0.22), transparent 70%);
  z-index: -1;
  filter: blur(6px);
}
.brand-hero .brand-wordmark {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  color: var(--text-main);
}
@keyframes markPulse {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-2px); }
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 16px;
  z-index: 50;
}
.topbar > div:last-child {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar .muted { font-family: var(--font-mono); font-size: 0.8125rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-light);
  padding: 28px;
  box-shadow: var(--shadow-md);
  position: relative;
}
.card + .card { margin-top: 20px; }
.card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-light);
}

/* ---------- Login ---------- */
.login-box {
  max-width: 420px;
  margin: 10vh auto 0;
  padding: 40px;
  animation: fadeUp 0.6s var(--ease-out);
}
.login-box .brand {
  display: flex;
  justify-content: center;
  margin: 0 auto 6px;
}
.login-tag {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-bottom: 28px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.login-box button { margin-top: 8px; }
.login-foot {
  text-align: center;
  margin-top: 22px;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Inputs ---------- */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-medium);
  border-radius: var(--r-md);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  transition: border-color 0.15s var(--ease-out), box-shadow 0.15s var(--ease-out), background-color 0.15s var(--ease-out);
}
input:hover:not(:focus) { border-color: var(--text-muted); }
input:focus, select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}
input[type="number"] { font-family: var(--font-mono); }

/* ---------- Buttons ---------- */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 11px 20px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--brand-primary);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.15s var(--ease-out), transform 0.1s var(--ease-out), box-shadow 0.15s var(--ease-out), border-color 0.15s var(--ease-out), color 0.15s var(--ease-out);
  box-shadow: 0 4px 14px rgba(0, 44, 255, 0.18);
  letter-spacing: -0.005em;
  white-space: nowrap;
}
button:hover { background: var(--brand-primary-hover); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

button.secondary {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-medium);
  box-shadow: none;
}
button.secondary:hover {
  background: var(--bg-inset);
  border-color: var(--text-main);
  transform: none;
}

button.danger {
  background: var(--danger-light);
  color: var(--danger);
  box-shadow: none;
  border-color: transparent;
}
button.danger:hover {
  background: var(--danger);
  color: #fff;
  transform: none;
}

button svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ---------- Error / Alert ---------- */
.error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: var(--r-md);
  border-left: 3px solid var(--danger);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeUp 0.25s var(--ease-out);
}

/* ---------- Quota ---------- */
.quota-block {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
#quotaText {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-main);
  letter-spacing: -0.01em;
}
.quota-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 500;
}
.quota-bar-bg {
  background: var(--bg-inset);
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  width: 100%;
  margin: 8px 0 24px;
  border: 1px solid var(--border-light);
}
.quota-bar-fill {
  background: linear-gradient(90deg, var(--brand-primary) 0%, #4062FF 100%);
  height: 100%;
  border-radius: 999px;
  transition: width 0.9s var(--ease-out);
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border-medium);
  border-radius: var(--r-lg);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 0.9375rem;
  transition: border-color 0.2s var(--ease-out), background-color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
  margin-bottom: 24px;
  position: relative;
}
.dropzone:hover {
  border-color: var(--text-muted);
  background: var(--bg-surface);
}
.dropzone.drag {
  border-color: var(--brand-primary);
  border-style: solid;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  transform: scale(1.005);
}
.dropzone-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  color: var(--text-muted);
  transition: color 0.2s var(--ease-out), transform 0.3s var(--ease-out);
}
.dropzone.drag .dropzone-icon {
  color: var(--brand-primary);
  transform: translateY(-4px);
}
.dropzone-hint {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 6px;
  color: var(--text-faint);
}

/* Upload progress */
#uploadProgressWrap {
  padding: 14px 16px;
  background: var(--bg-inset);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  animation: fadeUp 0.25s var(--ease-out);
}
#uploadProgressText {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-main);
  margin-bottom: 8px;
}
#uploadProgressWrap .quota-bar-bg { margin: 0; }

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 4px;
}
thead th {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1.5px solid var(--border-dark);
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
  background: transparent;
}
tbody td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: 0.9375rem;
  transition: background-color 0.15s var(--ease-out);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 0.15s var(--ease-out); }
tbody tr:hover td { background-color: var(--bg-base); }

/* First column padding align to card edge */
thead th:first-child, tbody td:first-child { padding-left: 4px; }
thead th:last-child, tbody td:last-child { padding-right: 4px; text-align: right; }

/* Monospace columns for size / date */
tbody td.mono, tbody td:nth-child(2), tbody td:nth-child(3) {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}
/* File name cell */
tbody td:first-child {
  color: var(--text-main);
  font-weight: 500;
}
.file-cell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.file-cell svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Admin table overrides — every column readable, active badge etc */
.admin-table tbody td { font-family: var(--font-ui); font-size: 0.9375rem; color: var(--text-main); }
.admin-table tbody td:nth-child(2),
.admin-table tbody td:nth-child(3),
.admin-table tbody td:nth-child(4) { font-family: var(--font-mono); font-size: 0.8125rem; color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.badge-on { background: var(--success-light); color: var(--success); }
.badge-off { background: var(--bg-inset); color: var(--text-muted); }
.badge-on::before,
.badge-off::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.tag-admin {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--text-main);
  color: #fff;
  margin-left: 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Row actions ---------- */
.row-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
  opacity: 0.35;
  transition: opacity 0.2s var(--ease-out);
}
tbody tr:hover .row-actions { opacity: 1; }
.row-actions button {
  padding: 7px 12px;
  font-size: 0.8125rem;
  box-shadow: none;
}
.row-actions button:not(.secondary):not(.danger) {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-medium);
}
.row-actions button:not(.secondary):not(.danger):hover {
  background: var(--text-main);
  color: #fff;
  border-color: var(--text-main);
  transform: none;
}

/* ---------- Empty state ---------- */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty svg {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  color: var(--text-faint);
  display: block;
}
.empty-title {
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 4px;
}
.empty-desc { font-size: 0.875rem; }

/* ---------- Card header (used inside admin & app) ---------- */
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}
.card-head h3 {
  border: none;
  padding: 0;
  margin: 0;
}
.card-head .muted {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

/* ---------- Stat pills ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--bg-base);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.stat-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* ---------- Animations ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card, .topbar { animation: fadeUp 0.4s var(--ease-out); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .wrap { padding: 20px 16px 48px; }
  .topbar { padding: 12px 14px; top: 8px; }
  .topbar > div:last-child { gap: 8px; }
  .card { padding: 20px; }
  .login-box { margin-top: 6vh; padding: 28px; }
  .dropzone { padding: 32px 16px; }
  thead th, tbody td { padding: 12px 8px; font-size: 0.875rem; }
  thead th:last-child, tbody td:last-child { padding-right: 0; }
  .row-actions { opacity: 1; flex-wrap: wrap; }
  .row-actions button { padding: 6px 10px; font-size: 0.75rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
