/* ============================================================
   Gestor de Archivos — Tema "Azul profesional, claro"
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f2;
  --border-strong: #d3dae7;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;
  --text: #1e293b;
  --muted: #64748b;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-bd: #a7f3d0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-bd: #fecaca;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .09), 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
  --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: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5em;
  position: relative;
  background:
    radial-gradient(1200px 500px at 50% -10%, #e7eeff 0%, rgba(231,238,255,0) 60%),
    var(--bg);
}
.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: 1120px; 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.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 { max-width: 1120px; 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, #e6ebf5); overflow: hidden;
}
progress::-webkit-progress-bar { background: #e6ebf5; 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: #e6ebf5;
}
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: #eef4ff; color: #2563eb; }
.ic-image  { background: #ecfdf5; color: #059669; }
.ic-video  { background: #fef3f2; color: #e11d48; }
.ic-audio  { background: #f5f3ff; color: #7c3aed; }
.ic-pdf    { background: #fef2f2; color: #dc2626; }
.ic-archive{ background: #fffbeb; color: #d97706; }
.ic-code   { background: #eef2ff; color: #4f46e5; }
.ic-doc    { background: #eff6ff; color: #2563eb; }
.ic-file   { background: #f1f5f9; color: #64748b; }

.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; }
}

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

.appfoot { max-width: 1120px; margin: 2.5em auto 0; padding: 0 1.5em 1em; color: var(--muted); font-size: .82em; text-align: center; }


/* Footer / Status bar fixed at bottom */
.status-bar {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 32px !important;
  background: #1e293b !important;
  color: #94a3b8 !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 16px !important;
  font-size: 12px !important;
  border-top: 1px solid #334155 !important;
  z-index: 99999 !important;
  gap: 20px !important;
  box-sizing: border-box !important;
}

.status-bar .status-item {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
}

.status-bar .status-dot {
  width: 8px !important;
  height: 8px !important;
  border-radius: 50% !important;
  background: #22c55e !important;
}

.status-bar .status-dot.offline {
  background: #ef4444 !important;
}

.status-bar strong {
  color: #f8fafc !important;
}

/* holgura para status-bar fija (32px) - padding-bottom para status-bar */
.app{padding-bottom:56px;}
.login-page{padding-bottom:56px;}
