/* ===========================
   Invantia — Core Theme
   =========================== */

:root {
  --bg: #0b0b0d;
  --bg-elev: #141418;
  --text: #e7e7ee;
  --muted: #a4a4b0;
  --accent: #7c6cff;      /* logo violet */
  --accent-2: #8f7cff;
  --border: #2a2a33;
  --danger: #ff5d5d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Apple Color Emoji","Segoe UI Emoji";
}

/* ===========================
   Topbar
   =========================== */
.topbar {
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #0d0d12, #0a0a0c 60%);
  position: sticky; top: 0; z-index: 50;
}

.hamburger { 
  background:none; border:0; padding:.5rem; border-radius:.5rem; 
  cursor:pointer; color: var(--text); display: inline-flex;
}
.hamburger:hover { background: var(--bg-elev); }
.hamburger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hamburger svg rect { fill: currentColor; }

.brand { 
  display:flex; align-items:center; gap:10px; text-decoration:none; 
  color:inherit; font-weight: 600;
}
.logo { width:28px; height:28px; border-radius:6px; }
.brand-name { font-weight: 700; letter-spacing: .2px; }

/* Desktop navigation (hidden on mobile) */
.topbar-nav { 
  display: none;
  align-items: center; 
  gap: 12px;
}
.topbar-nav a {
  color: var(--text); text-decoration: none; padding: 6px 12px;
  border-radius: 8px; transition: background 0.2s;
}
.topbar-nav a:hover { background: var(--bg-elev); }

.auth-indicator { 
  font-size: 1rem; line-height: 1; cursor: default; margin-left: 4px;
}

/* ===========================
   Flash Messages
   =========================== */
.flash { 
  margin: 12px; padding: 10px 12px; border-radius: 8px; 
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.flash-info { background:#1e3a5f; border:1px solid #2563eb; color:#93c5fd; }
.flash-success { background:#0f3b25; border:1px solid #10b981; color:#6ee7b7; }
.flash-error { background:#4c1d1d; border:1px solid #ef4444; color:#fca5a5; }

/* ===========================
   Sidebar (off-canvas by default; opens with .open)
   =========================== */
.sidebar {
  position: fixed; left: 0; top: 56px; bottom: 0;
  width: 260px; padding: 12px;
  background: var(--bg); border-right: 1px solid var(--border);
  overflow: auto;
  transform: translateX(-100%);
  transition: transform .25s ease;
  z-index: 60;
}
.sidebar.open { transform: translateX(0); }

.sidebar .nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar .nav a {
  display:block; padding:10px 12px; border-radius:10px;
  color: var(--text); text-decoration:none; border:1px solid transparent;
  transition: all 0.2s;
}
.sidebar .nav a:hover { background: var(--bg-elev); border-color: var(--border); }

.sidebar-footer { 
  position: absolute; bottom: 12px; left: 12px; right: 12px;
  color: var(--muted); font-size: 12px; padding: 8px;
  border-top: 1px solid var(--border);
}

/* ===========================
   Content Area
   =========================== */
.content { padding: 18px 22px; margin-left: 0; min-height: calc(100vh - 56px); }

.panel { 
  background: var(--bg-elev); border: 1px solid var(--border); 
  border-radius: 16px; padding: 18px; margin-bottom: 16px;
}
.panel.narrow { max-width: 520px; margin: 2rem auto; }

.h1 { font-size: 22px; margin: 4px 0 12px; font-weight: 700; }
.h2 { font-size: 18px; margin: 0 0 10px; font-weight: 600; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }

.grid-2 { 
  display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 12px;
}
.card { 
  background: #121218; border: 1px solid var(--border); 
  border-radius: 14px; padding: 14px;
}

/* ===========================
   Forms & Buttons
   =========================== */
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="file"] {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: #0f0f14; color: var(--text); font-size: 14px;
  transition: border-color 0.2s;
}
.form input:focus-visible { 
  outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent);
}

.btn, button[type="submit"] {
  background: var(--accent); color: #fff; font-weight: 600;
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer;
  font-size: 14px; transition: filter 0.2s;
}
.btn:hover, button[type="submit"]:hover { filter: brightness(1.1); }
.btn:active { transform: scale(0.98); }

.btn.ghost {
  background: transparent; color: var(--text); border: 1px solid var(--border);
}
.btn.ghost:hover { border-color: var(--accent); background: var(--bg-elev); }

/* ===========================
   Chat Shell
   =========================== */
.chat-shell { display: grid; gap: 10px; }
.chat-window {
  height: 280px; overflow: auto; background: #0f0f14; border: 1px solid var(--border);
  border-radius: 12px; padding: 10px;
}
.msg { 
  padding: 8px 12px; border-radius: 10px; margin: 6px 0; 
  display: inline-block; max-width: 80%;
}
.msg.bot  { background: #151523; border: 1px solid var(--border); }
.msg.user { 
  background: var(--accent); color: #fff; font-weight: 500; 
  margin-left: auto; display: block; text-align: right;
}

.chat-input { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.chat-input input {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); 
  background: #0f0f14; color: var(--text);
}

/* ===========================
   Tables
   =========================== */
.table { 
  width: 100%; border-collapse: collapse; 
  background: var(--bg-elev); border-radius: 12px; overflow: hidden;
}
.table thead { background: #0f0f14; }
.table th { 
  text-align: left; padding: 12px; font-weight: 600; 
  border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #16161c; }

.table a { color: var(--accent); text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* ===========================
   Responsive
   =========================== */

/* Desktop: =1024px */
@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .content { margin-left: 260px; }
  .hamburger { display: none; }
  .topbar-nav { display: flex; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* Tablet: 720px - 1023px */
@media (min-width: 720px) and (max-width: 1023px) {
  .topbar-nav { display: flex; }
  .hamburger { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Mobile: =719px */
@media (max-width: 719px) {
  .content { padding: 14px; }
  .panel { padding: 14px; }
  .h1 { font-size: 20px; }
  .grid-2 { grid-template-columns: 1fr; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px; }
}