/* ========= Design tokens ========= */
:root{
  --bg: #0e1320;
  --panel: #141a2a;
  --panel-2: #0f1526;
  --border: #252c41;
  --text: #eaf0ff;
  --muted: #a7b0c6;

  --brand: #5b8cff;
  --brand-2:#7aa5ff;
  --ok: #3ecf8e;
  --warn:#ffcc66;
  --danger:#ff5d5d;

  --shadow: 0 10px 24px rgba(0,0,0,.35);
  --radius: 14px;
}

/* ========= Base ========= */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(91,140,255,.15), transparent 60%),
    radial-gradient(900px 500px at 120% 10%, rgba(62,207,142,.12), transparent 60%),
    var(--bg);
}

/* ========= Topbar ========= */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 22px; border-bottom:1px solid var(--border);
  backdrop-filter: blur(6px);
  background: linear-gradient(180deg, rgba(20,26,42,.9), rgba(20,26,42,.75));
  position:sticky; top:0; z-index:10;
}
.brand{ display:flex; align-items:center; gap:14px; }
.logo{ width:120px; height:120px; object-fit:contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.3)); }
.brand-text h1{ margin:0; font-size:18px; font-weight:700; letter-spacing:.2px; }
.brand-text p{ margin:2px 0 0; color:var(--muted); font-size:12px; }
.chip{ background: linear-gradient(90deg, var(--brand), var(--brand-2)); color:#071023; padding:2px 8px; border-radius:999px; font-weight:700; }

/* ========= Tabs ========= */
.tabs{ display:flex; gap:8px; }
.tab-btn{
  background: transparent; color:var(--text);
  border:1px solid var(--border); padding:10px 14px;
  border-radius:10px; cursor:pointer; transition: all .2s ease;
  box-shadow: inset 0 -2px 0 rgba(255,255,255,.03);
}
.tab-btn:hover{ border-color:#324063; transform: translateY(-1px); }
.tab-btn.active{ background: linear-gradient(180deg, #1a2240, #121a34); border-color:#3c4b74; box-shadow: var(--shadow); }

/* ========= Layout ========= */
.page{ max-width:1200px; margin:24px auto; padding:0 16px; }
.tab{ display:none; }
.tab.active{ display:block; }
.pane{ display:grid; grid-template-columns: 280px 1fr; gap:18px; }
@media (max-width: 980px){
  .pane{ grid-template-columns: 1fr; }
}

/* ========= Cards / Panels ========= */
.card{
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border:1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px; border-bottom:1px solid var(--border);
  gap:14px; flex-wrap:wrap;
}
.card h3{ margin:0; font-size:16px; }
.card .muted{ color:var(--muted); margin:4px 0 0; font-size:12px; }
.content .card{ overflow:hidden; }
.table-wrap{ padding:10px 12px 16px; overflow:auto; max-height:60vh; position:relative; }

/* ========= Sidebar ========= */
.sidebar{ height:100%; overflow:hidden; display:flex; flex-direction:column; }
.sidebar-head{ padding:14px 16px; border-bottom:1px solid var(--border); display:grid; gap:10px; }
.list{ list-style:none; margin:0; padding:6px 0 10px; overflow:auto; max-height:60vh; }
.bucket-item{ padding:10px 14px; border-bottom:1px dashed #29314a; }
.bucket-item:hover{ background:#11182c; }
.list-select{
  background: transparent; color:var(--text); border:0; padding:10px;
  outline:none; height:60vh;
}
.list-select option{ padding:8px 10px; }

/* ========= Breadcrumb ========= */
.breadcrumb{ color:var(--muted); font-size:13px; display:flex; gap:4px; align-items:center; flex-wrap:wrap; }
.breadcrumb .crumb{ color:var(--text); }
.breadcrumb .crumb:hover{ text-decoration:underline; cursor:pointer; }

/* ========= Buttons / inputs ========= */
.input{
  background:#0c1120; color:var(--text);
  border:1px solid var(--border); border-radius:10px;
  padding:10px 12px; outline:none; min-width:240px;
}
.input:focus{ border-color:#3c4b74; box-shadow:0 0 0 2px rgba(91,140,255,.15); }

.actions{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }

.btn{
  background: linear-gradient(180deg, #2a3a7a, #1b2754);
  color:#fff; border:1px solid #314072; border-radius:12px;
  padding:10px 14px; cursor:pointer; transition: all .15s ease; font-weight:600;
  box-shadow: 0 6px 16px rgba(91,140,255,.25), inset 0 1px 0 rgba(255,255,255,.06);
}
.btn:hover{ transform: translateY(-1px); box-shadow: 0 10px 24px rgba(91,140,255,.28), inset 0 1px 0 rgba(255,255,255,.08); }
.btn:active{ transform: translateY(0); }

.btn.ghost{ background: transparent; border-color:#344165; }
.btn.ghost:hover{ background:#121a34; }

.btn.outline{ background: transparent; border-color:#3c4b74; }
.btn.outline:hover{ background:#121a34; }

.btn.danger{
  background: linear-gradient(180deg, #882e3a, #5b1a22);
  border-color:#8b3946; box-shadow: 0 6px 16px rgba(255,93,93,.25), inset 0 1px 0 rgba(255,255,255,.06);
}
.btn.danger:hover{ box-shadow: 0 10px 24px rgba(255,93,93,.30), inset 0 1px 0 rgba(255,255,255,.08); }

.pager{ display:flex; align-items:center; gap:10px; }
.pager-info{ color:var(--muted); min-width:64px; text-align:center; }

/* ========= Storage table ========= */
.storage-table{ width:100%; border-collapse: collapse; font-size:13px; }
.storage-table thead th{
  text-align:left; position:sticky; top:0; z-index:1;
  background:#0f162b; border-bottom:1px solid var(--border);
  padding:10px 8px; font-weight:700; letter-spacing:.2px;
}
.storage-table tbody td{
  padding:9px 8px; border-bottom:1px solid #1f2740; white-space:nowrap;
}
.storage-table tbody tr:hover{ background:#11182c; }
.cell-check{ width:36px; }
.cell-name{ display:flex; align-items:center; gap:8px; }
.cell-size, .cell-updated{ color:var(--muted); }

/* linhas tipadas (diretório/arquivo) */
.row.dir .cell-name{ font-weight:600; }
.row.file .cell-name{ font-weight:500; }

/* ícones (injetados no HTML como <span class="icon folder|file">) */
.icon{ display:inline-flex; width:18px; height:18px; align-items:center; justify-content:center; }
.icon::before{ font-size:16px; line-height:1; }
.icon.folder::before{ content:"📁"; }
.icon.file::before{ content:"📄"; }

/* ========= DB tables ========= */
table{ width:100%; border-collapse: collapse; font-size:13px; }
thead th{
  text-align:left; position:sticky; top:0; z-index:1;
  background:#0f162b; border-bottom:1px solid var(--border);
  padding:10px 8px; font-weight:700; letter-spacing:.2px;
}
tbody td{ padding:9px 8px; border-bottom:1px solid #1f2740; white-space:nowrap; }
tbody tr:hover{ background:#11182c; }

/* ========= Sticky action bars ========= */
.actions-top {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  position: sticky;
  top: 0;
  z-index: 5;
}
.actions-bottom {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  position: sticky;
  bottom: 0;
  z-index: 5;
}

/* ===== Importar planilha ===== */
.actions-import {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin-bottom: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}
.input-file {
  background: transparent; color: #eaf0ff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px; padding: 8px 10px; font-size: 14px; cursor: pointer;
}
.actions-import .btn { box-shadow: 0 10px 24px rgba(53, 99, 255, 0.25); }

/* ========= Footer ========= */
.footer{
  max-width:1200px; margin:20px auto 60px; padding:0 16px;
  color:var(--muted); font-size:12px; text-align:center;
}

/* ========= Busy overlay ========= */
#busyOverlay{
  position: fixed; inset: 0; display:none;
  background: rgba(7, 12, 25, .45); backdrop-filter: blur(2px);
  align-items: center; justify-content: center;
  z-index: 9999;
}
#busyBox{
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border:1px solid var(--border); border-radius:12px; padding:14px 18px;
  box-shadow: var(--shadow); display:flex; align-items:center; gap:12px;
}
#busyDot{
  width:10px; height:10px; border-radius:50%; background: var(--brand);
  box-shadow: 0 0 0 0 rgba(91,140,255,.6);
  animation: pulse 1.4s infinite;
}
#busyText{ color:var(--text); font-weight:600; }
@keyframes pulse{
  0%{ box-shadow: 0 0 0 0 rgba(91,140,255,.6); }
  70%{ box-shadow: 0 0 0 12px rgba(91,140,255,0); }
  100%{ box-shadow: 0 0 0 0 rgba(91,140,255,0); }
}

/* ========= Scrollbar sutil ========= */
.table-wrap::-webkit-scrollbar,
.list::-webkit-scrollbar{ height:10px; width:10px; }
.table-wrap::-webkit-scrollbar-thumb,
.list::-webkit-scrollbar-thumb{ background:#1f2740; border-radius:10px; }

/* ====== Melhorar visual do botão de upload de planilha ====== */
input[type="file"] {
  color: transparent; /* oculta o nome do arquivo */
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.875rem;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

.file-label:hover {
  background: linear-gradient(135deg, #334155, #1e293b);
  color: #fff;
  border-color: #475569;
}

.file-label:active {
  transform: scale(0.97);
}

/* Ícone (opcional) */
.file-label .icon-upload {
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml,%3Csvg fill='none' stroke='%23a5f3fc' stroke-width='2' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M4 16v2a2 2 0 002 2h12a2 2 0 002-2v-2M7 10l5-5m0 0l5 5m-5-5v12'/%3E%3C/svg%3E") center/contain no-repeat;
}
/* Abas: garanta que o atributo hidden realmente oculte */
.tab[hidden] { display: none !important; }

/* Acessibilidade/teclado nos botões de aba */
.tabs .tab-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Evitar que a barra superior bloqueie cliques nas abas em alguns browsers */
.tabs { position: relative; z-index: 1; }

/* Em telas muito pequenas, melhora o grid da área principal */
@media (max-width: 640px){
  .table-wrap { max-height: 50vh; }
}

/* ======== Corrige o cursor da navegação no Storage ======== */
.cell-name,
.cell-name .icon,
.breadcrumb .crumb {
  cursor: pointer;
}

/* Opcional: feedback visual ao passar o mouse */
.cell-name:hover,
.breadcrumb .crumb:hover {
  text-decoration: underline;
  color: var(--brand-2);
}
/* ======== Impede o cursor de texto e seleção nas pastas ======== */
.cell-name,
.cell-name *,
.breadcrumb .crumb {
  user-select: none;          /* bloqueia seleção de texto */
  caret-color: transparent;   /* esconde a barrinha de texto piscante */
}
/* Reforço cross-browser de não seleção */
.cell-name,
.cell-name * {
  -webkit-user-select: none; /* Safari/Chrome iOS */
  -moz-user-select: none;    /* Firefox */
  -ms-user-select: none;     /* Edge antigo */
  user-select: none;
}

/* Opcional: desativa callout/seleção no mobile */
.cell-name,
.cell-name * {
  -webkit-touch-callout: none;
}

/* (Opcional) Se a “I-beam” aparecer fora do texto, no TD inteiro: */
.storage-table tbody td { 
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  caret-color: transparent;
}

/* E garante que inputs/áreas de texto continuem normais */
input, textarea, select { 
  user-select: text !important; 
  caret-color: auto !important; 
}
/* Faz a área de clique ocupar o TD inteiro */
.cell-name { width: 100%; }
