/*
  Project: Mindmap App — Global Frontend CSS
  Path: /public_html/assets/styles.css
  Notes: CSS Variables, Light/Dark theme, responsive layout.
*/

/* ------------------------------
   1) CSS RESET + BASE TOKENS
------------------------------ */
:root {
  /* brand */
  --brand: #6c5ce7;           /* primary */
  --brand-600: #5a4dd7;
  --brand-700: #4a3fbf;
  --accent: #00d1b2;          /* secondary */

  /* neutrals */
  --bg: #ffffff;
  --surface: #f7f8fb;
  --surface-2: #eef0f6;
  --text: #1b1f2a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ring: rgba(108, 92, 231, .35);

  /* feedback */
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* layout */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(22, 28, 45, 0.08);
  --shadow-sm: 0 2px 10px rgba(22, 28, 45, 0.06);
  --maxw: 1200px;
}

/* Optional: automatic dark theme via attribute */
[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #0f172a;
  --surface-2: #111a2e;
  --text: #e5e7eb;
  --muted: #93a4b8;
  --border: #203149;
  --ring: rgba(0, 209, 178, .35);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

/* Reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img, svg, video { max-width: 100%; height: auto; display: block; }
button { font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

.container { max-width: var(--maxw); padding: 24px; margin: 0 auto; }

/* ------------------------------
   2) HEADER + NAV
------------------------------ */
.header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header__inner { display: flex; align-items: center; gap: 16px; padding: 14px 20px; }
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: .2px; font-size: 20px;
}
.logo__dot { width: 12px; height: 12px; border-radius: 999px; background: linear-gradient(135deg, var(--brand), var(--accent)); box-shadow: 0 0 0 3px var(--ring); }

.nav { margin-left: auto; display: flex; gap: 6px; }
.nav a { padding: 10px 14px; border-radius: var(--radius-sm); color: var(--muted); }
.nav a.is-active, .nav a:hover { color: var(--text); background: var(--surface); }

/* ------------------------------
   3) LAYOUT: SIDEBAR + MAIN
------------------------------ */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  padding: 18px;
}
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.sidebar__title { font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin: 8px 0 14px; }
.sidebar .list { display: grid; gap: 6px; }
.sidebar .list a { padding: 10px 12px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; border: 1px solid transparent; }
.sidebar .list a:hover { background: var(--surface-2); border-color: var(--border); }
.sidebar .list a.is-active { background: linear-gradient(180deg, var(--surface-2), transparent); border-color: var(--border); }

.main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-height: calc(100vh - 140px);
}

/* ------------------------------
   4) CARDS
------------------------------ */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__body { padding: 16px; }
.card__title { font-weight: 700; font-size: 18px; margin: 0 0 8px; }
.card__sub { color: var(--muted); font-size: 14px; margin-bottom: 8px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

/* ------------------------------
   5) BUTTONS
------------------------------ */
.btn {
  --btn-bg: var(--brand);
  --btn-fg: #fff;
  display: inline-flex; align-items: center; gap: 10px; 
  padding: 10px 14px; border-radius: 12px; border: 1px solid transparent;
  background: var(--btn-bg); color: var(--btn-fg);
  box-shadow: 0 6px 16px rgba(108, 92, 231, .25);
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn--ghost { --btn-bg: transparent; --btn-fg: var(--text); border-color: var(--border); box-shadow: none; }
.btn--secondary { --btn-bg: var(--accent); }
.btn--danger { --btn-bg: var(--danger); }
.btn--success { --btn-bg: var(--success); }
.btn--sm { padding: 8px 10px; border-radius: 10px; font-size: 14px; }
.btn--icon { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* Icon-only outline button */
.iconbtn { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--bg); }
.iconbtn:hover { background: var(--surface-2); }

/* ------------------------------
   6) FORMS
------------------------------ */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  box-shadow: 0 0 0 0 var(--ring);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}
.label { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: block; }
.field { margin-bottom: 14px; }

/* Toggle (for dark mode) */
.switch { position: relative; width: 46px; height: 26px; background: var(--surface-2); border-radius: 999px; border: 1px solid var(--border); transition: background .2s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); box-shadow: var(--shadow-sm); transition: transform .2s ease; }
.switch.is-on { background: var(--brand); }
.switch.is-on::after { transform: translateX(20px); }

/* ------------------------------
   7) TABLES
------------------------------ */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.table thead th {
  background: var(--surface);
  text-align: left; font-size: 13px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
  padding: 12px; border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ------------------------------
   8) MODALS
------------------------------ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(560px, 96vw); background: var(--bg); border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.modal__head { padding: 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal__title { font-size: 18px; font-weight: 700; }
.modal__body { padding: 16px; }
.modal__foot { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ------------------------------
   9) TOASTS
------------------------------ */
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 120;
  display: grid; gap: 8px; max-width: 360px;
}
.toast__item { background: var(--bg); border: 1px solid var(--border); border-left: 5px solid var(--brand); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-sm); }
.toast__item--success { border-left-color: var(--success); }
.toast__item--danger { border-left-color: var(--danger); }
.toast__item--warning { border-left-color: var(--warning); }

/* ------------------------------
   10) TYPOGRAPHY + UTILITIES
------------------------------ */
.h1 { font-size: clamp(28px, 3vw, 38px); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 8px; }
.h2 { font-size: clamp(22px, 2.5vw, 28px); font-weight: 700; margin: 0 0 10px; }
.p-muted { color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; padding: 2px 6px; border-radius: 8px; font-size: 12px; }

.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.space { height: 18px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.center { display: grid; place-items: center; }
.right { margin-left: auto; }
.hidden { display: none !important; }

/* ------------------------------
   11) MINDMAP-SPECIFIC (canvas, nodes, edges)
------------------------------ */
.mindmap { position: relative; background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius); min-height: 500px; overflow: hidden; }
.node {
  position: absolute; min-width: 140px; max-width: 260px; padding: 10px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-sm);
}
.node.is-selected { outline: 4px solid var(--ring); border-color: var(--brand); }
.node__title { font-weight: 700; margin-bottom: 6px; }
.node__body { color: var(--muted); font-size: 14px; }

.edge { position: absolute; pointer-events: none; }

/* Floating toolbar */
.toolbar {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 8px;
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  border: 1px solid var(--border); border-radius: 12px; backdrop-filter: blur(6px); padding: 6px; box-shadow: var(--shadow-sm);
}

/* Mini map */
.minimap { position: absolute; right: 12px; bottom: 12px; width: 180px; height: 120px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden; }

/* ------------------------------
   12) RESPONSIVE
------------------------------ */
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

@media (max-width: 640px) {
  .header__inner { padding: 12px 14px; }
  .container { padding: 16px; }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr; }
}

/* ------------------------------
   13) TRANSITIONS / ANIMATIONS (subtle)
------------------------------ */
.fade-in { animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ------------------------------
   14) THEMING HELPERS
------------------------------ */
.theme-brand { color: var(--brand); }
.theme-accent { color: var(--accent); }
.bg-surface { background: var(--surface); }
.border { border: 1px solid var(--border); }
.round { border-radius: var(--radius); }
.shadow { box-shadow: var(--shadow); }
