/* ===========================================================
   Suriya Dental Depot — Admin page styles
   Internal tool only, not linked from public nav.
=========================================================== */

body.admin-body {
  background: var(--off-white);
  min-height: 100vh;
}

/* ---------- Login screen ---------- */
.admin-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-login-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.admin-login-card img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; margin-bottom: 14px; }
.admin-login-card h1 { font-family: var(--font-head); font-size: 1.3rem; color: var(--navy); margin-bottom: 6px; }
.admin-login-card p.sub { color: var(--grey); font-size: 0.9rem; margin-bottom: 24px; }
.admin-login-card input[type="password"], .admin-login-card input[type="email"] {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--grey-light);
  border-radius: 8px; font-size: 1rem; margin-bottom: 14px; font-family: var(--font-body);
}
.admin-login-card input[type="password"]:focus, .admin-login-card input[type="email"]:focus { outline: none; border-color: var(--red); }
.admin-login-error { color: var(--red); font-size: 0.85rem; min-height: 20px; margin-bottom: 6px; }
.admin-login-hint { color: var(--grey); font-size: 0.78rem; margin-top: 18px; line-height: 1.5; }

/* ---------- Dashboard shell ---------- */
.admin-topbar {
  background: var(--navy);
  color: var(--white);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}
.admin-topbar .admin-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; }
.admin-topbar .admin-brand img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.admin-topbar-actions { display: flex; align-items: center; gap: 14px; }
.admin-topbar-actions a, .admin-topbar-actions button {
  color: var(--white); background: transparent; border: 1.5px solid rgba(255,255,255,0.35);
  border-radius: 8px; padding: 7px 14px; font-size: 0.85rem; cursor: pointer; font-family: var(--font-body);
}
.admin-topbar-actions a:hover, .admin-topbar-actions button:hover { background: rgba(255,255,255,0.12); }

.admin-banner {
  background: #FFF7E0; color: #7A5B00; border-bottom: 1px solid #F0DFA0;
  padding: 10px 24px; font-size: 0.85rem; text-align: center;
}
.admin-banner strong { color: #5A4200; }

.admin-main { max-width: 1200px; margin: 0 auto; padding: 24px; }

.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; border-bottom: 2px solid var(--grey-light); }
.admin-tab {
  padding: 10px 18px; font-family: var(--font-head); font-weight: 600; font-size: 0.95rem;
  color: var(--grey); background: transparent; border: none; cursor: pointer;
  border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.admin-tab.active { color: var(--red); border-bottom-color: var(--red); }

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

.admin-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-toolbar select, .admin-toolbar input[type="search"] {
  padding: 9px 12px; border: 1.5px solid var(--grey-light); border-radius: 8px; font-family: var(--font-body); font-size: 0.9rem;
}
.admin-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 8px;
  font-weight: 600; font-size: 0.88rem; cursor: pointer; border: none; font-family: var(--font-body);
}
.admin-btn-primary { background: var(--red); color: var(--white); }
.admin-btn-primary:hover { background: var(--red-dark); }
.admin-btn-outline { background: transparent; color: var(--navy); border: 1.5px solid var(--navy); }
.admin-btn-outline:hover { background: var(--navy); color: var(--white); }
.admin-btn-danger { background: transparent; color: var(--red); border: 1.5px solid var(--red); padding: 6px 12px; font-size: 0.8rem; }
.admin-btn-danger:hover { background: var(--red); color: var(--white); }
.admin-btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.admin-btn-move { padding: 6px 10px; font-size: 0.85rem; line-height: 1; }
.admin-btn-move:disabled { opacity: 0.3; cursor: default; }
.admin-btn-move:disabled:hover { background: transparent; color: var(--navy); }

/* ---------- Product table ---------- */
.admin-table-wrap { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-table th, .admin-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--grey-light); font-size: 0.9rem; }
.admin-table th { background: var(--off-white); color: var(--navy); font-family: var(--font-head); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: contain; background: var(--off-white); }
.admin-row-actions { display: flex; gap: 8px; }
.admin-empty-row td { text-align: center; color: var(--grey); padding: 30px; }

/* ---------- Modal form ---------- */
.admin-modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(11,31,75,0.55);
  align-items: center; justify-content: center; padding: 20px; z-index: 200;
}
.admin-modal-overlay.open { display: flex; }
.admin-modal {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 28px;
}
.admin-modal h2 { font-family: var(--font-head); color: var(--navy); font-size: 1.2rem; margin-bottom: 18px; }
.admin-field { margin-bottom: 16px; }
.admin-field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
.admin-field input[type="text"], .admin-field input[type="url"], .admin-field select, .admin-field textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--grey-light); border-radius: 8px;
  font-family: var(--font-body); font-size: 0.92rem;
}
.admin-field textarea { resize: vertical; min-height: 80px; }
.admin-field-row { display: flex; gap: 12px; }
.admin-field-row .admin-field { flex: 1; }
.admin-field-hint { font-size: 0.75rem; color: var(--grey); margin-top: 4px; }
.admin-new-cat-row { display: flex; gap: 8px; margin-top: 8px; }
.admin-new-cat-row input { flex: 1; }
.admin-img-preview { margin-top: 8px; width: 100%; height: 140px; border-radius: 8px; object-fit: contain; background: var(--off-white); display: none; }
.admin-img-preview.show { display: block; }

.admin-image-slots { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.admin-image-slot { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--off-white); border: 1.5px solid var(--grey-light); }
.admin-image-slot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.admin-image-slot .admin-image-remove {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(11,31,75,0.75); color: var(--white); border: none; cursor: pointer;
  font-size: 0.75rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.admin-image-slot .admin-image-remove:hover { background: var(--red); }
.admin-image-slot-add {
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 2px;
  background: var(--off-white); border: 1.5px dashed var(--grey-light); cursor: pointer;
  color: var(--grey); font-size: 1.6rem; font-weight: 300;
}
.admin-image-slot-add:hover { border-color: var(--red); color: var(--red); }
.admin-image-slot-add span.label { font-size: 0.65rem; font-weight: 600; }
.admin-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- Categories tab ---------- */
.admin-cat-section { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.admin-cat-section h3 { font-family: var(--font-head); color: var(--navy); font-size: 1.02rem; margin-bottom: 12px; }
.admin-cat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.admin-cat-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--off-white);
  border: 1px solid var(--grey-light); border-radius: 20px; padding: 6px 8px 6px 14px; font-size: 0.85rem;
}
.admin-cat-chip button { background: none; border: none; color: var(--grey); cursor: pointer; font-size: 0.95rem; line-height: 1; padding: 2px 4px; }
.admin-cat-chip button:hover { color: var(--red); }
.admin-cat-move:hover { color: var(--navy) !important; }
.admin-cat-move:disabled { opacity: 0.25; cursor: default; }
.admin-cat-move:disabled:hover { color: var(--grey) !important; }
.admin-cat-add { display: flex; gap: 8px; }
.admin-cat-add input { flex: 1; padding: 9px 12px; border: 1.5px solid var(--grey-light); border-radius: 8px; font-family: var(--font-body); }

@media (max-width: 640px) {
  .admin-field-row { flex-direction: column; }
  .admin-main { padding: 16px; }
  .admin-topbar { padding: 12px 16px; }

  /* Tab bar -> smaller, tighter tabs so all of them wrap onto screen
     instead of being clipped off past the right edge. */
  .admin-tabs { gap: 4px 10px; }
  .admin-tab { padding: 8px 4px; font-size: 0.82rem; }

  /* Product table -> stacked cards, so Edit/Delete are never scrolled off-screen */
  .admin-table-wrap { overflow: visible; box-shadow: none; background: none; }
  .admin-table { min-width: 0; }
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody { display: block; width: 100%; }
  .admin-table tr {
    display: grid;
    grid-template-columns: 46px 1fr;
    grid-template-areas: "photo name" "photo section" "photo category" "actions actions";
    column-gap: 12px; row-gap: 2px;
    background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px; margin-bottom: 12px;
  }
  .admin-table.admin-empty-row-parent tr { display: block; }
  .admin-table td { display: block; border-bottom: none; padding: 0; font-size: 0.88rem; }
  .admin-table td:nth-child(1) { grid-area: photo; }
  .admin-table td:nth-child(2) { grid-area: name; font-weight: 700; color: var(--navy); align-self: center; }
  .admin-table td:nth-child(3) { grid-area: section; color: var(--grey); }
  .admin-table td:nth-child(4) { grid-area: category; color: var(--grey); margin-bottom: 8px; }
  .admin-table td:nth-child(5) { grid-area: actions; }
  .admin-table .admin-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
  .admin-table .admin-row-actions .admin-btn-move { flex: 0 0 auto; padding: 6px 14px; }
  .admin-table .admin-row-actions .admin-btn:not(.admin-btn-move) { flex: 1 1 calc(50% - 3px); justify-content: center; }
  .admin-empty-row { display: block !important; padding: 30px 0; text-align: center; }
  .admin-empty-row td { display: block !important; }
}
