/* Playbrand v1.1 — Design System */

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

:root {
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, monospace;

  /* Brand */
  --pb-purple-50:  #EEEDFE;
  --pb-purple-100: #CECBF6;
  --pb-purple-400: #7F77DD;
  --pb-purple-600: #534AB7;
  --pb-purple-800: #3C3489;
  --pb-purple-900: #26215C;

  /* Neutrals */
  --gray-50:  #F8F8F7;
  --gray-100: #F1F0EE;
  --gray-200: #E4E2DE;
  --gray-300: #D0CEC9;
  --gray-400: #A09D97;
  --gray-500: #6B6965;
  --gray-600: #4A4845;
  --gray-700: #2E2D2B;
  --gray-800: #1A1918;
  --gray-900: #111110;

  /* Semantic */
  --color-success-bg:   #EAF3DE;
  --color-success-text: #3B6D11;
  --color-warning-bg:   #FAEEDA;
  --color-warning-text: #854F0B;
  --color-danger-bg:    #FCEBEB;
  --color-danger-text:  #A32D2D;
  --color-info-bg:      #E6F1FB;
  --color-info-text:    #185FA5;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--pb-purple-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Typography ── */
h1 { font-size: 1.6rem;  font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: .9rem;   font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); }
p  { margin-bottom: .75rem; }
p:last-child { margin-bottom: 0; }

/* ── Layout Shell ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -.01em;
  text-decoration: none;
}
.sidebar-logo-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--pb-purple-400);
  flex-shrink: 0;
}
.sidebar-logo:hover { text-decoration: none; }

.sidebar-section {
  padding: 18px 20px 6px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
}
.sidebar-nav { padding: 0 10px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  font-size: .9rem;
  text-decoration: none;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active { background: var(--pb-purple-600); color: #fff; }
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-bottom {
  margin-top: auto;
  padding: 14px 10px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  font-size: .85rem;
  text-decoration: none;
}
.sidebar-user:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  background: var(--pb-purple-600);
}
.avatar-lg {
  width: 40px; height: 40px;
  border-radius: 10px;
  font-size: .85rem;
}

/* ── Main Content ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  color: var(--gray-400);
}
.topbar-breadcrumb a { color: var(--gray-400); }
.topbar-breadcrumb a:hover { color: var(--gray-700); text-decoration: none; }
.topbar-breadcrumb .sep { font-size: .8rem; }
.topbar-breadcrumb .current { color: var(--gray-800); font-weight: 500; }
.topbar-spacer { flex: 1; }
.topbar-flash { flex: 1; }

/* ── Page Content ── */
.page-content { padding: 32px 28px; flex: 1; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-header-left h1 { margin-bottom: 4px; }
.page-header-left p { color: var(--gray-500); font-size: .9rem; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 22px; }
.card-footer {
  padding: 14px 22px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.stat-card .stat-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  margin-bottom: 6px;
}
.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  text-decoration: none;
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--pb-purple-600);
  color: #fff;
  border-color: var(--pb-purple-600);
}
.btn-primary:hover { background: var(--pb-purple-800); border-color: var(--pb-purple-800); color: #fff; }

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); color: var(--gray-900); }

.btn-danger {
  background: #fff;
  color: var(--color-danger-text);
  border-color: #F09595;
}
.btn-danger:hover { background: var(--color-danger-bg); }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }

.btn-sm { padding: 5px 11px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn svg { width: 15px; height: 15px; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--pb-purple-400);
  box-shadow: 0 0 0 3px rgba(127, 119, 221, .15);
}
.form-control::placeholder { color: var(--gray-300); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-hint { font-size: .8rem; color: var(--gray-400); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge-active  { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-draft   { background: var(--gray-100); color: var(--gray-500); }
.badge-paused  { background: var(--color-warning-bg); color: var(--color-warning-text); }
.badge-archived{ background: var(--gray-100); color: var(--gray-400); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }
.td-name { font-weight: 500; color: var(--gray-900); }
.td-actions { display: flex; align-items: center; gap: 6px; }

/* ── Customer / Project cards ── */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.item-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.item-card:hover {
  border-color: var(--pb-purple-400);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: inherit;
}
.item-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.item-card-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.item-card-title { font-weight: 600; font-size: .95rem; }
.item-card-sub   { font-size: .8rem; color: var(--gray-400); margin-top: 2px; }
.item-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Flash messages ── */
.flash {
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.flash-success { background: var(--color-success-bg); color: var(--color-success-text); }
.flash-error   { background: var(--color-danger-bg);  color: var(--color-danger-text); }
.flash-info    { background: var(--color-info-bg);    color: var(--color-info-text); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .3; }
.empty-state h3  { font-size: 1rem; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p   { font-size: .875rem; margin-bottom: 20px; }

/* ── Auth page ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-900);
  padding: 24px;
}
.auth-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gray-900);
  margin-bottom: 32px;
  text-decoration: none;
}
.auth-logo-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--pb-purple-400);
}

/* ── Editor layout ── */
.editor-shell {
  display: flex;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}
.editor-aside {
  width: 220px;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.editor-aside-header {
  padding: 14px 16px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-100);
}
.asset-nav { overflow-y: auto; flex: 1; padding: 8px; }
.asset-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .875rem;
  color: var(--gray-600);
  transition: background .15s;
  margin-bottom: 2px;
}
.asset-nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.asset-nav-item.active { background: var(--pb-purple-50); color: var(--pb-purple-600); font-weight: 500; }
.asset-nav-icon { font-size: 1rem; width: 24px; text-align: center; }
.asset-add-btn {
  margin: 8px;
  padding: 8px;
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--gray-400);
  font-size: .8rem;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 16px);
  transition: border-color .15s, color .15s;
}
.asset-add-btn:hover { border-color: var(--pb-purple-400); color: var(--pb-purple-600); }

.editor-main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
}
.editor-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 20px;
  gap: 0;
  flex-shrink: 0;
}
.editor-tab {
  padding: 12px 18px;
  font-size: .875rem;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}
.editor-tab:hover { color: var(--gray-800); }
.editor-tab.active { color: var(--pb-purple-600); border-bottom-color: var(--pb-purple-600); font-weight: 500; }

.editor-canvas { flex: 1; overflow-y: auto; padding: 20px; }

.editor-panel {
  width: 248px;
  background: #fff;
  border-left: 1px solid var(--gray-200);
  overflow-y: auto;
  flex-shrink: 0;
}
.panel-section {
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.panel-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-400);
  margin-bottom: 12px;
}
.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.panel-row label { font-size: .82rem; color: var(--gray-600); }
.panel-input {
  width: 80px;
  padding: 5px 8px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  color: var(--gray-800);
  text-align: right;
  font-family: var(--font);
}
.panel-input:focus { outline: none; border-color: var(--pb-purple-400); }

/* Toggle */
.toggle-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle {
  width: 34px; height: 19px;
  border-radius: 10px;
  background: var(--gray-300);
  position: relative;
  transition: background .2s;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
}
.toggle::after {
  content: '';
  position: absolute;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  top: 3px; left: 3px;
  transition: transform .2s;
  box-shadow: var(--shadow-sm);
}
.toggle.on { background: var(--pb-purple-400); }
.toggle.on::after { transform: translateX(15px); }

/* ── Utilities ── */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-muted { color: var(--gray-400); }
.text-sm    { font-size: .82rem; }
.text-right { text-align: right; }
.d-flex { display: flex; align-items: center; }
.gap-1  { gap: 8px; }
.gap-2  { gap: 16px; }
.flex-1 { flex: 1; }
.w-100  { width: 100%; }
.code-block {
  background: var(--gray-900);
  color: #a8e6cf;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: .78rem;
  word-break: break-all;
  line-height: 1.6;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .editor-panel { display: none; }
}
