/* FluxForge Vault — Mobile-first (~393px) */

:root {
  --bg: #0a0e14;
  --panel: #11161d;
  --panel-2: #1a212b;
  --border: #2a3441;
  --border-2: #3a4451;
  --text: #e6e8eb;
  --muted: #8b96a5;
  --accent: #f0a020;
  --accent-2: #50fa7b;
  --danger: #ff5555;
  --info: #6cb7ff;
  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  --serif: 'Newsreader', Georgia, serif;
  --radius: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

/* Force the HTML `hidden` attribute to win against display:flex etc. */
[hidden] { display: none !important; }


html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-image:
    radial-gradient(circle at 20% 0%, rgba(240, 160, 32, 0.06), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(80, 250, 123, 0.04), transparent 50%);
  padding-bottom: 6rem;
}

.muted { color: var(--muted); }
.msg { padding: 0.75rem; border-radius: var(--radius); margin-top: 1rem; font-size: 0.85rem; }
.msg.ok { background: rgba(80,250,123,0.1); border: 1px solid rgba(80,250,123,0.3); color: var(--accent-2); }
.msg.err { background: rgba(255,85,85,0.1); border: 1px solid rgba(255,85,85,0.3); color: var(--danger); }

button { font: inherit; cursor: pointer; }
input, select, textarea {
  width: 100%;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 160, 32, 0.15);
}

/* TOP BAR */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--serif);
  font-size: 1.1rem;
}
.topbar .brand i { color: var(--accent); }
.topbar .brand em { color: var(--accent); font-style: normal; font-weight: 500; margin-left: 0.2rem; }
.topbar-actions { display: flex; gap: 0.25rem; }

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* LOGIN */
.view-login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  max-width: 380px;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
.login-logo {
  font-size: 2rem;
  color: var(--accent);
  text-align: center;
  margin-bottom: 0.5rem;
}
.login-card h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.75rem;
  text-align: center;
  margin: 0;
}
.login-card h1 span { color: var(--accent); }
.login-card p { text-align: center; font-size: 0.85rem; margin: 0.25rem 0 1.5rem; }
.login-card label { display: block; font-size: 0.75rem; color: var(--muted); margin: 0.75rem 0 0.4rem; text-transform: uppercase; letter-spacing: 0.08em; }
.login-footer { text-align: center; margin-top: 1.5rem; font-size: 0.7rem; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 0.85rem 1rem;
  margin-top: 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.1s, background 0.2s;
}
.btn-primary:hover { background: #ffb830; }
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
}
.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
}

/* TOOLBAR */
.toolbar {
  padding: 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 40;
}
.search-wrap {
  position: relative;
}
.search-wrap i {
  position: absolute;
  left: 0.85rem; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-wrap input { padding-left: 2.4rem; }

.cat-strip {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
}
.cat-strip::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.78rem;
  white-space: nowrap;
  transition: all 0.15s;
}
.cat-chip:hover { color: var(--text); }
.cat-chip.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}
.cat-chip i { margin-right: 0.4rem; }

/* DOC LIST */
.doc-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.doc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  transition: border-color 0.15s, transform 0.1s;
  cursor: pointer;
}
.doc-card:hover { border-color: var(--accent); }
.doc-card:active { transform: scale(0.99); }
.doc-icon {
  width: 40px; height: 40px;
  flex-shrink: 0;
  background: var(--panel-2);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 1.1rem;
}
.doc-meta { flex: 1; min-width: 0; }
.doc-name {
  font-weight: 600;
  font-size: 0.88rem;
  margin: 0 0 0.25rem;
  word-break: break-word;
  line-height: 1.3;
}
.doc-sub {
  font-size: 0.72rem;
  color: var(--muted);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.doc-sub .pill {
  background: var(--panel-2);
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.65rem;
}
.doc-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--muted);
}
.doc-empty i { font-size: 2.5rem; margin-bottom: 1rem; color: var(--border-2); }

/* FAB */
.fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  border: none;
  box-shadow: var(--shadow);
  font-size: 1.4rem;
  z-index: 30;
  transition: transform 0.15s;
}
.fab:hover { transform: scale(1.08); }
.fab:active { transform: scale(0.95); }

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: var(--panel);
  border-top: 2px solid var(--accent);
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 1.25rem;
  border-radius: 12px 12px 0 0;
  animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(20px); } to { transform: translateY(0); } }
.modal-card-lg { max-width: 800px; }
.modal-card header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.modal-card h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.15rem;
  margin: 0;
}
.modal-card h3 i { color: var(--accent); margin-right: 0.4rem; }
.modal-card label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin: 0.85rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.form-actions {
  display: flex; gap: 0.5rem; margin-top: 1.25rem;
}
.form-actions button { flex: 1; }

/* DOC BODY (detail view) */
.doc-body { font-size: 0.85rem; }
.doc-body .meta-row {
  display: flex; justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
}
.doc-body .meta-row span:first-child { color: var(--muted); }
.doc-body .actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin: 1rem 0;
}
.doc-body .actions button { flex: 1 1 auto; min-width: 110px; }
.share-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: var(--radius);
  margin-top: 0.5rem;
  font-size: 0.75rem;
}
.share-url {
  display: flex; gap: 0.4rem; margin-top: 0.4rem;
}
.share-url input { font-size: 0.7rem; }

/* ADMIN TABS */
.tabs { display: flex; gap: 0.4rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.6rem 1rem;
  border-bottom: 2px solid transparent;
  font-size: 0.85rem;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.user-row, .audit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
}
.user-row .info { display: flex; flex-direction: column; gap: 0.15rem; }
.user-row .info b { font-size: 0.85rem; }
.user-row select { width: auto; padding: 0.3rem 0.5rem; font-size: 0.78rem; }
.audit-row { font-family: var(--mono); font-size: 0.72rem; }
.audit-row .action-tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--accent-2);
  margin-right: 0.4rem;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  z-index: 200;
  animation: toastIn 0.2s ease-out;
}
.toast.err { border-color: var(--danger); color: var(--danger); }
@keyframes toastIn { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* TABLET+ */
@media (min-width: 768px) {
  body { font-size: 15px; }
  .doc-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
  }
  .toolbar { padding: 1.25rem 1.5rem; }
  .modal { align-items: center; }
  .modal-card { border-radius: 12px; max-height: 85vh; }
  .topbar { padding: 1rem 1.5rem; }
}

@media (min-width: 1024px) {
  .doc-list { grid-template-columns: repeat(3, 1fr); }
}