/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary:      #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-bg:           #f8fafc;
  --color-surface:      #ffffff;
  --color-border:       #e2e8f0;
  --color-text:         #1e293b;
  --color-muted:        #64748b;
  --color-success:      #16a34a;
  --color-error:        #dc2626;
  --color-warning:      #d97706;
  --color-info:         #0891b2;
  --sidebar-bg:         #1e2432;
  --sidebar-text:       #cbd5e1;
  --sidebar-hover:      #2d3448;
  --sidebar-active:     #2563eb;
  --sidebar-width:      220px;
  --topbar-height:      52px;
  --radius:             6px;
  --shadow:             0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
}

html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
p  { margin-bottom: .75rem; }
a  { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .8em; color: var(--color-muted); margin-left: .4rem; }

input, select, textarea, button {
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .4rem .75rem;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--color-primary); }
textarea { resize: vertical; width: 100%; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 100;
  box-shadow: var(--shadow);
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.logo:hover { text-decoration: none; }
.tagline { font-size: .7rem; opacity: .7; display: block; font-weight: 400; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .9rem;
}
.topbar-nav a {
  color: var(--color-muted);
  padding: .2rem .4rem;
  border-radius: var(--radius);
}
.topbar-nav a:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.topbar-nav form { margin: 0; }
.topbar-nav button[type=submit] {
  background: none;
  border: none;
  color: var(--color-muted);
  cursor: pointer;
  padding: .2rem .4rem;
  box-shadow: none;
}
.topbar-nav button[type=submit]:hover { color: var(--color-error); background: none; }
.topbar-nav span { color: var(--color-muted); font-size: .85rem; }

/* ── Layout ───────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
  padding-top: var(--topbar-height);
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  flex-shrink: 0;
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: .75rem 0;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem 2.5rem;
  max-width: 960px;
}

/* ── Sidebar Navigation ───────────────────────────────────── */
.sidebar-nav { display: flex; flex-direction: column; }

.sidebar-category { border-bottom: 1px solid rgba(255,255,255,.06); }

.sidebar-category-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .55rem 1rem;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  letter-spacing: .04em;
  text-transform: uppercase;
  box-shadow: none;
}
.sidebar-category-label:hover { background: var(--sidebar-hover); }
.sidebar-category-label--disabled {
  opacity: .4;
  cursor: default;
}
.sidebar-category-label--disabled:hover { background: none; }

.sidebar-tools { display: flex; flex-direction: column; padding: .2rem 0; }
.sidebar-link {
  display: block;
  padding: .35rem 1rem .35rem 2.25rem;
  color: rgba(203,213,225,.8);
  font-size: .85rem;
  text-decoration: none;
  transition: background .1s, color .1s;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.1);
  margin: .5rem 0;
}

/* Direct sidebar links (pricing, account, admin) outside a category */
.sidebar-nav > a.sidebar-link {
  padding-left: 1rem;
  color: rgba(203,213,225,.7);
  font-weight: 500;
}

/* ── Flash Messages ───────────────────────────────────────── */
.flash {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.flash-info    { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn, button[type=submit] {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  box-shadow: none;
}
.btn:hover, button[type=submit]:hover {
  background: var(--color-primary-dark);
  text-decoration: none;
  color: #fff;
}
.btn-delete {
  background: var(--color-error);
}
.btn-delete:hover { background: #b91c1c; }
.btn-icon {
  padding: .3rem .5rem;
  font-size: .8rem;
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.btn-icon:hover { background: var(--color-bg); color: var(--color-text); }

/* ── Forms ────────────────────────────────────────────────── */
label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: .75rem;
}
label input, label select, label textarea { font-weight: 400; width: 100%; }
label input[type=checkbox], label input[type=radio] { width: auto; }
select { background: var(--color-surface); }

/* ── Auth Form ────────────────────────────────────────────── */
.auth-form {
  max-width: 380px;
  margin: 2rem auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}
.auth-form h1 { text-align: center; margin-bottom: 1.5rem; }
.auth-form form { display: flex; flex-direction: column; }
.auth-form button[type=submit] { width: 100%; justify-content: center; margin-top: .5rem; }
.auth-form p { text-align: center; font-size: .9rem; margin-top: 1rem; }

/* ── Tool Container ───────────────────────────────────────── */
.tool-container { max-width: 720px; }

.tool-description {
  color: var(--color-muted);
  font-size: .9rem;
  margin-bottom: 1.25rem;
}

.tool-input {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}
.tool-input label { margin-bottom: 0; }
.tool-input input, .tool-input select, .tool-input textarea { width: 100%; }

.tool-error {
  color: var(--color-error);
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: .6rem 1rem;
  font-size: .9rem;
  margin-top: .75rem;
}

#tool-result { margin-top: 1.25rem; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.25rem;
}
.tab-nav button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: .5rem 1rem;
  color: var(--color-muted);
  font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  box-shadow: none;
}
.tab-nav button:hover { color: var(--color-text); background: none; }
.tab-nav button.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: none;
}

/* ── Create Form ──────────────────────────────────────────── */
.create-form {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.create-form input { flex: 1; min-width: 180px; }
.create-form button[type=submit] { flex-shrink: 0; }

/* ── Data Table ───────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-bottom: 1.5rem;
}
.data-table th {
  text-align: left;
  padding: .55rem .75rem;
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}
.data-table td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }
.data-table details summary { cursor: pointer; color: var(--color-primary); font-size: .85rem; }
.data-table pre {
  font-size: .8rem;
  background: #f1f5f9;
  padding: .5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-top: .5rem;
  white-space: pre-wrap;
}

/* ── Fleet Status ─────────────────────────────────────────── */
.fleet-status {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.fleet-status--ok      { background: #dcfce7; color: #15803d; }
.fleet-status--error   { background: #fee2e2; color: #b91c1c; }
.fleet-status--pending { background: #fef9c3; color: #854d0e; }

/* ── Admin ────────────────────────────────────────────────── */
.admin-category-heading {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-muted);
  margin: 2rem 0 .75rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--color-border);
}
.admin-module-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.admin-module-card h3 { margin-bottom: .75rem; }

/* ── Quota Bar ────────────────────────────────────────────── */
.quota-bar { margin-bottom: 1rem; }
.quota-label { font-size: .85rem; color: var(--color-muted); margin-bottom: .3rem; }
.quota-progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  appearance: none;
  background: var(--color-border);
  overflow: hidden;
}
.quota-progress::-webkit-progress-bar   { background: var(--color-border); }
.quota-progress::-webkit-progress-value { background: var(--color-primary); border-radius: 999px; }
.quota-progress::-moz-progress-bar      { background: var(--color-primary); }

/* ── Notices ──────────────────────────────────────────────── */
.rate-limit-notice, .tier-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .9rem;
  color: #78350f;
  margin-bottom: 1rem;
}
.rate-limit-notice .btn { margin-top: .5rem; }

/* ── Job Status ───────────────────────────────────────────── */
.job-status {
  color: var(--color-muted);
  font-style: italic;
  font-size: .9rem;
}

/* ── Pricing ──────────────────────────────────────────────── */
.pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  margin-bottom: 1.5rem;
}
.pricing-table th, .pricing-table td {
  padding: .55rem .75rem;
  border: 1px solid var(--color-border);
  text-align: center;
}
.pricing-table th { background: var(--color-bg); font-weight: 600; }
.pricing-table td:first-child { text-align: left; }
.pricing-section-header td {
  background: #f1f5f9;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
}

/* ── Promo ────────────────────────────────────────────────── */
.promo { margin-top: 2rem; }
.promo h2 { margin-bottom: 1rem; }
.promo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.promo-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  text-decoration: none;
  color: var(--color-text);
  transition: box-shadow .15s, border-color .15s;
}
.promo-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--color-primary);
  text-decoration: none;
}
.promo-card img { width: 100%; height: 80px; object-fit: contain; }
.promo-card strong { font-size: .95rem; }
.promo-card span { font-size: .82rem; color: var(--color-muted); }

/* ── Share Bar ────────────────────────────────────────────── */
.share-bar { display: inline-flex; gap: .4rem; align-items: center; }
.share-btn, .bookmark-btn {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: .8rem;
  padding: .2rem .55rem;
  cursor: pointer;
  border-radius: var(--radius);
  box-shadow: none;
}
.share-btn:hover, .bookmark-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}
.share-msg { font-size: .8rem; color: var(--color-success); }

/* ── Tool Output ──────────────────────────────────────────── */
.json-output, .hash-output, .barcode-output, .qr-output,
.lorem-output, .regex-matches, .dns-records, .ping-output,
.uuid-list, .diff-output {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  font-size: .875rem;
  margin-top: .75rem;
  overflow-x: auto;
}
.json-output pre { white-space: pre-wrap; word-break: break-all; }

.diff-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.diff-line { display: flex; gap: .5rem; font-family: monospace; font-size: .85rem; padding: .15rem .4rem; border-radius: 3px; }
.diff-marker { font-weight: 700; user-select: none; }
.diff-text { white-space: pre-wrap; word-break: break-all; flex: 1; }

.color-preview {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 3px;
  border: 1px solid var(--color-border);
  vertical-align: middle;
  margin-right: .4rem;
}

.cron-dates { list-style: disc; padding-left: 1.25rem; }
.cron-dates li { font-size: .9rem; margin-bottom: .15rem; }

.regex-offset { color: var(--color-muted); font-size: .8rem; margin-left: .25rem; }

/* ── Utility ──────────────────────────────────────────────── */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; display: inline-block; }
[x-cloak] { display: none !important; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 1rem; }
  .diff-inputs { grid-template-columns: 1fr; }
  .create-form { flex-direction: column; }
  .create-form input { min-width: 0; }
  .topbar { padding: 0 .75rem; }
}
