/* ─────────────────────────────────────────────────────────────────────────
   ServerPepitos Hub – estilo Explorador de Windows 11
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --bg: #f3f3f3;
  --bg-panel: #ffffff;
  --bg-sidebar: #f9f9f9;
  --bg-toolbar: #fbfbfb;
  --bg-hover: rgba(0, 0, 0, 0.05);
  --bg-selected: #e5f1fb;
  --bg-selected-active: #cce4f7;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --text: #1f1f1f;
  --text-soft: #5f5f5f;
  --text-faint: #8a8a8a;
  --accent: #0067c0;
  --accent-hover: #005ba1;
  --danger: #c42b1c;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --radius: 6px;
  --radius-lg: 10px;
  --titlebar-h: 36px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202020;
    --bg-panel: #2b2b2b;
    --bg-sidebar: #252525;
    --bg-toolbar: #2b2b2b;
    --bg-hover: rgba(255, 255, 255, 0.06);
    --bg-selected: #1f3a5c;
    --bg-selected-active: #2a5183;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --text: #f0f0f0;
    --text-soft: #b8b8b8;
    --text-faint: #888;
    --accent: #4cc2ff;
    --accent-hover: #79d0ff;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  font-family: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* ─── TITLEBAR ─────────────────────────────────────────────────────────── */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--titlebar-h);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  user-select: none;
  -webkit-app-region: drag;
}
.titlebar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 12px;
  padding-left: 8px;
}
.titlebar-logo { color: var(--accent); }
.titlebar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}
.searchbar {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px 12px;
  width: min(420px, 90%);
  -webkit-app-region: no-drag;
}
.searchbar:focus-within {
  border-color: var(--accent);
  background: var(--bg-panel);
}
.searchbar svg { color: var(--text-faint); flex-shrink: 0; }
.searchbar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
}
.titlebar-right {
  display: flex;
  -webkit-app-region: no-drag;
}
.win-btn {
  width: 36px; height: var(--titlebar-h);
  border: none; background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 11px;
}
.win-btn:hover { background: var(--bg-hover); }
.win-btn.close:hover { background: #e81123; color: white; }

/* ─── LAYOUT ───────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  height: calc(100% - var(--titlebar-h));
}

/* ─── SIDEBAR ──────────────────────────────────────────────────────────── */
.sidebar {
  width: 260px;
  min-width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px 4px;
  flex-shrink: 0;
}
.sidebar-group {
  margin-bottom: 12px;
}
.sidebar-group-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
  padding: 6px 12px 4px;
  font-weight: 600;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  margin: 1px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  position: relative;
}
.sidebar-item:hover { background: var(--bg-hover); }
.sidebar-item.active {
  background: var(--bg-selected);
  font-weight: 600;
}
.sidebar-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.sidebar-item svg, .sidebar-item .emoji {
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.sidebar-item .name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── MAIN ─────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  min-width: 0;
}
.view {
  display: none;
  flex-direction: column;
  height: 100%;
}
.view.active { display: flex; }

/* ─── TOOLBAR (Explorador) ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
}
.tb-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.tb-btn:hover:not(:disabled) { background: var(--bg-hover); }
.tb-btn:disabled { opacity: 0.4; cursor: default; }
.tb-btn.danger:hover { color: var(--danger); }
.tb-btn svg { color: currentColor; }
.tb-sep {
  width: 1px; height: 18px;
  background: var(--border);
  margin: 0 6px;
}

/* ─── ADDRESS BAR / BREADCRUMB ─────────────────────────────────────────── */
.address-bar {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.breadcrumb {
  display: flex;
  align-items: center;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 13px;
  overflow-x: auto;
  white-space: nowrap;
}
.breadcrumb-item {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--text);
}
.breadcrumb-item:hover { background: var(--bg-hover); }
.breadcrumb-sep {
  color: var(--text-faint);
  margin: 0 2px;
}

/* ─── FILE LIST ────────────────────────────────────────────────────────── */
.file-area {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-panel);
}
.file-list-header,
.file-row {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) 1fr 1fr 100px;
  gap: 0;
  padding: 6px 12px;
  align-items: center;
  font-size: 13px;
}
.file-list-header {
  position: sticky; top: 0;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-soft);
  z-index: 1;
}
.file-row {
  cursor: pointer;
  border-bottom: 1px solid transparent;
  user-select: none;
}
.file-row:hover { background: var(--bg-hover); }
.file-row.selected { background: var(--bg-selected); }
.file-row.selected:hover { background: var(--bg-selected-active); }
.col-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.file-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-icon.folder { color: #dcb67a; }
.file-icon.img { color: #4caf50; }
.file-icon.doc { color: #2b579a; }
.file-icon.audio { color: #9c27b0; }
.file-icon.video { color: #e53935; }
.file-icon.code { color: #00bcd4; }
.file-icon.archive { color: #ff9800; }
.file-icon.pdf { color: #d32f2f; }
.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-date, .col-type {
  color: var(--text-soft);
  font-size: 12px;
}
.col-size {
  color: var(--text-soft);
  font-size: 12px;
  text-align: right;
}

/* Vista iconos */
.file-list.icons-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  padding: 12px;
}
.file-list.icons-view .file-list-header { display: none; }
.file-list.icons-view .file-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius);
  text-align: center;
}
.file-list.icons-view .col-name {
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.file-list.icons-view .file-icon {
  width: 48px; height: 48px;
}
.file-list.icons-view .file-icon svg { width: 48px; height: 48px; }
.file-list.icons-view .col-date,
.file-list.icons-view .col-type,
.file-list.icons-view .col-size { display: none; }
.file-list.icons-view .file-name {
  font-size: 12px;
  word-break: break-word;
  white-space: normal;
  text-align: center;
  line-height: 1.3;
}

/* ─── STATUSBAR ────────────────────────────────────────────────────────── */
.statusbar {
  padding: 4px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-toolbar);
  font-size: 12px;
  color: var(--text-soft);
}

/* ─── APP VIEW ─────────────────────────────────────────────────────────── */
.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
}
#app-title {
  font-weight: 600;
  font-size: 13px;
}
.app-actions { display: flex; gap: 4px; }
#app-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: white;
}

/* ─── SETTINGS ─────────────────────────────────────────────────────────── */
#view-settings {
  overflow-y: auto;
  padding: 24px 32px;
}
.settings-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 4px;
}
.settings-header p {
  color: var(--text-soft);
  margin: 0 0 24px;
}
.settings-section {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.settings-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.settings-section-head h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}
.hint {
  font-size: 12px;
  color: var(--text-soft);
  margin: 0 0 12px;
  line-height: 1.5;
}
.hint code {
  background: var(--bg-panel);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}
.config-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 8px;
  padding: 8px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  align-items: center;
}
.config-row input {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  width: 100%;
}
.config-row input:focus { border-color: var(--accent); outline: none; }
.config-row .row-delete {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 18px;
  padding: 4px 8px;
}
.config-row .row-delete:hover { color: var(--danger); }
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.big { padding: 10px 24px; font-size: 14px; }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 7px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.btn-secondary:hover { background: var(--bg-hover); }
.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}
#save-status {
  color: #2e7d32;
  font-size: 13px;
}

/* ─── MODAL ────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  min-width: 360px;
  max-width: 500px;
  box-shadow: var(--shadow-md);
}
.modal-head {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}
.modal-body {
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text);
}
.modal-body input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-panel);
}
.modal-body input:focus { border-color: var(--accent); outline: none; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Scrollbars finos (Windows 11-ish) ───────────────────────────────── */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: transparent;
  border: 3px solid transparent;
  border-radius: 6px;
  background-clip: padding-box;
}
*:hover::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
  background-clip: padding-box;
}

/* ── Click derecho menú contextual nativo ───────────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 4px;
  z-index: 2000;
  min-width: 200px;
  user-select: none;
}
.ctx-menu[hidden] { display: none; }
.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  border-radius: 4px;
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-icon { width: 16px; text-align: center; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Fullscreen de la app (oculta sidebar) ─────────────────────────── */
.layout.app-fullscreen .sidebar { display: none; }
.layout.app-fullscreen .titlebar-center,
.layout.app-fullscreen .titlebar-right { opacity: 0.3; }

/* ── Dashboard de métricas ────────────────────────────────────────── */
#view-dashboard { overflow-y: auto; padding: 32px; }
.dashboard h1 { font-size: 28px; font-weight: 600; margin: 0 0 24px; color: var(--text); }
.dashboard h2 { font-size: 18px; font-weight: 600; margin: 32px 0 12px; color: var(--text); }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.metric-card {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}
.metric-title {
  font-size: 13px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 12px;
}
.metric-sub {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 8px;
}
.gauge {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0%, var(--bg-panel) 0%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gauge::before {
  content: "";
  position: absolute;
  inset: 12px;
  background: var(--bg-sidebar);
  border-radius: 50%;
}
.gauge-text {
  position: relative;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.big-number {
  font-size: 32px;
  font-weight: 600;
  color: var(--accent);
  margin: 18px 0;
}
.disk-bar {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
}
.disk-bar-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}
.disk-bar-bar {
  background: var(--bg-panel);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.disk-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s;
}
.disk-bar-fill.warn { background: #ed9e26; }
.disk-bar-fill.danger { background: var(--danger); }

/* ── Shares ───────────────────────────────────────────────────────── */
.share-row {
  display: grid;
  grid-template-columns: 1fr 140px 100px 100px;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg-sidebar);
  align-items: center;
  font-size: 13px;
}
.share-row.expired { opacity: 0.5; }
.share-row .share-url {
  font-family: monospace;
  font-size: 11px;
  color: var(--accent);
  word-break: break-all;
}
.share-row a { color: var(--accent); text-decoration: none; }
.share-row a:hover { text-decoration: underline; }
.btn-copy {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text);
}
.btn-copy:hover { background: var(--bg-hover); }

/* App embebida ocupa todo el alto */
#view-app { height: 100%; }
.titlebar-right { gap: 0; }

