/* =========================================================
   MOBIN DESIGN SYSTEM
   CodeBark — Clean SaaS Developer UI
   ========================================================= */

:root {
  --primary: #f97316;
  --primary-dark: #ea580c;
  --secondary: #ef4444;
  --gradient: linear-gradient(135deg, #f97316, #ef4444);

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #fff7ed;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --border: #e2e8f0;
  --border-hover: #fed7aa;

  --success: #16a34a;
  --danger: #dc2626;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --shadow-sm: 0 4px 15px rgba(15, 23, 42, .05);
  --shadow-md: 0 12px 35px rgba(15, 23, 42, .08);
  --shadow-lg: 0 25px 70px rgba(15, 23, 42, .10);

  --transition: .25s ease;
}

/* =========================================================
   RESET
   ========================================================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(249, 115, 22, .055), transparent 30%),
    radial-gradient(circle at 90% 10%, rgba(239, 68, 68, .045), transparent 30%),
    var(--bg);

  color: var(--text);
  font-family: "Inter", sans-serif;
  overflow-x: hidden;

  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font-family: inherit;
}

button {
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================================================
   LOADING SCREEN
   ========================================================= */

.cb-loading {
  position: fixed;
  inset: 0;
  z-index: 99999;

  display: flex;
  justify-content: center;
  align-items: center;

  background:
    radial-gradient(circle at center, rgba(249,115,22,.08), transparent 35%),
    #ffffff;

  transition:
    opacity .7s ease,
    visibility .7s ease;
}

.cb-loading.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-wrapper {
  width: min(90%, 430px);
  text-align: center;
}

.loader-logo {
  position: relative;

  width: 100px;
  height: 100px;

  margin: 0 auto 25px;

  display: flex;
  align-items: center;
  justify-content: center;
}

.loader-logo > div[class^="ring"] {
  position: absolute;
  inset: 0;

  border-radius: 50%;
  border: 2px solid transparent;
}

.ring1 {
  border-top-color: var(--primary) !important;
  animation: spin 1.5s linear infinite;
}

.ring2 {
  inset: 9px !important;
  border-right-color: var(--secondary) !important;
  animation: spinReverse 2s linear infinite;
}

.ring3 {
  inset: 18px !important;
  border-bottom-color: #fb923c !important;
  animation: spin 2.5s linear infinite;
}

.logo-icon {
  width: 52px;
  height: 52px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 16px;

  color: #fff;
  background: var(--gradient);

  box-shadow: 0 12px 30px rgba(249, 115, 22, .28);

  font-size: 21px;
}

.loader-title {
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -1.5px;
}

.loader-title span {
  color: var(--primary);
}

.loader-sub {
  margin-top: 7px;

  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
}

.loader-bar-wrap {
  margin-top: 32px;
}

.loader-bar {
  height: 7px;

  overflow: hidden;

  border-radius: 50px;
  background: #f1f5f9;
}

.bar-fill {
  width: 0;
  height: 100%;

  border-radius: inherit;
  background: var(--gradient);

  box-shadow: 0 0 18px rgba(249,115,22,.25);

  transition: width .1s linear;
}

.loader-percent {
  margin-top: 10px;

  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.loader-dots {
  display: flex;
  justify-content: center;
  gap: 6px;

  margin-top: 20px;
}

.loader-dots span {
  width: 6px;
  height: 6px;

  border-radius: 50%;
  background: var(--primary);

  animation: loadingDot 1s infinite ease-in-out;
}

.loader-dots span:nth-child(2) {
  animation-delay: .15s;
}

.loader-dots span:nth-child(3) {
  animation-delay: .3s;
}

/* =========================================================
   NAVBAR
   ========================================================= */

.cb-navbar {
  position: sticky;
  top: 0;
  z-index: 1000;

  min-height: 78px;
  padding: 12px 4%;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;

  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--border);

  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  box-shadow: 0 4px 20px rgba(15,23,42,.035);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;

  cursor: pointer;
  user-select: none;
}

.brand .icon {
  width: 43px;
  height: 43px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 13px;

  color: white;
  background: var(--gradient);

  box-shadow: 0 7px 20px rgba(249,115,22,.2);

  font-size: 17px;
}

.brand h1 {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: -.7px;
}

.brand h1 span {
  color: var(--primary);
}

.brand small {
  display: block;

  margin-top: 1px;

  color: var(--text-muted);

  font-size: 9px;
  font-weight: 700;
  letter-spacing: .4px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 5px;

  padding: 5px;

  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.nav-links a {
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 9px 14px;

  border-radius: 10px;

  color: var(--text-secondary);

  font-size: 12px;
  font-weight: 700;

  transition: var(--transition);
}

.nav-links a i {
  font-size: 11px;
}

.nav-links a:hover {
  color: var(--primary);
  background: #fff;
}

.nav-links a.active {
  color: #fff;
  background: var(--gradient);

  box-shadow: 0 5px 15px rgba(249,115,22,.2);
}

.tools {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tools button {
  min-height: 38px;
  padding: 0 12px;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  color: var(--text-secondary);
  background: #fff;

  border: 1px solid var(--border);
  border-radius: 11px;

  cursor: pointer;

  font-size: 11px;
  font-weight: 700;

  transition: var(--transition);
}

.tools button:hover {
  color: var(--primary);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.tools button.primary,
.tools button.back-btn {
  color: white;
  border-color: transparent;
  background: var(--gradient);
}

.tools button.primary:hover,
.tools button.back-btn:hover {
  color: white;
  box-shadow: 0 8px 22px rgba(249,115,22,.25);
}

/* =========================================================
   MAIN
   ========================================================= */

#mainContent {
  width: min(1450px, 92%);
  margin: 0 auto;
}

.cb-page {
  display: none;

  padding: 70px 0 35px;

  animation: pageIn .4s ease;
}

.cb-page.active {
  display: block;
}

/* =========================================================
   HERO
   ========================================================= */

.home-hero {
  position: relative;

  max-width: 900px;

  margin: 0 auto;

  padding: 80px 30px 75px;

  text-align: center;

  border: 1px solid var(--border);
  border-radius: var(--radius-xl);

  background:
    radial-gradient(circle at 50% 0%, rgba(249,115,22,.08), transparent 40%),
    #fff;

  box-shadow: var(--shadow-md);

  overflow: hidden;
}

.home-hero::before {
  content: "";

  position: absolute;

  width: 260px;
  height: 260px;

  top: -170px;
  left: 50%;

  transform: translateX(-50%);

  border-radius: 50%;

  background: rgba(249,115,22,.08);

  filter: blur(25px);
}

.badge {
  position: relative;

  display: inline-flex;
  align-items: center;

  padding: 7px 14px;

  border: 1px solid #fed7aa;
  border-radius: 50px;

  color: var(--primary-dark);
  background: var(--surface-soft);

  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
}

.home-hero h1 {
  position: relative;

  margin-top: 20px;

  font-size: clamp(38px, 6vw, 70px);
  line-height: 1.05;
  letter-spacing: -3px;
  font-weight: 900;
}

.home-hero h1 span {
  background: var(--gradient);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.home-hero p {
  position: relative;

  max-width: 620px;

  margin: 22px auto 30px;

  color: var(--text-secondary);

  font-size: 15px;
  line-height: 1.8;
}

.start-btn {
  position: relative;

  padding: 14px 25px;

  display: inline-flex;
  align-items: center;
  gap: 9px;

  color: #fff;
  background: var(--gradient);

  border-radius: 50px;

  cursor: pointer;

  font-size: 13px;
  font-weight: 800;

  box-shadow: 0 10px 25px rgba(249,115,22,.22);

  transition: var(--transition);
}

.start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 35px rgba(249,115,22,.3);
}

/* =========================================================
   STATS
   ========================================================= */

.home-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;

  margin-top: 25px;
}

.stat-card {
  padding: 25px 20px;

  text-align: center;

  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);

  box-shadow: var(--shadow-sm);

  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.stat-card .num {
  color: var(--primary);

  font-size: 28px;
  font-weight: 900;
  letter-spacing: -1px;
}

.stat-card .label {
  margin-top: 5px;

  color: var(--text-muted);

  font-size: 11px;
  font-weight: 700;
}

/* =========================================================
   FEATURES
   ========================================================= */

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;

  margin-top: 18px;
}

.feature-card {
  padding: 25px;

  background: #fff;

  border: 1px solid var(--border);
  border-radius: var(--radius-lg);

  box-shadow: var(--shadow-sm);

  transition: var(--transition);
}

.feature-card:hover {
  transform: translateY(-5px);

  border-color: var(--border-hover);

  box-shadow: var(--shadow-md);
}

.feature-card .icon {
  width: 43px;
  height: 43px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin-bottom: 18px;

  border-radius: 13px;

  background: var(--surface-soft);

  font-size: 19px;
}

.feature-card h3 {
  margin-bottom: 7px;

  font-size: 14px;
  font-weight: 800;
}

.feature-card p {
  color: var(--text-secondary);

  font-size: 12px;
  line-height: 1.7;
}

/* =========================================================
   EDITOR
   ========================================================= */

.editor-container {
  display: grid;

  grid-template-columns: 1fr 1fr 1.2fr;

  gap: 15px;

  min-height: 650px;
}

.editor-panel {
  display: flex;
  flex-direction: column;

  min-width: 0;

  overflow: hidden;

  background: #fff;

  border: 1px solid var(--border);
  border-radius: var(--radius-lg);

  box-shadow: var(--shadow-sm);
}

.panel-header {
  min-height: 52px;

  padding: 0 16px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  color: var(--text-secondary);

  border-bottom: 1px solid var(--border);

  background: #fff;

  font-size: 11px;
  font-weight: 800;
}

.panel-header > span:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
}

.html-icon {
  color: #f97316;
}

.css-icon {
  color: #2563eb;
}

.preview-icon {
  color: #8b5cf6;
}

.dot {
  width: 6px;
  height: 6px;

  display: inline-block;

  border-radius: 50%;
}

.html-dot {
  background: #f97316;
}

.css-dot {
  background: #2563eb;
}

.preview-dot {
  background: #8b5cf6;
}

.editor-panel textarea {
  width: 100%;
  height: 100%;
  min-height: 590px;

  resize: none;

  padding: 20px;

  color: #334155;
  background: #fbfdff;

  border: none;
  outline: none;

  font-family:
    "Cascadia Code",
    "Consolas",
    monospace;

  font-size: 12px;
  line-height: 1.8;

  tab-size: 2;
}

.editor-panel textarea:focus {
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(249,115,22,.08);
}

/* =========================================================
   PREVIEW
   ========================================================= */

.preview-panel {
  position: relative;
}

.tab-bar {
  min-height: 48px;

  padding: 7px 10px;

  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;

  background: #f8fafc;

  border-bottom: 1px solid var(--border);
}

.tab {
  width: 34px;
  height: 32px;

  display: flex;
  align-items: center;
  justify-content: center;

  color: var(--text-muted);
  background: #fff;

  border: 1px solid var(--border);
  border-radius: 9px;

  cursor: pointer;

  transition: var(--transition);
}

.tab:hover {
  color: var(--primary);
  border-color: var(--border-hover);
}

.tab.active-tab {
  color: #fff;
  background: var(--gradient);
  border-color: transparent;

  box-shadow: 0 5px 12px rgba(249,115,22,.18);
}

#previewWindow {
  width: 100%;
  height: 100%;
  min-height: 540px;

  display: block;

  border: none;

  background: #fff;

  transition:
    width .3s ease,
    max-width .3s ease;
}

/* =========================================================
   FOOTER
   ========================================================= */

.footer-bar {
  min-height: 55px;

  margin: 20px 0 30px;
  padding: 8px 15px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;

  background: #fff;

  border: 1px solid var(--border);
  border-radius: 16px;

  box-shadow: var(--shadow-sm);
}

.info-item {
  display: flex;
  align-items: center;
  gap: 7px;

  color: var(--text-muted);

  font-size: 10px;
  font-weight: 700;
}

.info-item i {
  color: var(--primary);
}

.status-badge {
  padding: 6px 10px;

  display: flex;
  align-items: center;
  gap: 6px;

  color: var(--success);
  background: #f0fdf4;

  border: 1px solid #bbf7d0;
  border-radius: 50px;

  font-size: 10px;
  font-weight: 800;
}

.status-badge i {
  color: currentColor;
  font-size: 7px;
}

.status-badge.error {
  color: var(--danger);
  background: #fef2f2;
  border-color: #fecaca;
}

/* =========================================================
   NOTIFICATION
   ========================================================= */

.notification {
  position: fixed;
  right: 25px;
  bottom: 25px;

  z-index: 9999;

  min-width: 250px;

  padding: 14px 17px;

  display: flex;
  align-items: center;
  gap: 10px;

  background: #fff;

  border: 1px solid var(--border);
  border-radius: 14px;

  box-shadow: var(--shadow-lg);

  transform: translateY(120px);
  opacity: 0;

  pointer-events: none;

  transition: .35s ease;

  font-size: 12px;
  font-weight: 700;
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification i {
  color: var(--primary);
}

/* =========================================================
   MODAL
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;

  z-index: 9998;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;

  background: rgba(15,23,42,.28);

  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);

  opacity: 0;
  visibility: hidden;

  transition: .25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  width: min(100%, 430px);

  padding: 35px;

  text-align: center;

  background: #fff;

  border: 1px solid var(--border);
  border-radius: 24px;

  box-shadow: var(--shadow-lg);

  transform: translateY(15px) scale(.97);

  transition: .3s ease;
}

.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

.modal-icon {
  width: 55px;
  height: 55px;

  margin: 0 auto 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 16px;

  background: var(--surface-soft);

  font-size: 24px;
}

.modal-box h2 {
  font-size: 21px;
  font-weight: 900;
}

.modal-box p {
  margin-top: 8px;

  color: var(--text-secondary);

  font-size: 12px;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 9px;

  margin-top: 25px;
}

.modal-actions button {
  padding: 11px 19px;

  border-radius: 11px;

  cursor: pointer;

  font-size: 11px;
  font-weight: 800;

  transition: var(--transition);
}

.btn-cancel {
  color: var(--text-secondary);
  background: #f8fafc;
  border: 1px solid var(--border);
}

.btn-cancel:hover {
  background: #f1f5f9;
}

.btn-confirm {
  color: #fff;
  background: var(--gradient);

  box-shadow: 0 7px 18px rgba(249,115,22,.2);
}

.btn-confirm:hover {
  transform: translateY(-2px);
}

/* =========================================================
   SCROLLBAR
   ========================================================= */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f8fafc;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 50px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* =========================================================
   SELECTION
   ========================================================= */

::selection {
  color: #fff;
  background: var(--primary);
}

/* =========================================================
   DARK MODE
   Mobin-compatible secondary mode
   ========================================================= */

body.dark-mode {
  --bg: #111827;
  --surface: #1f2937;
  --surface-soft: #29211d;

  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border: #374151;
  --border-hover: #9a3412;

  background: #111827;
}

body.dark-mode .cb-navbar,
body.dark-mode .editor-panel,
body.dark-mode .panel-header,
body.dark-mode .stat-card,
body.dark-mode .feature-card,
body.dark-mode .home-hero,
body.dark-mode .footer-bar,
body.dark-mode .notification,
body.dark-mode .modal-box {
  background: #1f2937;
  border-color: #374151;
}

body.dark-mode .nav-links {
  background: #111827;
  border-color: #374151;
}

body.dark-mode .nav-links a:hover {
  background: #1f2937;
}

body.dark-mode .tools button,
body.dark-mode .tab {
  background: #1f2937;
  border-color: #374151;
}

body.dark-mode .editor-panel textarea {
  color: #e2e8f0;
  background: #111827;
}

body.dark-mode .editor-panel textarea:focus {
  background: #111827;
}

body.dark-mode .tab-bar {
  background: #111827;
  border-color: #374151;
}

body.dark-mode #previewWindow {
  background: #fff;
}

body.dark-mode .home-hero {
  background:
    radial-gradient(circle at 50% 0%, rgba(249,115,22,.12), transparent 40%),
    #1f2937;
}

body.dark-mode .loader-title,
body.dark-mode .modal-box h2,
body.dark-mode .feature-card h3,
body.dark-mode .stat-card .label {
  color: #f8fafc;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1150px) {
  .cb-navbar {
    flex-wrap: wrap;
  }

  .nav-links {
    order: 3;
    width: 100%;

    justify-content: center;
  }

  .editor-container {
    grid-template-columns: 1fr 1fr;
  }

  .preview-panel {
    grid-column: 1 / -1;
  }

  .home-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 760px) {
  #mainContent {
    width: 94%;
  }

  .cb-navbar {
    padding: 10px 3%;

    gap: 10px;
  }

  .brand small {
    display: none;
  }

  .nav-links {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .nav-links a {
    white-space: nowrap;
  }

  .tools {
    margin-left: auto;
  }

  .tools button span {
    display: none;
  }

  .tools button {
    width: 38px;
    padding: 0;
  }

  .tools .primary {
    width: 38px;
  }

  .cb-page {
    padding-top: 35px;
  }

  .home-hero {
    padding: 55px 20px;
  }

  .home-hero h1 {
    letter-spacing: -2px;
  }

  .home-stats {
    grid-template-columns: 1fr 1fr;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .editor-container {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    grid-column: auto;
  }

  .editor-panel textarea {
    min-height: 420px;
  }

  #previewWindow {
    min-height: 450px;
  }

  .footer-bar {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .brand h1 {
    font-size: 16px;
  }

  .brand .icon {
    width: 38px;
    height: 38px;
  }

  .nav-links a {
    padding: 8px 10px;
    font-size: 10px;
  }

  .home-stats {
    grid-template-columns: 1fr;
  }

  .home-hero h1 {
    font-size: 38px;
  }

  .home-hero p {
    font-size: 13px;
  }

  .start-btn {
    width: 100%;
    justify-content: center;
  }

  .panel-header {
    padding: 0 11px;
  }

  .tab-bar {
    justify-content: center;
  }

  .notification {
    left: 15px;
    right: 15px;
    bottom: 15px;
    min-width: 0;
  }
}

/* =========================================================
   ANIMATIONS
   ========================================================= */

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinReverse {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes loadingDot {
  0%,
  100% {
    opacity: .3;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}