/* ============================================================
   Gestor de Archivos — Tema "Azul profesional, claro"
   ============================================================ */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --border: #334155;
  --border-strong: #475569;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-soft: rgba(59, 130, 246, .16);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, .14);
  --success-bd: rgba(34, 197, 94, .40);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, .14);
  --danger-bd: rgba(239, 68, 68, .40);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 2px 6px rgba(0, 0, 0, .40);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .50);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .6em 1.1em;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn-block { width: 100%; }

/* ---------- Campos ---------- */
.field { margin-bottom: 1.1em; }
.field label {
  display: block;
  font-weight: 600;
  font-size: .85em;
  color: var(--muted);
  margin-bottom: .45em;
}
input[type="text"], input[type="password"], input[type="file"] {
  width: 100%;
  font: inherit;
  padding: .65em .8em;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input[type="text"]:focus, input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
  position: relative;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(59,130,246,.18) 0%, rgba(59,130,246,0) 60%),
    linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
}
.login-wrap {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5em;
  width: 100%;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.2em 2em;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 1.6em;
}
.login-brand .logo {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 14px;
  margin-bottom: .8em;
}
.login-brand h1 { font-size: 1.25em; margin: 0; }
.login-brand p { margin: .25em 0 0; color: var(--muted); font-size: .9em; }

/* ============================================================
   APP (topbar + contenido)
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.topbar-inner {
  max-width: 1680px; margin: 0 auto;
  display: flex; align-items: center; gap: 1em;
  padding: .8em 1.5em;
}
.brand { display: flex; align-items: center; gap: .6em; font-weight: 700; }
.brand .logo {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 9px;
}
.topbar-spacer { flex: 1; }
.topbar-nav { display: flex; align-items: center; gap: .3em; }
.topbar-nav a {
  color: var(--muted); font-weight: 600; font-size: .92em;
  padding: .45em .7em; border-radius: var(--radius-sm);
}
.topbar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar-nav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar-nav a.danger { color: var(--danger); }
.topbar-nav a.danger:hover { background: var(--danger-bg); }
.chip-user {
  display: inline-flex; align-items: center; gap: .5em;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-weight: 600; font-size: .88em;
  padding: .35em .7em; border-radius: 999px;
}
.chip-user .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: .72em; font-weight: 700;
}

.app { width: 100%; max-width: 1680px; margin: 0 auto; padding: 1.6em 1.5em 3em; }
.page-title { font-size: 1.35em; margin: 0 0 1.1em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Toolbar (subida + carpeta) ---------- */
.toolbar {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1em;
  margin-bottom: 1.3em;
}
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1.2em;
  display: flex; align-items: center; gap: 1em;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone .dz-icon {
  flex: none; width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--primary); background: var(--primary-soft); border-radius: 10px;
}
.dropzone .dz-text { flex: 1; min-width: 0; }
.dropzone .dz-text strong { display: block; }
.dropzone .dz-text span { color: var(--muted); font-size: .85em; }
.dropzone .dz-file { color: var(--text); font-weight: 600; font-size: .85em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.newfolder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2em;
  display: flex; flex-direction: column; gap: .7em;
}
.newfolder .row { display: flex; gap: .5em; }
.newfolder .row input { flex: 1; }

/* ---------- Progreso de subida ---------- */
.upload-status { margin-top: 1em; }
.upload-status .phase { font-weight: 600; font-size: .9em; margin-bottom: .4em; }
.upload-status .sub { color: var(--muted); font-size: .85em; margin-top: .4em; }
progress {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 10px; border: none; border-radius: 999px;
  background: var(--accent, rgba(255,255,255,.08)); overflow: hidden;
}
progress::-webkit-progress-bar { background: rgba(255,255,255,.08); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
progress.indeterminate {
  position: relative; background: rgba(255,255,255,.08);
}
progress.indeterminate::-webkit-progress-value { background: transparent; }
progress.indeterminate::before {
  content: ''; position: absolute; top: 0; left: -40%;
  width: 40%; height: 100%; background: var(--primary); border-radius: 999px;
  animation: indeterminate 1.2s infinite;
}
@keyframes indeterminate {
  0% { left: -40%; } 50% { left: 40%; } 100% { left: 100%; }
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  display: flex; flex-wrap: wrap; align-items: center; gap: .2em;
  font-size: .92em; margin-bottom: 1em; color: var(--muted);
}
.breadcrumb a { color: var(--muted); padding: .2em .45em; border-radius: 6px; }
.breadcrumb a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.breadcrumb .sep { color: var(--border-strong); }
.breadcrumb .current { color: var(--text); font-weight: 600; padding: .2em .45em; }

/* ---------- Tabla de archivos ---------- */
.table-wrap { overflow-x: auto; }
table.filetable { width: 100%; border-collapse: collapse; }
.filetable thead th {
  text-align: left; font-size: .78em; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
  padding: .85em 1em; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.filetable thead th.sortable { cursor: pointer; user-select: none; }
.filetable thead th.sortable:hover { color: var(--text); }
.filetable thead th .arrow { opacity: .35; font-size: .9em; margin-left: .3em; }
.filetable thead th[aria-sort="ascending"] .arrow,
.filetable thead th[aria-sort="descending"] .arrow { opacity: 1; color: var(--primary); }
.filetable tbody td { padding: .7em 1em; border-bottom: 1px solid var(--border); vertical-align: middle; }
.filetable tbody tr:last-child td { border-bottom: none; }
.filetable tbody tr:hover { background: var(--surface-2); }
.filetable td.col-actions { text-align: right; white-space: nowrap; }

.name-cell { display: flex; align-items: center; gap: .7em; min-width: 0; }
.name-cell .fileicon { flex: none; width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center; }
.name-cell .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.name-cell a.fname:hover { color: var(--primary); text-decoration: underline; }

/* colores por tipo */
.ic-folder { background: rgba(59,130,246,.16);  color: #60a5fa; }
.ic-image  { background: rgba(34,197,94,.16);   color: #4ade80; }
.ic-video  { background: rgba(244,63,94,.16);   color: #fb7185; }
.ic-audio  { background: rgba(124,58,237,.18);  color: #a78bfa; }
.ic-pdf    { background: rgba(239,68,68,.16);   color: #f87171; }
.ic-archive{ background: rgba(217,119,6,.18);   color: #fbbf24; }
.ic-code   { background: rgba(99,102,241,.18);  color: #818cf8; }
.ic-doc    { background: rgba(37,99,235,.16);   color: #60a5fa; }
.ic-file   { background: rgba(148,163,184,.16); color: #cbd5e1; }

.muted { color: var(--muted); }

/* botones de acción por fila */
.iconbtn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.iconbtn:hover { background: var(--surface); border-color: var(--border); color: var(--text); text-decoration: none; }
.iconbtn.danger:hover { color: var(--danger); border-color: var(--danger-bd); background: var(--danger-bg); }
.iconbtn svg { width: 17px; height: 17px; }

.empty {
  text-align: center; color: var(--muted); padding: 3em 1em;
}
.empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: .5em; }

/* ---------- Alertas ---------- */
.alert {
  display: flex; align-items: center; gap: .6em;
  padding: .75em 1em; border-radius: var(--radius-sm);
  margin-bottom: 1.1em; font-weight: 500; border: 1px solid transparent;
}
.alert svg { flex: none; width: 18px; height: 18px; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-bd); }

/* ---------- Gestión de usuarios ---------- */
.stack { display: flex; flex-direction: column; gap: 1.3em; }
.card-pad { padding: 1.3em 1.4em; }
.card-pad h2 { margin: 0 0 1em; font-size: 1.05em; }
.usertable { width: 100%; border-collapse: collapse; }
.usertable th, .usertable td { text-align: left; padding: .7em 1em; border-bottom: 1px solid var(--border); }
.usertable th { font-size: .78em; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.usertable td.right { text-align: right; }
.form-inline-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: .8em; align-items: end; }

/* ---------- Responsive ---------- */
@media (max-width: 780px) {
  .toolbar { grid-template-columns: 1fr; }
  .form-inline-grid { grid-template-columns: 1fr; }
  .topbar-nav a span.label { display: none; }
  .filetable thead th.col-date, .filetable td.col-date { display: none; }
}
@media (max-width: 520px) {
  .app { padding: 1em 1em 2.5em; }
  .filetable thead th.col-size, .filetable td.col-size { display: none; }
  .chip-user .uname { display: none; }
}

/* fila de checkbox (config) */
.check-row { display: flex; align-items: center; gap: .6em; margin-bottom: 1.1em; font-weight: 600; }
.check-row input { width: auto; }

/* utilidades */
.inline { display: inline; }
.no-m { margin: 0 !important; }
.breadcrumb a svg { vertical-align: -2px; }

.appfoot {
  margin-top: auto;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px;
  font-size: .8em; color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.appfoot .foot-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); flex: 0 0 auto; }
.appfoot strong { color: var(--text); font-weight: 600; }
