/* CheckoutTool Admin CSS */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:        #f5f5f5;
  --color-surface:   #ffffff;
  --color-border:    #e5e7eb;
  --color-text:      #111827;
  --color-muted:     #6b7280;
  --color-primary:   #2563eb;
  --color-primary-h: #1d4ed8;
  --color-danger:    #dc2626;
  --color-success:   #16a34a;
  --color-warning:   #d97706;
  --radius:          8px;
  --shadow:          0 1px 3px rgba(0,0,0,.08);
  --nav-w:           240px;
  --font:            system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ── Auth ────────────────────────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-container { width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 2rem; }
.logo-text { font-size: 1.5rem; font-weight: 700; color: var(--color-primary); }
.auth-card { background: var(--color-surface); border-radius: var(--radius); box-shadow: 0 4px 24px rgba(0,0,0,.1); padding: 2rem; }
.auth-title { font-size: 1.25rem; font-weight: 600; margin-bottom: .5rem; }
.auth-subtitle { color: var(--color-muted); margin-bottom: 1.5rem; font-size: .875rem; }
.auth-links { margin-top: 1.25rem; text-align: center; font-size: .875rem; color: var(--color-muted); }
.auth-links a { color: var(--color-primary); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.separator { margin: 0 .5rem; }

/* ── Nav ─────────────────────────────────────────────────────────────── */
.admin-nav {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--nav-w);
  background: #1e1e2e; color: #c9d1d9;
  display: flex; flex-direction: column;
  padding: 1.5rem 0;
  z-index: 100;
}
.nav-brand { padding: 0 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.nav-logo { color: #fff; font-weight: 700; font-size: 1rem; text-decoration: none; display: block; }
.plan-badge { display: inline-block; font-size: .65rem; padding: .15rem .4rem; border-radius: 9999px; margin-left: .5rem; font-weight: 600; vertical-align: middle; }
.plan-trial { background: #92400e; color: #fef3c7; }
.plan-active { background: #166534; color: #dcfce7; }
.plan-cancelled { background: #374151; color: #d1d5db; }

.nav-links { list-style: none; padding: 1rem 0; flex: 1; overflow-y: auto; }
.nav-links li a {
  display: block; padding: .6rem 1.25rem;
  color: #9ca3af; text-decoration: none; font-size: .875rem;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-links li a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-links li.active a { color: #fff; background: rgba(37,99,235,.3); }
.nav-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-warning); position: absolute; right: 1rem; top: 50%; transform: translateY(-50%);
}
.nav-user { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }
.nav-email { display: block; font-size: .75rem; color: #6b7280; margin-bottom: .5rem; word-break: break-all; }

/* ── Main Content ─────────────────────────────────────────────────────── */
.admin-main { margin-left: var(--nav-w); padding: 2rem; min-height: 100vh; max-width: 1200px; }
.admin-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--color-muted); font-size: .875rem; margin-top: .25rem; }
.header-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Stats Grid ──────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card { background: var(--color-surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-label { font-size: .75rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }

/* ── Dashboard Sections ───────────────────────────────────────────────── */
.dashboard-section { margin-bottom: 2rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-header h2 { font-size: 1rem; font-weight: 600; }

/* ── Products Grid ────────────────────────────────────────────────────── */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.product-card { background: var(--color-surface); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.product-card-name { font-weight: 600; margin-bottom: .25rem; }
.product-card-meta { font-size: .8rem; color: var(--color-muted); margin-bottom: 1rem; }
.product-card-actions { display: flex; gap: .5rem; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--color-surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th { background: #f9fafb; text-align: left; padding: .75rem 1rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); border-bottom: 1px solid var(--color-border); }
.data-table td { padding: .75rem 1rem; 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: #f9fafb; }
.actions { white-space: nowrap; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 9999px; font-size: .7rem; font-weight: 600; white-space: nowrap; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-sm { font-size: .6rem; padding: .1rem .4rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: 6px; font-size: .875rem; font-weight: 500;
  cursor: pointer; text-decoration: none; border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-h); }
.btn-outline  { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: #eff6ff; }
.btn-ghost    { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger   { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success  { background: var(--color-success); color: #fff; }
.btn-sm       { padding: .3rem .7rem; font-size: .8rem; }
.btn-full     { width: 100%; }
.btn-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-lg       { padding: .75rem 1.5rem; font-size: 1rem; }

/* ── Forms ───────────────────────────────────────────────────────────── */
.form-group  { margin-bottom: 1.25rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: .4rem; font-size: .875rem; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint   { font-size: .75rem; color: var(--color-muted); margin-top: .3rem; display: block; }
.form-card   { background: var(--color-surface); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.form-section { margin-bottom: 2rem; padding-bottom: 2rem; border-bottom: 1px solid var(--color-border); }
.form-section:last-of-type { border-bottom: none; }
.form-section-title { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }
.form-actions { display: flex; gap: .75rem; padding-top: 1rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 400; }
.checkbox-label input { width: 16px; height: 16px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--color-border);
  border-radius: 6px; font-size: .875rem; font-family: var(--font);
  background: #fff; color: var(--color-text);
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
input.input-disabled, select:disabled { background: #f9fafb; color: var(--color-muted); cursor: not-allowed; }
textarea { resize: vertical; }

.input-group { display: flex; }
.input-group input { border-radius: 6px 0 0 6px; }
.input-addon { display: flex; align-items: center; padding: 0 .75rem; background: #f3f4f6; border: 1px solid var(--color-border); border-left: none; border-radius: 0 6px 6px 0; color: var(--color-muted); font-size: .875rem; white-space: nowrap; }

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert { padding: .875rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .875rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }

/* ── Trial Banner ─────────────────────────────────────────────────────── */
.trial-banner { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.trial-urgent { background: #fee2e2; border-color: #fecaca; color: #991b1b; }

/* ── Content Card ────────────────────────────────────────────────────── */
.content-card { background: var(--color-surface); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.content-card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 1.25rem; }

/* ── Connect Page ────────────────────────────────────────────────────── */
.connect-status { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.5rem; }
.connect-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.connect-ok   .connect-icon { background: #dcfce7; }
.connect-pending .connect-icon { background: #fef9c3; }
.connect-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.connect-info { margin-bottom: 1.5rem; }
.connect-info p { color: var(--color-muted); margin: .5rem 0 1rem; }
.feature-list { list-style: none; margin: 0 0 1.5rem; display: flex; flex-direction: column; gap: .5rem; }
.feature-list li { font-size: .875rem; }

/* ── Plan Options ────────────────────────────────────────────────────── */
.plan-status { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.plan-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.plan-card { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1.25rem; position: relative; }
.plan-card-featured { border-color: var(--color-primary); }
.plan-card-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--color-primary); color: #fff; font-size: .7rem; padding: .15rem .6rem; border-radius: 9999px; white-space: nowrap; }
.plan-card-title { font-weight: 600; margin-bottom: .5rem; }
.plan-card-price { font-size: 1.25rem; font-weight: 700; color: var(--color-primary); margin-bottom: .25rem; }
.plan-card-sub { font-size: .75rem; color: var(--color-muted); margin-bottom: 1rem; }

/* ── Editor ──────────────────────────────────────────────────────────── */
.editor-layout { display: flex; flex-direction: column; gap: 1rem; }
.editor-section { background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.editor-section.is-active { border-left: 3px solid var(--color-primary); }
.section-header-row { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; }
.section-meta { display: flex; align-items: center; gap: .75rem; }
.section-icon { font-size: 1.1rem; }
.section-name { font-weight: 500; }
.section-controls { display: flex; align-items: center; gap: .75rem; }
.toggle-btn { padding: .3rem .75rem; border-radius: 9999px; font-size: .75rem; font-weight: 600; cursor: pointer; border: none; }
.toggle-on  { background: #dcfce7; color: #166534; }
.toggle-off { background: #f3f4f6; color: #374151; }

.section-body { padding: 1.25rem; border-top: 1px solid var(--color-border); display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.subsection-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--color-muted); margin-bottom: .75rem; }
.content-editor, .ai-editor { }
.ai-instruction-field { width: 100%; }

.ai-status { display: flex; align-items: center; gap: .75rem; padding: 1rem; background: #eff6ff; border-radius: var(--radius); margin-bottom: 1rem; }
.ai-spinner { width: 18px; height: 18px; border: 2px solid var(--color-primary); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ai-preview { margin-top: 1rem; padding: 1rem; background: #f9fafb; border-radius: var(--radius); }
.ai-preview h4 { font-size: .8rem; font-weight: 600; margin-bottom: .5rem; color: var(--color-muted); }
.ai-preview-content { font-size: .8rem; white-space: pre-wrap; font-family: monospace; color: #374151; margin-bottom: .75rem; }

/* ── Detail List ─────────────────────────────────────────────────────── */
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1.5rem; font-size: .875rem; }
.detail-list dt { font-weight: 600; color: var(--color-muted); }

/* ── Empty State ─────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem; background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state p { color: var(--color-muted); margin-bottom: 1.25rem; }

/* ── Pagination ──────────────────────────────────────────────────────── */
.pagination { display: flex; gap: .75rem; justify-content: center; margin-top: 1.5rem; }

/* ── Misc ────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
small.text-muted { font-size: .8rem; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-nav  { position: static; width: 100%; flex-direction: row; padding: .75rem 1rem; }
  .admin-main { margin-left: 0; padding: 1rem; }
  .nav-links  { display: none; }
  .form-row   { grid-template-columns: 1fr; }
  .section-body { grid-template-columns: 1fr; }
  .plan-options { grid-template-columns: 1fr; }
}
