/* =========================================================
   Design tokens
   ========================================================= */
:root{
  --bg-app: #14171c;
  --bg-panel: #1a1e25;
  --bg-sidebar: #12151a;
  --bg-input: #0f1216;
  --border: #262c37;

  --text-main: #d3d7de;
  --text-dim: #6b7280;
  --text-bright: #f2f4f8;

  --amber: #e6b450;
  --teal: #5ccfe6;
  --pink: #f28779;
  --green: #7fd88f;
  --red: #e2685a;
  --yellow: #e6c07b;

  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-ui: 'Inter', ui-sans-serif, system-ui, sans-serif;

  --radius: 6px;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

button, input, textarea{ font-family: inherit; }

/* =========================================================
   App shell
   ========================================================= */
.app{
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 640px;
}

/* Title bar */
.titlebar{
  height: 38px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 12px;
  color: var(--text-dim);
}
.titlebar-left{ display: flex; gap: 7px; width: 120px; }
.dot{ width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot-red{ background: var(--red); }
.dot-yellow{ background: var(--yellow); }
.dot-green{ background: var(--green); }
.titlebar-center{ flex: 1; text-align: center; letter-spacing: 0.02em; }
.titlebar-right{ width: 120px; text-align: right; font-variant-numeric: tabular-nums; }

/* Workspace = sidebar + editor */
.workspace{
  flex: 1;
  display: flex;
  min-height: 0;
}

/* =========================================================
   Sidebar
   ========================================================= */
.sidebar{
  width: 230px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
}
.sidebar-title{
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 4px 16px 8px;
}
.sidebar-title-git{ margin-top: 24px; }
.tree-folder{
  padding: 4px 16px;
  color: var(--text-dim);
  font-size: 13px;
}
.tree-file{
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 13px;
  padding: 6px 16px 6px 28px;
  cursor: pointer;
  text-align: left;
  border-left: 2px solid transparent;
}
.tree-file:hover{ background: rgba(255,255,255,0.03); }
.tree-file.active{
  background: rgba(92,207,230,0.08);
  border-left-color: var(--teal);
  color: var(--text-bright);
}
.file-icon{
  font-size: 9px;
  font-weight: 700;
  width: 20px;
  text-align: center;
  border-radius: 3px;
  padding: 1px 0;
  flex-shrink: 0;
}
.file-icon.js{ background: rgba(230,180,80,0.15); color: var(--amber); }
.file-icon.json{ background: rgba(127,216,143,0.15); color: var(--green); }
.file-icon.md{ background: rgba(92,207,230,0.15); color: var(--teal); }
.file-icon.txt{ background: rgba(242,135,121,0.15); color: var(--pink); }

.git-info{
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.git-dot{
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 6px;
}

/* =========================================================
   Editor
   ========================================================= */
.editor{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tabs{
  display: flex;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  height: 36px;
  flex-shrink: 0;
}
.tab{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  font-size: 12px;
  color: var(--text-dim);
  border-right: 1px solid var(--border);
  background: transparent;
}
.tab.active{
  background: var(--bg-panel);
  color: var(--text-bright);
  border-top: 2px solid var(--teal);
}

.editor-body{
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.gutter{
  width: 46px;
  flex-shrink: 0;
  background: var(--bg-panel);
  color: #454c59;
  font-size: 12px;
  line-height: 1.7;
  text-align: right;
  padding: 24px 10px 24px 0;
  user-select: none;
  overflow: hidden;
}

.code-panel{
  flex: 1;
  background: var(--bg-panel);
  overflow-y: auto;
  padding: 24px 28px 40px;
}

.code-section.hidden{ display: none; }

.code-block{
  font-size: 13.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 20px;
}

.tok-comment{ color: #5c6370; font-style: italic; }
.tok-kw{ color: var(--pink); }
.tok-var{ color: var(--teal); }
.tok-prop{ color: #b3b9c5; }
.tok-str{ color: var(--green); }
.tok-heading{ color: var(--amber); font-weight: 700; }

/* Skills bars */
.skill-bars{
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 460px;
  margin-top: 8px;
}
.skill-row{ font-size: 12.5px; color: var(--text-dim); }
.skill-row span{ display: block; margin-bottom: 5px; color: var(--text-main); }
.bar{
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar i{
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--green));
  border-radius: 3px;
  transform-origin: left;
  animation: growBar 1s ease-out;
}
@keyframes growBar{
  from{ transform: scaleX(0); }
  to{ transform: scaleX(1); }
}

/* Contact form */
.contact-form{
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  margin-top: 12px;
}
.contact-form input,
.contact-form textarea{
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  resize: vertical;
}
.contact-form input:focus,
.contact-form textarea:focus{
  outline: none;
  border-color: var(--teal);
}
.contact-form button{
  align-self: flex-start;
  background: var(--teal);
  color: #0d1117;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.contact-form button:hover{ background: #7fdcef; }
.contact-form button:focus-visible,
.tree-file:focus-visible,
.terminal-input-row input:focus-visible{
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.form-status{ font-size: 12px; color: var(--green); min-height: 16px; }

/* =========================================================
   Terminal
   ========================================================= */
.terminal{
  height: 190px;
  flex-shrink: 0;
  background: var(--bg-input);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.terminal-header{
  display: flex;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 11px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.08em;
}
.terminal-hint code{
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--amber);
}
.terminal-output{
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  font-size: 12.5px;
  line-height: 1.6;
}
.term-line{ color: var(--text-main); margin-bottom: 2px; }
.term-cmd{ color: var(--amber); }
.term-echo{ color: var(--text-dim); }
.term-echo::before{ content: "minh-anh@portfolio ➜ "; color: var(--teal); }
.term-error{ color: var(--red); }
.term-highlight{ color: var(--green); }

.terminal-input-row{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}
.prompt{ color: var(--teal); font-size: 12.5px; white-space: nowrap; }
.prompt-arrow{ color: var(--amber); }
.terminal-input-row input{
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-bright);
  font-size: 12.5px;
}
.terminal-input-row input:focus{ outline: none; }

/* =========================================================
   Status bar
   ========================================================= */
.statusbar{
  height: 24px;
  flex-shrink: 0;
  background: var(--teal);
  color: #0d1117;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
}
.status-right{ margin-left: auto; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 820px){
  .sidebar{ width: 170px; }
  .titlebar-center{ display: none; }
  .gutter{ display: none; }
  .code-panel{ padding: 18px; }
  .terminal{ height: 160px; }
}

@media (max-width: 600px){
  .workspace{ flex-direction: column; }
  .sidebar{
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
  }
  .sidebar-tree{ display: flex; overflow-x: auto; }
  .tree-folder{ display: none; }
  .sidebar-title-git, .git-info{ display: none; }
  .tree-file{ white-space: nowrap; border-left: none; border-bottom: 2px solid transparent; }
  .tree-file.active{ border-bottom-color: var(--teal); }
}
