/* ============================================================
   MIA & MAX — ADMIN STYLESHEET
   ============================================================ */

:root {
  --a-pink:    #FF6B9D;
  --a-blue:    #4ECDC4;
  --a-yellow:  #FFE14D;
  --a-purple:  #A855F7;
  --a-orange:  #FF9F43;
  --a-dark:    #1a1040;
  --a-dark2:   #0d0820;
  --a-sidebar-w: 260px;
  --a-topbar-h:  64px;
  --a-white:   #ffffff;
  --a-light:   #f5f7ff;
  --a-light2:  #eef0fb;
  --a-text:    #2d2d4e;
  --a-text2:   #6b7280;
  --a-border:  #e5e7eb;
  --a-shadow:  0 4px 16px rgba(0,0,0,0.08);
  --a-radius:  16px;
  --a-radius-sm: 10px;
  --a-font-head: 'Baloo 2', cursive;
  --a-font-body: 'Nunito', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--a-font-body); color: var(--a-text); background: var(--a-light); }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

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

/* ──────── SIDEBAR ──────── */
.admin-sidebar {
  width: var(--a-sidebar-w);
  background: linear-gradient(180deg, var(--a-dark) 0%, var(--a-dark2) 100%);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 4px 0 24px rgba(0,0,0,0.2);
}

.sidebar-header {
  padding: 24px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.sidebar-logo {
  height: 40px;
  filter: drop-shadow(0 2px 8px rgba(255,107,157,0.4));
}
.sidebar-close {
  color: rgba(255,255,255,0.5);
  font-size: 1.1rem;
  display: none;
  padding: 4px 8px;
  transition: color 0.2s;
}
.sidebar-close:hover { color: var(--a-pink); }

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--a-radius-sm);
  color: rgba(255,255,255,0.6);
  font-family: var(--a-font-head);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
  position: relative;
}
.sidebar-link i { width: 20px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.sidebar-link:hover {
  background: rgba(255,255,255,0.07);
  color: var(--a-white);
}
.sidebar-link.active {
  background: linear-gradient(135deg, rgba(255,107,157,0.25), rgba(168,85,247,0.25));
  color: var(--a-white);
  border: 1px solid rgba(255,107,157,0.3);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: linear-gradient(var(--a-pink), var(--a-purple));
  border-radius: 0 2px 2px 0;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-char {
  height: 52px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
  animation: float-sidebar 3.5s ease-in-out infinite;
}
.sidebar-char:nth-child(2) { animation-delay: 0.5s; animation-duration: 4s; }
@keyframes float-sidebar {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

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

/* ──────── TOPBAR ──────── */
.admin-topbar {
  height: var(--a-topbar-h);
  background: var(--a-white);
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.topbar-menu-btn {
  font-size: 1.15rem;
  color: var(--a-text2);
  display: none;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.topbar-menu-btn:hover { background: var(--a-light2); color: var(--a-purple); }
.topbar-title { flex: 1; }
.topbar-title h1 { font-family: var(--a-font-head); font-size: 1.2rem; font-weight: 800; color: var(--a-dark); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--a-light2);
  color: var(--a-text2);
  font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.topbar-btn:hover { background: var(--a-light); color: var(--a-purple); }
.btn-publish {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: linear-gradient(135deg, #FF6B9D, #A855F7);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.btn-publish:hover  { opacity: 0.88; transform: scale(1.03); }
.btn-publish:active { transform: scale(0.97); }
.topbar-avatar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(255,107,157,0.1), rgba(168,85,247,0.1));
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--a-dark);
  border: 1.5px solid rgba(168,85,247,0.2);
}
.topbar-avatar i { color: var(--a-purple); }

/* ──────── CONTENT ──────── */
.admin-content { flex: 1; padding: 28px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}
.admin-page-header h2 {
  font-family: var(--a-font-head);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--a-dark);
}
.admin-page-header p { font-size: 0.9rem; color: var(--a-text2); margin-top: 2px; }

/* ──────── CARDS ──────── */
.admin-card {
  background: var(--a-white);
  border-radius: var(--a-radius);
  box-shadow: var(--a-shadow);
  border: 1px solid var(--a-border);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--a-border);
  background: var(--a-light);
}
.card-header h3 {
  font-family: var(--a-font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--a-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header h3 i { color: var(--a-purple); }
.card-action {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--a-purple);
  padding: 4px 12px;
  border-radius: 50px;
  background: rgba(168,85,247,0.08);
  transition: background 0.2s;
}
.card-action:hover { background: rgba(168,85,247,0.15); }

/* ──────── STATS GRID ──────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--a-white);
  border-radius: var(--a-radius);
  padding: 24px;
  box-shadow: var(--a-shadow);
  border: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--a-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-info strong {
  display: block;
  font-family: var(--a-font-head);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--a-dark);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-info span { font-size: 0.85rem; color: var(--a-text2); font-weight: 600; }

/* ──────── OVERVIEW GRID ──────── */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ──────── TABLE ──────── */
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table th {
  background: var(--a-light);
  padding: 12px 16px;
  text-align: left;
  font-family: var(--a-font-head);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--a-text2);
  border-bottom: 2px solid var(--a-border);
  white-space: nowrap;
}
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--a-border);
  color: var(--a-text);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--a-light); }
.admin-table .book-mini-cover {
  width: 40px; height: 52px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.admin-table .no-cover {
  width: 40px; height: 52px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: var(--a-light2);
}
.badge-sm {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-available { background: rgba(78,205,196,0.15); color: #0d9488; }
.badge-unavailable { background: rgba(107,114,128,0.12); color: #6b7280; }
.tbl-actions { display: flex; gap: 8px; }
.btn-edit, .btn-delete {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  transition: opacity 0.2s, transform 0.2s;
  display: inline-flex; align-items: center; gap: 5px;
}
.btn-edit   { background: rgba(168,85,247,0.1); color: var(--a-purple); }
.btn-delete { background: rgba(255,99,99,0.1);  color: #dc2626; }
.btn-edit:hover   { background: rgba(168,85,247,0.2); transform: scale(1.04); }
.btn-delete:hover { background: rgba(255,99,99,0.2);  transform: scale(1.04); }

/* ──────── FORMS ──────── */
.admin-form { padding: 24px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--a-text2);
  margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--a-border);
  border-radius: var(--a-radius-sm);
  font-family: var(--a-font-body);
  font-size: 0.95rem;
  color: var(--a-text);
  background: var(--a-white);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--a-purple);
  box-shadow: 0 0 0 3px rgba(168,85,247,0.1);
}
.form-group input[type="color"] {
  padding: 4px 8px;
  height: 42px;
  cursor: pointer;
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--a-border);
}

/* ──────── BUTTONS ──────── */
.btn-add {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px;
  background: linear-gradient(135deg, var(--a-pink), var(--a-purple));
  color: #fff;
  border-radius: 50px;
  font-family: var(--a-font-head);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(255,107,157,0.35);
  transition: all 0.2s;
}
.btn-add:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,107,157,0.45); }

.btn-save {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--a-blue), #2a9d8f);
  color: #fff;
  border-radius: 50px;
  font-family: var(--a-font-head);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(78,205,196,0.35);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-save:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(78,205,196,0.45); }

.btn-cancel {
  padding: 10px 22px;
  background: var(--a-light2);
  color: var(--a-text2);
  border-radius: 50px;
  font-family: var(--a-font-head);
  font-weight: 700;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.btn-cancel:hover { background: var(--a-border); }

.btn-export {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 20px;
  background: rgba(78,205,196,0.1);
  color: #0d9488;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  transition: background 0.2s;
  cursor: pointer;
}
.btn-export:hover { background: rgba(78,205,196,0.2); }

.btn-import {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 20px;
  background: rgba(168,85,247,0.1);
  color: var(--a-purple);
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-import:hover { background: rgba(168,85,247,0.2); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 20px;
  background: rgba(220,38,38,0.1);
  color: #dc2626;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-danger:hover { background: rgba(220,38,38,0.2); }

/* ──────── ADMIN MODAL ──────── */
.admin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.admin-modal.open { opacity: 1; pointer-events: all; }
.admin-modal-box {
  background: var(--a-white);
  border-radius: var(--a-radius);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  transform: scale(0.95) translateY(16px);
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.admin-modal.open .admin-modal-box { transform: scale(1) translateY(0); }
.admin-modal-box--sm { max-width: 440px; }
.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--a-border);
  background: var(--a-light);
}
.admin-modal-header h3 {
  font-family: var(--a-font-head);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--a-dark);
}
.admin-modal-close {
  font-size: 1.5rem;
  color: var(--a-text2);
  line-height: 1;
  transition: color 0.2s, transform 0.2s;
}
.admin-modal-close:hover { color: var(--a-dark); transform: rotate(90deg); }

/* ──────── SETTINGS ──────── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.settings-actions { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.settings-action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--a-light);
  border-radius: var(--a-radius-sm);
  flex-wrap: wrap;
}
.settings-action-item strong { display: block; font-weight: 700; color: var(--a-dark); margin-bottom: 4px; }
.settings-action-item p { font-size: 0.82rem; color: var(--a-text2); }
.settings-action-item.danger-zone { background: rgba(220,38,38,0.04); border: 1px solid rgba(220,38,38,0.12); }

.system-info { padding: 24px; }
.sys-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--a-border);
  font-size: 0.9rem;
}
.sys-row:last-child { border-bottom: none; }
.sys-row span { color: var(--a-text2); }

/* ──────── SEARCH ──────── */
.admin-search {
  width: 100%;
  max-width: 400px;
  padding: 10px 16px;
  border: 1.5px solid var(--a-border);
  border-radius: 50px;
  font-family: var(--a-font-body);
  font-size: 0.95rem;
  outline: none;
  background: var(--a-white);
  margin: 16px 24px;
  display: block;
  transition: border-color 0.2s;
}
.admin-search:focus { border-color: var(--a-purple); }
.store-filter-admin { background: var(--a-light); border-bottom: 1px solid var(--a-border); }

/* ──────── CONTENT EDITOR ──────── */
.content-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.json-preview {
  background: #1e1e3f;
  color: #a3d977;
  padding: 20px 24px;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  max-height: 400px;
  overflow-y: auto;
  border-radius: 0 0 var(--a-radius) var(--a-radius);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ──────── ALERT ──────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--a-radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  display: none;
}
.alert.show { display: block; }
.alert.success { background: rgba(78,205,196,0.12); color: #0d9488; border: 1px solid rgba(78,205,196,0.3); }
.alert.error   { background: rgba(220,38,38,0.08);  color: #dc2626; border: 1px solid rgba(220,38,38,0.2); }

/* ──────── TOAST ──────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--a-dark);
  color: #fff;
  border-radius: var(--a-radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 260px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
  border-left: 4px solid var(--a-blue);
}
.toast.toast-error   { border-color: #dc2626; }
.toast.toast-warning { border-color: var(--a-yellow); }
.toast.toast-success { border-color: var(--a-blue); }
.toast.toast-out { animation: toastOut 0.3s ease forwards; }
.toast i { font-size: 1.1rem; flex-shrink: 0; }
@keyframes toastIn  { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* ──────── OVERVIEW LISTS ──────── */
.overview-list { padding: 0 24px; }
.overview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--a-border);
}
.overview-item:last-child { border-bottom: none; }
.overview-item-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: var(--a-light2);
}
.overview-item-info strong { display: block; font-weight: 700; font-size: 0.9rem; color: var(--a-dark); }
.overview-item-info span { font-size: 0.78rem; color: var(--a-text2); }

/* ──────── EMPTY STATE ──────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--a-text2);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ──────── RESPONSIVE ──────── */
@media (max-width: 1024px) {
  .overview-grid        { grid-template-columns: 1fr; }
  .settings-grid        { grid-template-columns: 1fr; }
  .content-editor-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close { display: block; }
  .admin-main    { margin-left: 0; }
  .topbar-menu-btn { display: flex; }
  .admin-content { padding: 16px; }
  .admin-topbar  { padding: 0 16px; }
  .stats-grid    { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-row   { grid-template-columns: 1fr; }
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 10px 10px; }
}

/* ──────── SCROLLBAR ──────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(168,85,247,0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(168,85,247,0.5); }
