/* ── GSheetPress Admin UI — Shared Design System ── */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@500;700;800&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --purple: #5b4cf5;
  --purple-light: #f0eeff;
  --purple-dark: #4338ca;
  --gray-50: #f7f7fc;
  --gray-100: #f0f0f8;
  --gray-200: #e4e4ed;
  --gray-400: #8b8ba0;
  --gray-600: #3d3d52;
  --gray-800: #0d0d14;
  --red: #ef4444;
  --orange: #f97316;
  --green: #16a34a;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
}

html, body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: 'DM Sans', sans-serif; cursor: pointer; }
img { max-width: 100%; display: block; }

/* ── LAYOUT ── */
.admin-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 9px;
}
.sidebar-logo img { height: 26px; width: auto; }
.sidebar-logo span {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.3px;
}
.sidebar-logo span em { font-style: normal; color: var(--purple); }

.sidebar-nav { flex: 1; padding: 10px 8px; }
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gray-400);
  padding: 10px 10px 5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--gray-600);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--purple-light); color: var(--purple); font-weight: 500; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--gray-200); margin: 6px 8px; }

.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 9px;
}
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--purple-light);
  color: var(--purple);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: 'Syne', sans-serif;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-plan { font-size: 11px; color: var(--gray-400); }
.btn-logout {
  background: none;
  border: none;
  color: var(--gray-400);
  padding: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.btn-logout:hover { color: var(--red); }
.btn-logout svg { width: 15px; height: 15px; }

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

.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700; color: var(--gray-800); letter-spacing: -0.3px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.admin-content { padding: 22px 24px; flex: 1; }

/* ── CARDS ── */
.card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 18px; margin-bottom: 18px; }
.card-title { font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700; color: var(--gray-800); margin-bottom: 14px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header .card-title { margin-bottom: 0; }

/* ── STATS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.stat-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 16px 18px; }
.stat-label { font-size: 11px; color: var(--gray-400); margin-bottom: 7px; display: flex; align-items: center; gap: 5px; }
.stat-label svg { width: 13px; height: 13px; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 24px; font-weight: 700; color: var(--gray-800); letter-spacing: -0.5px; line-height: 1; margin-bottom: 3px; }
.stat-sub { font-size: 11px; color: var(--gray-400); }

/* ── PLAN BANNER ── */
.plan-banner { background: var(--purple); border-radius: var(--radius-lg); padding: 18px 22px; color: #fff; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; position: relative; overflow: hidden; }
.plan-banner::before { content: ''; position: absolute; top: -30px; right: -30px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,0.06); }
.plan-banner h3 { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700; margin-bottom: 3px; }
.plan-banner p { font-size: 13px; opacity: 0.75; }
.btn-upgrade-white { background: #fff; color: var(--purple); border: none; padding: 9px 18px; border-radius: var(--radius-md); font-size: 13px; font-weight: 700; white-space: nowrap; font-family: 'DM Sans', sans-serif; flex-shrink: 0; text-decoration: none; display: inline-block; }

/* ── TRIAL BANNER ── */
.trial-banner { background: #fff7ed; border: 1px solid #fed7aa; border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.trial-banner p { font-size: 13px; color: #9a3412; line-height: 1.5; }
.btn-trial { background: var(--orange); color: #fff; border: none; padding: 8px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600; white-space: nowrap; font-family: 'DM Sans', sans-serif; flex-shrink: 0; text-decoration: none; display: inline-block; }

/* ── BUTTONS ── */
.btn-primary { background: var(--purple); color: #fff; border: none; padding: 9px 16px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; transition: background 0.2s; font-family: 'DM Sans', sans-serif; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.btn-primary:hover { background: var(--purple-dark); }
.btn-primary svg { width: 14px; height: 14px; }
.btn-secondary { background: #fff; color: var(--gray-800); border: 1px solid var(--gray-200); padding: 9px 16px; border-radius: var(--radius-md); font-size: 13px; transition: border-color 0.2s; font-family: 'DM Sans', sans-serif; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.btn-secondary:hover { border-color: var(--gray-400); }
.btn-danger { background: #fff; color: var(--red); border: 1px solid #fecaca; padding: 6px 12px; border-radius: var(--radius-md); font-size: 12px; font-weight: 500; transition: background 0.2s; font-family: 'DM Sans', sans-serif; cursor: pointer; }
.btn-danger:hover { background: #fff5f5; }
.btn-icon { background: var(--gray-100); color: var(--gray-600); border: none; width: 30px; height: 30px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; transition: background 0.15s; flex-shrink: 0; cursor: pointer; }
.btn-icon:hover { background: var(--gray-200); }
.btn-icon svg { width: 13px; height: 13px; }

/* ── TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray-400); padding: 9px 12px; border-bottom: 1px solid var(--gray-200); background: var(--gray-50); }
.data-table td { padding: 11px 12px; font-size: 13px; color: var(--gray-600); border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.td-name { font-weight: 500; color: var(--gray-800) !important; }
.table-actions { display: flex; gap: 5px; align-items: center; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-active { background: #f0fdf4; color: var(--green); }
.badge-trial { background: #fff7ed; color: #d97706; }
.badge-expired { background: #fff5f5; color: var(--red); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--gray-600); margin-bottom: 5px; display: block; }
.form-input { width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); font-size: 13px; font-family: 'DM Sans', sans-serif; color: var(--gray-800); background: #fff; outline: none; transition: border-color 0.2s; }
.form-input:focus { border-color: var(--purple); }
.form-select { width: 100%; padding: 9px 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); font-size: 13px; font-family: 'DM Sans', sans-serif; color: var(--gray-800); background: #fff; outline: none; transition: border-color 0.2s; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%238b8ba0' stroke-width='1.5' d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 13px; }
.form-select:focus { border-color: var(--purple); }

/* ── TOGGLE ── */
.toggle-wrap { display: flex; align-items: center; gap: 9px; }
.toggle { position: relative; width: 34px; height: 19px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--gray-200); border-radius: 99px; transition: 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 13px; height: 13px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .toggle-slider { background: var(--purple); }
.toggle input:checked + .toggle-slider::before { transform: translateX(15px); }
.toggle-label { font-size: 13px; color: var(--gray-600); }

/* ── TABS ── */
.tab-nav { display: flex; gap: 2px; border-bottom: 1px solid var(--gray-200); margin-bottom: 18px; }
.tab-btn { padding: 8px 14px; font-size: 13px; color: var(--gray-400); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; transition: color 0.15s; font-family: 'DM Sans', sans-serif; }
.tab-btn:hover { color: var(--gray-800); }
.tab-btn.active { color: var(--purple); font-weight: 500; border-bottom-color: var(--purple); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── COPY FIELD ── */
.copy-field { display: flex; gap: 6px; align-items: center; }
.copy-input { flex: 1; padding: 7px 10px; border: 1px solid var(--gray-200); border-radius: var(--radius-md); font-size: 11px; font-family: 'Courier New', monospace; color: var(--gray-600); background: var(--gray-50); outline: none; min-width: 0; }
.btn-copy { background: var(--purple-light); color: var(--purple); border: none; padding: 7px 12px; border-radius: var(--radius-md); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; font-family: 'DM Sans', sans-serif; transition: background 0.15s; flex-shrink: 0; }
.btn-copy:hover { background: #e0d9ff; }
.btn-copy.copied { background: #f0fdf4; color: var(--green); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state p { font-size: 13px; margin-bottom: 14px; }

/* ── LOADING ── */
.loading-dots { display: flex; gap: 4px; justify-content: center; padding: 28px; }
.loading-dots span { width: 7px; height: 7px; background: var(--gray-200); border-radius: 50%; animation: dot-bounce 1.2s infinite; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce { 0%,80%,100%{transform:scale(0.8);opacity:0.4} 40%{transform:scale(1);opacity:1} }

/* ── USAGE BAR ── */
.usage-bar-bg { height: 6px; background: var(--gray-100); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.usage-bar-fill { height: 100%; border-radius: 99px; background: var(--purple); transition: width 0.6s; }
.usage-bar-fill.warning { background: var(--orange); }
.usage-bar-fill.danger { background: var(--red); }

/* ── TOAST ── */
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--gray-800); color: #fff; padding: 11px 18px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500; z-index: 9999; transform: translateY(60px); opacity: 0; transition: all 0.3s; pointer-events: none; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ── QUICK ACTIONS ── */
.quick-actions { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
.quick-action { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 16px; text-align: center; cursor: pointer; transition: border-color 0.2s, transform 0.15s; text-decoration: none; display: block; }
.quick-action:hover { border-color: var(--purple); transform: translateY(-1px); }
.quick-action-icon { font-size: 22px; margin-bottom: 7px; }
.quick-action-label { font-size: 13px; font-weight: 500; color: var(--gray-800); margin-bottom: 2px; }
.quick-action-sub { font-size: 11px; color: var(--gray-400); }

/* ── RESPONSIVE ── */
@media(max-width:900px){
  .sidebar{transform:translateX(-100%);transition:transform 0.25s;}
  .sidebar.open{transform:translateX(0);}
  .admin-main{margin-left:0;}
  .stats-grid{grid-template-columns:repeat(2,1fr);}
  .quick-actions{grid-template-columns:repeat(2,1fr);}
  .admin-content{padding:14px;}
  .admin-topbar{padding:0 14px;}
}
@media(max-width:560px){
  .stats-grid{grid-template-columns:1fr;}
}
