/* ============================================================
   ChargedStudios - Admin / CMS
   Vercel · Supabase-style dark dashboard
   ============================================================ */

body.admin-body { overflow: hidden; }

/* ---------- LOGIN ---------- */
.login {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 24px;
  background: radial-gradient(60% 60% at 50% 30%, rgba(34,211,238,0.07), transparent 70%), var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: linear-gradient(180deg, var(--surface), var(--bg-1));
  border: 1px solid var(--line-2); border-radius: var(--r-lg);
  padding: 38px 34px; box-shadow: var(--shadow-lg);
}
.login-logo { width: 46px; height: 46px; border-radius: 13px;
  background: radial-gradient(circle at 30% 25%, var(--cyan-bright), var(--cyan) 45%, var(--cyan-dim));
  display: grid; place-items: center; box-shadow: 0 0 28px -4px var(--cyan-glow); margin-bottom: 22px; }
.login-logo svg { width: 24px; height: 24px; }
.login h1 { font-size: 23px; font-weight: 600; letter-spacing: -0.025em; }
.login p { color: var(--text-3); font-size: 14px; margin-top: 8px; }
.field { margin-top: 18px; }
.field label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }
.input, .ta, .sel {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px;
  color: var(--text); font-family: var(--sans); font-size: 14.5px;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus, .ta:focus, .sel:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.ta { height: auto; min-height: 120px; padding: 12px 14px; line-height: 1.6; resize: vertical; }
.sel { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2374747f' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px; }
.login-hint { margin-top: 16px; font-family: var(--mono); font-size: 11.5px; color: var(--text-4); text-align: center; }
.login-hint b { color: var(--cyan); }
.err { color: #f87171; font-size: 12.5px; margin-top: 10px; min-height: 16px; }

/* ---------- SHELL ---------- */
.admin { display: grid; grid-template-columns: 256px 1fr; height: 100vh; }
@media (max-width: 820px){ .admin { grid-template-columns: 1fr; } .sidebar { display: none; } }

.sidebar { background: var(--bg-1); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 14px; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 8px 10px 18px; font-weight: 600; font-size: 15px; }
.side-brand .logo { width: 28px; height: 28px; border-radius: 8px; background: radial-gradient(circle at 30% 25%, var(--cyan-bright), var(--cyan) 45%, var(--cyan-dim)); display: grid; place-items: center; box-shadow: 0 0 16px -3px var(--cyan-glow); flex:none; }
.side-brand .logo svg { width: 15px; height: 15px; }
.side-brand .env { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--cyan); background: var(--cyan-soft); padding: 3px 7px; border-radius: 5px; letter-spacing: .08em; }
.side-sec { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-4); padding: 16px 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--text-2); font-size: 14px; cursor: pointer; transition: background .16s, color .16s; border: 1px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: var(--cyan-soft); color: var(--cyan); border-color: rgba(34,211,238,0.2); }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item .count { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-4); background: var(--surface-2); padding: 1px 7px; border-radius: 20px; }
.nav-item.active .count { color: var(--cyan); background: rgba(34,211,238,0.12); }
.side-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 9px; }
.side-user .av { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--cyan), var(--purple)); display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #04141a; flex:none; }
.side-user .nm { font-size: 13px; font-weight: 500; }
.side-user .rl { font-size: 11px; color: var(--text-4); font-family: var(--mono); }
.side-user .out { margin-left: auto; color: var(--text-4); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: transparent; border: 0; }
.side-user .out:hover { color: #f87171; background: rgba(248,113,113,0.08); }

/* ---------- MAIN ---------- */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.topbar { height: 60px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 24px; flex: none; }
.topbar .tb-title { font-size: 15px; font-weight: 600; }
.topbar .tb-crumb { font-family: var(--mono); font-size: 12px; color: var(--text-4); }
.topbar .spacer { flex: 1; }
.content { flex: 1; overflow-y: auto; padding: 28px 24px 60px; }
.content-inner { max-width: 1080px; margin: 0 auto; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.025em; }
.page-head p { color: var(--text-3); font-size: 14px; margin-top: 6px; max-width: 56ch; }

/* buttons reuse .btn from styles.css; admin extras */
.btn-danger { background: rgba(248,113,113,0.1); color: #f87171; border: 1px solid rgba(248,113,113,0.25); }
.btn-danger:hover { background: rgba(248,113,113,0.18); }
.icon-btn { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: transparent; border: 1px solid var(--line); color: var(--text-3); transition: all .16s; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: rgba(255,255,255,0.03); }
.icon-btn.danger:hover { color: #f87171; border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.07); }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 28px; }
@media (max-width: 760px){ .kpis { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.kpi .k { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.kpi .k svg { width: 15px; height: 15px; color: var(--cyan); }
.kpi .v { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; margin-top: 12px; }
.kpi .sub { font-size: 12px; color: var(--text-4); margin-top: 4px; font-family: var(--mono); }

/* ---------- PROJECT LIST ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-4); }
.toolbar .search .input { height: 40px; padding-left: 36px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { height: 30px; padding: 0 12px; border-radius: 6px; background: transparent; border: 0; color: var(--text-3); font-size: 13px; font-family: var(--sans); }
.seg button.active { background: var(--surface-3); color: var(--text); }

.proj-list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: grid; grid-template-columns: 22px 56px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.row:hover { border-color: var(--line-2); }
.row.dragging { opacity: .4; }
.row.drop-target { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.row .grip { color: var(--text-4); cursor: grab; display: grid; place-items: center; }
.row .grip:active { cursor: grabbing; }
.row .pthumb { width: 56px; height: 38px; border-radius: 7px; border: 1px solid var(--line); position: relative; overflow: hidden; }
.row .pmeta { min-width: 0; }
.row .pname { font-size: 14.5px; font-weight: 560; display: flex; align-items: center; gap: 9px; }
.row .pdom { font-family: var(--mono); font-size: 11.5px; color: var(--text-4); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .pactions { display: flex; align-items: center; gap: 8px; }

/* publish toggle */
.toggle { position: relative; width: 38px; height: 22px; border-radius: 20px; background: var(--surface-3); border: 1px solid var(--line-2); cursor: pointer; transition: background .2s, border-color .2s; flex: none; }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform .2s, background .2s; }
.toggle.on { background: rgba(34,211,238,0.2); border-color: var(--cyan); }
.toggle.on::after { transform: translateX(16px); background: var(--cyan); box-shadow: 0 0 8px var(--cyan-glow); }
.pub-label { font-family: var(--mono); font-size: 11px; width: 56px; color: var(--text-4); }
.pub-label.on { color: #34d399; }

.badge-feat { font-family: var(--mono); font-size: 10px; color: #fbbf24; background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.25); padding: 2px 6px; border-radius: 5px; }

.empty { text-align: center; padding: 70px 20px; color: var(--text-4); }
.empty svg { width: 40px; height: 40px; margin-bottom: 14px; opacity: .5; }

/* ---------- DRAWER (editor) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); z-index: 150; opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); z-index: 160;
  background: var(--bg-1); border-left: 1px solid var(--line-2);
  transform: translateX(100%); transition: transform .32s cubic-bezier(.3,.8,.3,1);
  display: flex; flex-direction: column; box-shadow: -40px 0 90px -30px rgba(0,0,0,0.8);
}
.drawer.open { transform: none; }
.drawer.settled { transition: none !important; transform: none !important; }
.drawer.hidden { transition: none !important; transform: translateX(101%) !important; }
.scrim.settled { transition: none !important; opacity: 1 !important; }
.scrim.hidden { transition: none !important; opacity: 0 !important; pointer-events: none !important; }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex: none; }
.drawer-head h3 { font-size: 16px; font-weight: 600; }
.drawer-head .x { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line); flex: none; }
.drawer-foot .spacer { flex: 1; }

.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--text-4); margin-top: 6px; font-family: var(--mono); }

/* tag input */
.tags-input { display: flex; flex-wrap: wrap; gap: 7px; padding: 9px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; }
.tags-input:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-soft); }
.tags-input .chip { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px 8px; border-radius: 7px; }
.tags-input .chip button { background: transparent; border: 0; color: var(--text-4); display: grid; place-items: center; padding: 0; }
.tags-input .chip button:hover { color: #f87171; }
.tags-input input { flex: 1; min-width: 90px; background: transparent; border: 0; outline: none; color: var(--text); font-family: var(--sans); font-size: 14px; height: 28px; }

/* category radio */
.cat-radio { display: flex; gap: 8px; }
.cat-radio label { flex: 1; text-align: center; padding: 10px; border: 1px solid var(--line-2); border-radius: 10px; font-size: 13px; cursor: pointer; color: var(--text-3); transition: all .16s; }
.cat-radio input { display: none; }
.cat-radio input:checked + label, .cat-radio label.sel { border-color: var(--cyan); background: var(--cyan-soft); color: var(--cyan); }

/* image drop */
.imgdrop { border: 1.5px dashed var(--line-2); border-radius: 12px; padding: 22px; text-align: center; color: var(--text-4); cursor: pointer; transition: all .16s; }
.imgdrop:hover, .imgdrop.over { border-color: var(--cyan); color: var(--cyan); background: var(--cyan-soft); }
.imgdrop svg { width: 26px; height: 26px; margin-bottom: 8px; }
.img-preview { margin-top: 12px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.img-preview img { width: 100%; display: block; max-height: 180px; object-fit: cover; }
.img-preview .rm { position: absolute; top: 8px; right: 8px; }

/* media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 14px; }
.media-cell { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); position: relative; }
.media-cell img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.media-cell .mc-meta { padding: 9px 11px; font-family: var(--mono); font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-cell .mc-rm { position: absolute; top: 7px; right: 7px; opacity: 0; transition: opacity .16s; }
.media-cell:hover .mc-rm { opacity: 1; }

/* testimonials */
.testi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.testi p { font-size: 14.5px; color: var(--text-2); line-height: 1.6; }
.testi .who { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.testi .nm { font-size: 13px; font-weight: 500; }
.testi .co { font-family: var(--mono); font-size: 11.5px; color: var(--text-4); }

/* settings */
.set-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; margin-bottom: 16px; }
.set-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.set-card p { font-size: 13px; color: var(--text-3); margin-bottom: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); z-index: 300;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 11px; padding: 12px 18px;
  display: flex; align-items: center; gap: 10px; font-size: 13.5px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 8px #34d399; }
