/* =========================================================
   Teori Bahasa & Otomata — Design System
   Palet pink pastel, clean & minimalis
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --pink-50:  #fff5f8;
  --pink-100: #ffe6ef;
  --pink-200: #ffd0e2;
  --pink-300: #ffb3d1;
  --pink-400: #ff8fb8;
  --pink-500: #f4699b;
  --pink-600: #d84f83;
  --pink-700: #b23a68;
  --rose-ink: #4a2338;
  --ink-soft: #7a5c6d;
  --cream:    #fffbfc;
  --line:     #f3d9e6;
  --success:  #4caf82;
  --success-bg: #e7f7ef;
  --danger:   #e2597a;
  --danger-bg: #fdeaef;
  --shadow-sm: 0 2px 10px rgba(216, 79, 131, 0.08);
  --shadow-md: 0 8px 30px rgba(216, 79, 131, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(180deg, var(--pink-50) 0%, var(--cream) 320px);
  color: var(--rose-ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, .display-font {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  color: var(--rose-ink);
}

code, pre, .mono, textarea.code-input {
  font-family: 'JetBrains Mono', Consolas, monospace;
}

a { color: var(--pink-600); text-decoration: none; }
a:hover { color: var(--pink-700); }

/* ---------------- Navbar ---------------- */
.navbar-otomata {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand-otomata {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--rose-ink) !important;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--pink-300), var(--pink-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.nav-link-otomata {
  color: var(--ink-soft) !important;
  font-weight: 500;
  font-size: 0.92rem;
  padding: 0.5rem 0.9rem !important;
  border-radius: 999px;
  transition: all 0.15s ease;
}

.nav-link-otomata:hover,
.nav-link-otomata.active {
  color: var(--pink-700) !important;
  background: var(--pink-100);
}

/* ---------------- Layout ---------------- */
main { flex: 1; }

.page-hero {
  padding: 2.75rem 0 1.75rem;
}

.page-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--pink-100);
  color: var(--pink-700);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 0.9rem;
}

.page-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--ink-soft);
  font-size: 1rem;
  max-width: 640px;
}

/* ---------------- Cards ---------------- */
.card-soft {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.6rem;
  margin-bottom: 1.5rem;
}

.card-soft h5, .card-soft h6 {
  font-weight: 600;
}

.card-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--pink-600);
  margin-bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ---------------- Forms ---------------- */
.form-control, .form-select, textarea {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.92rem;
  background-color: var(--pink-50);
  color: var(--rose-ink);
}

.form-control:focus, .form-select:focus, textarea:focus {
  border-color: var(--pink-400);
  box-shadow: 0 0 0 0.2rem rgba(255, 143, 184, 0.25);
  background-color: #fff;
}

.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--rose-ink);
  margin-bottom: 0.35rem;
}

textarea.code-input {
  font-size: 0.86rem;
  line-height: 1.55;
  min-height: 190px;
}

.form-text-hint {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

/* ---------------- Buttons ---------------- */
.btn-pink {
  background: linear-gradient(135deg, var(--pink-500), var(--pink-600));
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.55rem 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-pink:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-pink-outline {
  background: #fff;
  border: 1.5px solid var(--pink-300);
  color: var(--pink-700);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.5rem 1.3rem;
  transition: all 0.15s ease;
}
.btn-pink-outline:hover {
  background: var(--pink-100);
  border-color: var(--pink-400);
  color: var(--pink-700);
}

.btn-chip {
  background: var(--pink-50);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
}
.btn-chip:hover {
  background: var(--pink-100);
  color: var(--pink-700);
}

/* ---------------- Home cards ---------------- */
.module-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.9rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  text-decoration: none;
}
.module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--pink-300);
}
.module-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 1.1rem;
}
.module-card h5 { color: var(--rose-ink); margin-bottom: 0.5rem; }
.module-card p { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: 0; }
.module-card .go-link {
  margin-top: 1.1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pink-600);
}

/* ---------------- Result / status boxes ---------------- */
.result-box {
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.result-accept {
  background: var(--success-bg);
  color: var(--success);
}
.result-reject {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-pink {
  background: var(--pink-100);
  color: var(--pink-700);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
}

/* ---------------- Trace table ---------------- */
.table-otomata {
  font-size: 0.86rem;
}
.table-otomata thead th {
  background: var(--pink-50);
  color: var(--pink-700);
  font-weight: 600;
  border-bottom: 2px solid var(--line);
}
.table-otomata td, .table-otomata th {
  vertical-align: middle;
  padding: 0.55rem 0.8rem;
}
.table-otomata tbody tr:hover {
  background: var(--pink-50);
}

/* ---------------- Graph / tree canvas ---------------- */
.graph-canvas {
  width: 100%;
  height: 380px;
  border: 1.5px dashed var(--pink-200);
  border-radius: var(--radius-sm);
  background: var(--pink-50);
}

.tree-wrap {
  overflow-x: auto;
  padding: 1rem 0.5rem;
}

/* ---------------- Parse tree (CSS connector tree) ---------------- */
.parse-tree, .parse-tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: center;
}
.parse-tree {
  display: inline-flex;
  padding-top: 0.5rem;
}
.parse-tree ul {
  display: flex;
  padding-top: 22px;
  position: relative;
}
.parse-tree li {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 22px 10px 0 10px;
}
.parse-tree li::before, .parse-tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid var(--pink-300);
  width: 50%;
  height: 22px;
}
.parse-tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--pink-300);
}
.parse-tree li:only-child::after, .parse-tree li:only-child::before {
  display: none;
}
.parse-tree li:only-child { padding-top: 0; }
.parse-tree li:first-child::before, .parse-tree li:last-child::after {
  border: 0 none;
}
.parse-tree li:last-child::before {
  border-right: 2px solid var(--pink-300);
  border-radius: 0 5px 0 0;
}
.parse-tree li:first-child::after {
  border-radius: 5px 0 0 0;
}
.parse-tree ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid var(--pink-300);
  width: 0;
  height: 22px;
}
.parse-tree li .tree-node {
  border: 1.5px solid var(--pink-300);
  border-radius: 10px;
  padding: 0.35rem 0.8rem;
  background: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--rose-ink);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.parse-tree li .tree-node.leaf-terminal {
  background: var(--pink-100);
  color: var(--pink-700);
  border-color: var(--pink-400);
}
.parse-tree li .tree-node.leaf-epsilon {
  background: #f2f2f2;
  color: #999;
  font-style: italic;
}

/* ---------------- Steps timeline (CNF) ---------------- */
.step-card {
  border-left: 3px solid var(--pink-300);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1rem;
  background: var(--pink-50);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.step-card h6 {
  color: var(--pink-700);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.step-card .grammar-line {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--rose-ink);
  line-height: 1.7;
}
.step-card .step-note {
  color: var(--ink-soft);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ---------------- Footer ---------------- */
.footer-otomata {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-align: center;
  background: #fff;
}

/* ---------------- Misc ---------------- */
.divider-soft {
  border: none;
  border-top: 1px solid var(--line);
  margin: 1.4rem 0;
}

.nav-tabs-pink {
  border-bottom: 1.5px solid var(--line);
  gap: 0.3rem;
}
.nav-tabs-pink .nav-link {
  border: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: 999px 999px 0 0;
  padding: 0.55rem 1.15rem;
}
.nav-tabs-pink .nav-link.active {
  background: var(--pink-100);
  color: var(--pink-700);
  border-bottom: 3px solid var(--pink-500);
}

.spinner-pink {
  width: 1.1rem;
  height: 1.1rem;
  border: 2.5px solid var(--pink-200);
  border-top-color: var(--pink-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

::selection {
  background: var(--pink-200);
}

@media (max-width: 767px) {
  .page-title { font-size: 1.6rem; }
  .card-soft { padding: 1.2rem; }
}
