/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  background: #0a0a18;
  color: #ccc;
  font-family: 'Noto Sans KR', sans-serif;
  line-height: 1.5;
}

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

/* ===== SIDEBAR ===== */
.admin-sidebar {
  width: 240px;
  background: linear-gradient(180deg, #0f0f23 0%, #141430 100%);
  border-right: 1px solid #1e1e3e;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform 0.3s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #1e1e3e;
  text-align: center;
}
.sidebar-logo a {
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  display: block;
  margin-bottom: 4px;
}
.sidebar-logo .sub {
  font-size: 11px;
  color: #555;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  padding: 10px 20px 4px;
  font-size: 10px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #888;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 13px;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: #ddd; }
.nav-item.active {
  background: rgba(229,57,53,0.12);
  color: #e57373;
  border-left-color: #e53935;
}
.nav-item .ni { font-size: 15px; flex-shrink: 0; }
.sidebar-bottom {
  padding: 14px 16px;
  border-top: 1px solid #1e1e3e;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-bottom a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
  font-size: 12px;
  padding: 7px 4px;
  border-radius: 6px;
  transition: color 0.15s;
}
.sidebar-bottom a:hover { color: #ccc; }

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ===== MAIN ===== */
.admin-main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* ===== TOPBAR ===== */
.admin-topbar {
  background: #111127;
  border-bottom: 1px solid #1e1e3e;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-topbar h1 { font-size: 16px; font-weight: 700; color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Hamburger */
.hamburger {
  display: none;
  background: rgba(255,255,255,0.06);
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  color: #ccc;
  font-size: 18px;
  width: 36px; height: 36px;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.hamburger:hover { background: rgba(255,255,255,0.1); color: #fff; }

.btn-preview {
  background: transparent;
  border: 1px solid #e53935;
  color: #e57373;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-preview:hover { background: #e53935; color: #fff; }

.admin-content { padding: 24px; flex: 1; }

/* ===== SECTIONS ===== */
.section { display: none; }
.section.active { display: block; }
.section-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e1e3e;
}
.section-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-hint {
  color: #666;
  font-size: 12px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ===== CARDS ===== */
.card {
  background: #111127;
  border: 1px solid #1e1e3e;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
}
.card-desc { color: #777; font-size: 13px; margin-bottom: 14px; line-height: 1.6; }
.danger-title { color: #e57373 !important; }

.logo-preview-box {
  background: #0a0a18;
  border: 1px solid #1e1e3e;
  border-radius: 6px;
  padding: 16px;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 12px;
}

.quick-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Backup grid */
.backup-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-group:last-child { margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; color: #888; font-weight: 500; }
.form-input, .form-textarea, .form-select {
  background: #0a0a18;
  border: 1px solid #252545;
  border-radius: 6px;
  padding: 8px 12px;
  color: #ddd;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
  width: 100%;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: #e53935;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select option { background: #111127; }

/* Toggle */
.toggle {
  position: relative;
  width: 44px; height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #2a2a4a;
  border-radius: 24px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: #e53935; }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ===== BUTTONS ===== */
.btn {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-full { width: 100%; }
.btn-lg { padding: 10px 30px; font-size: 14px; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-xs { padding: 2px 7px; font-size: 10px; }
.btn-primary   { background: #e53935; color: #fff; }
.btn-primary:hover   { background: #c62828; }
.btn-success   { background: #2e7d32; color: #fff; }
.btn-success:hover   { background: #1b5e20; }
.btn-info      { background: #1565c0; color: #fff; }
.btn-info:hover      { background: #0d47a1; }
.btn-warning   { background: #e65100; color: #fff; }
.btn-warning:hover   { background: #bf360c; }
.btn-danger    { background: #b71c1c; color: #fff; }
.btn-danger:hover    { background: #7f0000; }
.btn-secondary { background: #37474f; color: #fff; }
.btn-secondary:hover { background: #263238; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: #111127;
  border: 1px solid #1e1e3e;
  border-top: 3px solid #e53935;
  border-radius: 10px;
  padding: 18px;
  text-align: center;
}
.stat-icon { font-size: 22px; margin-bottom: 8px; }
.stat-num { font-size: 26px; font-weight: 900; color: #e57373; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: #666; }

/* ===== ALERT ===== */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.6;
}
.alert-info    { background: rgba(21,101,192,0.12); border: 1px solid #1565c0; color: #90caf9; }
.alert-success { background: rgba(46,125,50,0.12);  border: 1px solid #2e7d32;  color: #a5d6a7; }

/* ===== CATEGORY MANAGER ===== */
.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-item {
  background: #0d0d22;
  border: 1px solid #1e1e3e;
  border-radius: 8px;
  overflow: hidden;
}
.cat-header {
  display: flex;
  align-items: center;
  padding: 11px 14px;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.cat-header:hover { background: rgba(255,255,255,0.02); }
.cat-icon-input {
  width: 38px;
  background: #111127;
  border: 1px solid #252545;
  border-radius: 4px;
  padding: 4px;
  color: #fff;
  font-size: 16px;
  text-align: center;
  flex-shrink: 0;
}
.cat-name-input {
  flex: 1;
  background: #111127;
  border: 1px solid #252545;
  border-radius: 4px;
  padding: 6px 10px;
  color: #ddd;
  font-size: 13px;
  font-family: inherit;
  min-width: 0;
}
.cat-name-input:focus { outline: none; border-color: #e53935; }
.cat-link-count { color: #555; font-size: 11px; white-space: nowrap; }
.cat-toggle-arrow { color: #444; font-size: 11px; flex-shrink: 0; }

.cat-body { padding: 0 14px 14px; display: none; }
.cat-body.open { display: block; }

.link-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.link-empty { color: #444; font-size: 12px; padding: 8px 0; }
.link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #111127;
  border: 1px solid #1e1e3e;
  border-radius: 6px;
}
.rank-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.link-row input[type=text] {
  background: #0a0a18;
  border: 1px solid #252545;
  border-radius: 4px;
  padding: 5px 8px;
  color: #ddd;
  font-size: 12px;
  font-family: inherit;
}
.link-row input[type=text]:focus { outline: none; border-color: #e53935; }
.inp-title { flex: 1; min-width: 80px; }
.inp-url   { flex: 2; min-width: 100px; }

.cat-body-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

/* ===== BANNER ADMIN ===== */
.banner-row-card {
  background: #111127;
  border: 1px solid #1e1e3e;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}
.banner-row-label {
  font-size: 13px;
  font-weight: 700;
  color: #aaa;
  margin-bottom: 12px;
}
.banner-cells {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.banner-cell-card {
  background: #0a0a18;
  border: 1px solid #1e1e3e;
  border-radius: 6px;
  overflow: hidden;
}
.banner-cell-preview {
  height: 80px;
  background: linear-gradient(135deg, #0f0f23, #1a1a3e);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.banner-cell-preview:hover { opacity: 0.85; }
.banner-cell-preview img { width: 100%; height: 100%; object-fit: cover; }
.banner-cell-preview .placeholder-text {
  color: #444;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}
.banner-cell-body { padding: 10px; }
.banner-cell-body .form-group { margin-bottom: 6px; }
.banner-cell-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ===== SOCIAL MANAGER ===== */
.social-manager {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.social-card {
  background: #0d0d22;
  border: 1px solid #1e1e3e;
  border-radius: 8px;
  padding: 14px;
}
.social-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.social-icon-inp {
  width: 38px; height: 38px;
  background: #111127;
  border: 1px solid #252545;
  border-radius: 8px;
  font-size: 20px;
  text-align: center;
  color: #fff;
  padding: 0;
  flex-shrink: 0;
}
.social-name-inp {
  flex: 1;
  background: #111127;
  border: 1px solid #252545;
  border-radius: 4px;
  padding: 6px 10px;
  color: #ddd;
  font-size: 12px;
  font-family: inherit;
}
.social-name-inp:focus { outline: none; border-color: #e53935; }
.social-card .form-group { margin-bottom: 8px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: #2e7d32;
  color: #fff;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #b71c1c; }

/* ===== LOGIN SCREEN ===== */
.login-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, #111127 0%, #0a0a18 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-box {
  background: #111127;
  border: 1px solid #1e1e3e;
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 360px;
  width: 90%;
  text-align: center;
}
.login-logo { font-size: 40px; margin-bottom: 12px; }
.login-box h2 { color: #fff; font-size: 18px; margin-bottom: 6px; }
.login-box p { color: #777; font-size: 12px; margin-bottom: 20px; line-height: 1.6; }
.login-box small strong { color: #e57373; }
.login-box .form-input {
  text-align: center;
  font-size: 18px;
  letter-spacing: 4px;
  margin-bottom: 12px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .backup-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 991px) {
  .admin-sidebar { width: 220px; }
  .admin-main { margin-left: 220px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .admin-sidebar {
    width: 260px;
    transform: translateX(-100%);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 16px; }
  .admin-topbar { padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .backup-grid { grid-template-columns: 1fr; }
  .banner-cells { grid-template-columns: 1fr; }
  .social-manager { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
