* { box-sizing: border-box; }
:root {
  --bg: #0d0d12;
  --bg-card: #14141c;
  --bg-card-hover: #1a1a24;
  --border: #26262f;
  --text: #f2f2f3;
  --text-dim: #a9a9b3;
  --text-faint: #6b6b76;
  --accent: #a855f7;
  --accent-dim: #7c3aed;
  --accent-bg: #26163a;
  --accent-text: #d5b4ff;
  --radius: 14px;
  --radius-sm: 9px;
}
body {
  margin: 0;
  font-family: -apple-system, 'Segoe UI', Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input { font-family: inherit; }

.btn {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-primary { background: linear-gradient(135deg, var(--accent-dim), var(--accent)); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg-card-hover); }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); }
.btn-icon { background: transparent; border: none; color: var(--text-faint); cursor: pointer; padding: 6px; border-radius: 8px; display: flex; }
.btn-icon:hover { color: #ff6b6b; background: var(--bg-card-hover); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 10px; font-size: 13px; }

/* ---------- LOGIN ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; }
.login-brand { text-align: center; margin-bottom: 30px; }
.login-icon { font-size: 40px; }
.login-brand h1 { font-size: 28px; margin: 12px 0 4px; letter-spacing: -0.5px; }
.login-brand .accent { color: var(--accent); font-weight: 700; }
.login-sub { color: var(--text-faint); margin: 0; font-size: 14px; }
.login-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px; width: 100%; max-width: 380px; text-align: center; }
.login-lock { width: 46px; height: 46px; border-radius: 50%; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; font-size: 18px; }
.login-box h2 { margin: 0 0 6px; font-size: 18px; }
.login-hint { color: var(--text-faint); font-size: 13px; margin: 0 0 20px; }
.login-field { position: relative; margin-bottom: 16px; }
.login-field input { width: 100%; padding: 12px 40px 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #0a0a0e; color: #fff; font-size: 14px; }
.login-field input:focus { outline: none; border-color: var(--accent-dim); }
.toggle-eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--text-faint); }
.login-error { color: #e05555; font-size: 13px; margin-top: 10px; min-height: 16px; }
.login-footer { margin-top: 20px; color: var(--text-faint); font-size: 12px; }
.login-status { font-size: 13px; margin-top: 8px; min-height: 16px; }
.login-status.error { color: #e05555; }
.login-status.success { color: #4caf50; }

/* ---------- SHELL / SIDEBAR ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 270px; flex-shrink: 0; border-right: 1px solid var(--border); padding: 22px 16px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; font-weight: 700; font-size: 16px; }
.brand-icon { font-size: 18px; }

.nav-main { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; text-align: left; width: 100%; }
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: var(--bg-card-hover); color: var(--text); }
.nav-item.is-active { background: var(--accent-bg); color: var(--accent-text); }

.nav-section-label { color: var(--text-faint); font-size: 12px; padding: 14px 12px 6px; }

.nav-folders { display: flex; flex-direction: column; gap: 1px; max-height: 280px; overflow-y: auto; margin-bottom: 6px; }
.folder-nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; text-align: left; width: 100%; }
.folder-nav-item:hover { background: var(--bg-card-hover); color: var(--text); }
.folder-nav-item.is-active { background: var(--accent-bg); color: var(--accent-text); }
.folder-nav-item svg { flex-shrink: 0; opacity: 0.85; }

.btn-add-folder { margin: 6px 4px 18px; background: none; border: 1px dashed var(--border); color: var(--text-faint); border-radius: 9px; padding: 9px 12px; font-size: 13px; cursor: pointer; text-align: left; }
.btn-add-folder:hover { color: var(--accent-text); border-color: var(--accent-dim); }

.storage-box { margin-top: auto; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 10px; }
.storage-label { font-size: 12px; color: var(--text-faint); margin-bottom: 6px; }
.storage-value { font-size: 15px; font-weight: 600; color: var(--accent-text); }
.storage-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.btn-logout { background: none; border: none; color: var(--text-faint); font-size: 13px; cursor: pointer; text-align: left; padding: 8px 12px; }
.btn-logout:hover { color: #ff6b6b; }

/* ---------- MAIN ---------- */
.main { flex: 1; padding: 26px 34px; overflow-x: hidden; }

.topbar { margin-bottom: 26px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.search-box { flex: 1; max-width: 760px; display: flex; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.search-box svg { color: var(--text-faint); flex-shrink: 0; }
.search-box input { flex: 1; background: none; border: none; color: var(--text); font-size: 14px; }
.search-box input:focus { outline: none; }
.search-box input::placeholder { color: var(--text-faint); }
.avatar-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-faint); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; overflow: hidden; padding: 0; }
.avatar-btn img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

.view-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.view-head h1 { font-size: 21px; margin: 0; font-weight: 700; }
.view-actions { display: flex; gap: 10px; }
.btn-back { display: flex; align-items: center; gap: 6px; background: none; border: none; color: var(--text-dim); font-size: 14px; cursor: pointer; padding: 0; margin-right: 4px; }
.btn-back:hover { color: var(--accent-text); }

/* folder cards (home) */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.folder-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; cursor: pointer; display: flex; align-items: flex-start; justify-content: space-between; transition: background 0.12s, border-color 0.12s; }
.folder-card:hover { background: var(--bg-card-hover); border-color: var(--accent-dim); }
.folder-card-left { display: flex; gap: 14px; align-items: flex-start; }
.folder-card-icon { color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.folder-card-name { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.folder-card-count { font-size: 12px; color: var(--text-faint); }
.folder-card-dots { flex-shrink: 0; }

/* recent files list */
.recent-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.recent-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-card); }
.recent-row:last-child { border-bottom: none; }
.recent-row:hover { background: var(--bg-card-hover); }
.recent-icon { width: 38px; height: 38px; border-radius: 8px; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; color: var(--accent-text); flex-shrink: 0; }
.recent-info { flex: 1; min-width: 0; }
.recent-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: 12px; color: var(--text-faint); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.recent-meta { display: flex; align-items: center; gap: 22px; flex-shrink: 0; color: var(--text-faint); font-size: 13px; }
.recent-meta .recent-size { min-width: 60px; text-align: right; }
.recent-meta .recent-date { min-width: 130px; text-align: right; }
.recent-actions { display: flex; gap: 4px; flex-shrink: 0; }
.recent-actions a { color: var(--text-faint); display: flex; }
.recent-actions a:hover { color: var(--accent-text); }

/* files grid */
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.file-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.file-card:hover { background: var(--bg-card-hover); }
.file-card-top { display: flex; align-items: center; gap: 10px; }
.file-icon { width: 36px; height: 36px; border-radius: 8px; background: var(--accent-bg); display: flex; align-items: center; justify-content: center; color: var(--accent-text); flex-shrink: 0; }
.file-ext-badge { font-size: 10px; font-weight: 700; letter-spacing: 0.4px; color: var(--accent-text); background: var(--accent-bg); padding: 2px 6px; border-radius: 5px; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13.5px; word-break: break-word; }
.file-size { font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.file-actions { display: flex; gap: 8px; }
.file-actions a { text-decoration: none; }

.file-thumb-wrap { width: 100%; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: #0a0a0e; border: 1px solid var(--border); }
.file-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-info-inline { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-faint); }

.upload-status { color: var(--accent-text); font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.empty-state { text-align: center; color: var(--text-faint); padding: 60px 20px; font-size: 14px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay[hidden] { display: none; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-faint); font-size: 16px; cursor: pointer; }
.modal-body { padding: 20px; }
.field-label { display: block; margin: 10px 0 6px; font-size: 13px; color: var(--text-dim); }
.modal-body input { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: #0a0a0e; color: #fff; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }

.profile-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.profile-avatar-preview { width: 60px; height: 60px; border-radius: 50%; background: var(--accent-bg); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--accent-text); flex-shrink: 0; font-size: 22px; }
.profile-avatar-preview img { width: 100%; height: 100%; object-fit: cover; }

/* cropper */
.crop-modal-canvas-wrap { display: flex; justify-content: center; margin: 6px 0 16px; }
#cropCanvas { border-radius: 50%; cursor: grab; background: #0a0a0e; touch-action: none; border: 2px solid var(--accent-dim); }
#cropCanvas:active { cursor: grabbing; }
.crop-hint { text-align: center; color: var(--text-faint); font-size: 12.5px; margin-bottom: 16px; line-height: 1.4; }
.crop-zoom-row { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.crop-zoom-icon { color: var(--text-faint); flex-shrink: 0; }
.crop-zoom-icon.small { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.crop-zoom-icon.big { width: 14px; height: 14px; border-radius: 50%; background: var(--text-faint); }
#zoomSlider { flex: 1; accent-color: var(--accent); }

.folder-card { cursor: grab; }
.folder-card.is-dragging { opacity: 0.4; }
.folder-card.is-drag-over { border-color: var(--accent); background: var(--accent-bg); }

.folder-card { cursor: grab; }
.folder-card.is-dragging { opacity: 0.4; }
.folder-card.is-drag-over { border-color: var(--accent); background: var(--accent-bg); }

.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb-item { background: none; border: none; color: var(--text-dim); font-size: 21px; font-weight: 700; cursor: pointer; padding: 2px 4px; }
.breadcrumb-item:hover:not(.is-current) { color: var(--accent-text); }
.breadcrumb-item.is-current { color: var(--text); cursor: default; }
.breadcrumb-sep { color: var(--text-faint); font-size: 16px; }

/* popups temáticos (substituem confirm/alert/prompt do navegador) */
.confirm-modal-body { text-align: center; padding: 4px 0 12px; }
.confirm-modal-icon { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; background: var(--accent-bg); color: var(--accent); }
.confirm-modal-icon.is-danger { background: rgba(239,68,68,0.15); color: #ef4444; }
.confirm-modal-message { color: var(--text); font-size: 15px; line-height: 1.5; margin: 0; }
.btn-danger { background: #ef4444; color: #fff; border: none; }
.btn-danger:hover { background: #dc2626; }

/* armazenamento em tempo real */
.storage-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; margin: 8px 0; }
.storage-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .5s ease; }
.storage-apps { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.storage-app-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-dim); }
.storage-app-row strong { color: var(--text); font-weight: 600; }

/* logo customizada */
.login-icon-img { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; margin: 0 auto 8px; display: block; }
.brand-icon-img { width: 24px; height: 24px; border-radius: 6px; object-fit: cover; }
#siteNameLabel { cursor: text; border-radius: 4px; padding: 2px 4px; }
#siteNameLabel:hover { background: rgba(255,255,255,0.06); }
#siteNameLabel[contenteditable="true"] { background: rgba(255,255,255,0.1); outline: 1px solid var(--accent); }

.login-icon-img, .brand-icon-img { border-radius: 50%; }
