/* ==========================================================================
   Stumarcot Admin UI
   Design system for the admin panel (templates extending base.html)
   ========================================================================== */

:root {
  --ad-yellow: #ffd700;
  --ad-yellow-dark: #ffa500;
  --ad-sidebar: #16181d;
  --ad-sidebar-hover: rgba(255, 255, 255, 0.06);
  --ad-bg: #f4f6f9;
  --ad-surface: #ffffff;
  --ad-border: #e6e9ee;
  --ad-text: #1f2733;
  --ad-muted: #7a869a;
  --ad-radius: 14px;
  --ad-shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 6px 20px rgba(16, 24, 40, 0.05);
  --ad-sidebar-w: 258px;
}

body.admin-body {
  background: var(--ad-bg);
  color: var(--ad-text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.95rem;
}

/* ===== Sidebar ===== */
.ad-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--ad-sidebar-w);
  background: var(--ad-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.28s ease;
}

.ad-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 22px;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.ad-brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.ad-brand-text {
  line-height: 1.15;
}

.ad-brand-text strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--ad-yellow);
}

.ad-brand-text span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.45);
}

.ad-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 24px;
}

.ad-nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: rgba(255, 255, 255, 0.32);
  padding: 16px 12px 8px;
  font-weight: 700;
}

.ad-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  margin-bottom: 3px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  transition: background 0.18s ease, color 0.18s ease;
}

.ad-nav-link i {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.85;
}

.ad-nav-link:hover {
  background: var(--ad-sidebar-hover);
  color: #fff;
}

.ad-nav-link.active {
  background: linear-gradient(90deg, rgba(255, 215, 0, 0.18), rgba(255, 215, 0, 0.02));
  color: var(--ad-yellow);
  box-shadow: inset 3px 0 0 var(--ad-yellow);
}

.ad-nav-link.active i {
  opacity: 1;
}

.ad-nav-link .ad-count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.ad-sidebar-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.ad-userchip {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 12px;
}

.ad-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ad-yellow), var(--ad-yellow-dark));
  color: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  text-transform: uppercase;
}

.ad-userchip .meta {
  min-width: 0;
  line-height: 1.25;
}

.ad-userchip .name {
  color: #fff;
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-userchip .role {
  font-size: 0.72rem;
  color: var(--ad-yellow);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.ad-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.18s ease, color 0.18s ease;
}

.ad-logout:hover {
  background: #e5484d;
  color: #fff;
}

/* ===== Layout ===== */
.ad-main {
  margin-left: var(--ad-sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.ad-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--ad-border);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.ad-topbar h1 {
  font-size: 1.12rem;
  font-weight: 700;
  margin: 0;
}

.ad-topbar .ad-spacer {
  margin-left: auto;
}

.ad-burger {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--ad-text);
  padding: 6px 10px;
  border-radius: 8px;
}

.ad-burger:hover {
  background: #eef1f5;
}

.ad-viewsite {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 9px;
  border: 1px solid var(--ad-border);
  background: #fff;
  color: var(--ad-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.18s ease;
}

.ad-viewsite:hover {
  border-color: var(--ad-yellow-dark);
  color: #8a6d00;
  background: #fffbe8;
}

.ad-content {
  padding: 28px;
  flex: 1;
}

.ad-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  z-index: 1035;
}

.ad-overlay.show {
  display: block;
}

/* ===== Page head ===== */
.ad-pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.ad-pagehead h2 {
  font-size: 1.55rem;
  font-weight: 700;
  margin: 0 0 5px;
}

.ad-pagehead p {
  color: var(--ad-muted);
  margin: 0;
  font-size: 0.9rem;
}

/* ===== Buttons ===== */
.ad-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.ad-btn-primary {
  background: linear-gradient(135deg, var(--ad-yellow), var(--ad-yellow-dark));
  color: #1a1a1a;
  box-shadow: 0 4px 12px rgba(255, 176, 0, 0.28);
}

.ad-btn-primary:hover {
  color: #1a1a1a;
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(255, 176, 0, 0.38);
}

.ad-btn-ghost {
  background: #fff;
  border-color: var(--ad-border);
  color: var(--ad-text);
}

.ad-btn-ghost:hover {
  background: #f3f5f8;
  color: var(--ad-text);
}

.ad-btn-danger {
  background: #fff;
  border-color: #f3c7c8;
  color: #d13438;
}

.ad-btn-danger:hover {
  background: #d13438;
  border-color: #d13438;
  color: #fff;
}

.ad-btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* ===== Cards ===== */
.ad-card {
  background: var(--ad-surface);
  border: 1px solid var(--ad-border);
  border-radius: var(--ad-radius);
  box-shadow: var(--ad-shadow);
}

.ad-card-head {
  padding: 17px 22px;
  border-bottom: 1px solid var(--ad-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ad-card-head h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.ad-card-body {
  padding: 22px;
}

/* ===== Stat cards ===== */
.ad-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.ad-stat {
  background: var(--ad-surface);
  border: 1px solid var(--ad-border);
  border-radius: var(--ad-radius);
  padding: 20px;
  box-shadow: var(--ad-shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.ad-stat:hover {
  transform: translateY(-3px);
  color: inherit;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.1);
}

.ad-stat-icon {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.ad-stat-icon.amber { background: #fff4d1; color: #b07b00; }
.ad-stat-icon.blue  { background: #e4efff; color: #1c68d4; }
.ad-stat-icon.green { background: #e2f7ec; color: #12805c; }
.ad-stat-icon.violet{ background: #efe8ff; color: #6b3fd4; }

.ad-stat .value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.1;
}

.ad-stat .label {
  color: var(--ad-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ===== Tables ===== */
.ad-table-wrap {
  overflow-x: auto;
}

.ad-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ad-table thead th {
  background: #fafbfc;
  text-align: left;
  padding: 13px 18px;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ad-muted);
  border-bottom: 1px solid var(--ad-border);
  white-space: nowrap;
}

.ad-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid #f1f3f6;
  vertical-align: middle;
}

.ad-table tbody tr:last-child td {
  border-bottom: none;
}

.ad-table tbody tr:hover {
  background: #fafbfd;
}

.ad-table .ad-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.ad-cell-title {
  font-weight: 600;
  color: var(--ad-text);
}

.ad-cell-sub {
  color: var(--ad-muted);
  font-size: 0.82rem;
  margin-top: 2px;
}

.ad-thumb {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
  background: #eef1f5;
}

.ad-thumb-empty {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  background: #eef1f5;
  color: #aab3c0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.ad-media {
  display: flex;
  align-items: center;
  gap: 13px;
}

/* ===== Badges ===== */
.ad-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.ad-badge.green  { background: #e2f7ec; color: #12805c; }
.ad-badge.grey   { background: #eef1f5; color: #6b7684; }
.ad-badge.amber  { background: #fff4d1; color: #a37200; }
.ad-badge.red    { background: #fdeaea; color: #c62b30; }
.ad-badge.blue   { background: #e4efff; color: #1c68d4; }

/* ===== Forms ===== */
.ad-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 20px;
}

.ad-field {
  margin-bottom: 20px;
}

.ad-field.full {
  grid-column: 1 / -1;
}

.ad-field label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 7px;
  color: #384252;
}

.ad-field .req {
  color: #d13438;
}

.ad-input,
.ad-field input[type="text"],
.ad-field input[type="email"],
.ad-field input[type="password"],
.ad-field input[type="number"],
.ad-field input[type="date"],
.ad-field input[type="file"],
.ad-field select,
.ad-field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #d8dee7;
  border-radius: 10px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--ad-text);
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ad-field textarea {
  resize: vertical;
  line-height: 1.6;
}

.ad-field input:focus,
.ad-field select:focus,
.ad-field textarea:focus {
  outline: none;
  border-color: var(--ad-yellow-dark);
  box-shadow: 0 0 0 3px rgba(255, 176, 0, 0.16);
}

.ad-hint {
  font-size: 0.8rem;
  color: var(--ad-muted);
  margin-top: 6px;
}

.ad-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid var(--ad-border);
  border-radius: 10px;
  background: #fafbfc;
}

.ad-check input {
  width: 17px;
  height: 17px;
  margin-top: 1px;
  accent-color: var(--ad-yellow-dark);
  flex: 0 0 auto;
}

.ad-check label {
  margin: 0;
  font-weight: 600;
  font-size: 0.87rem;
  cursor: pointer;
}

.ad-check .ad-hint {
  margin-top: 3px;
}

.ad-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--ad-border);
  margin-top: 4px;
  padding-top: 20px;
}

/* ===== Flash messages ===== */
/* Carries Bootstrap's .alert classes so the dismiss button works; these
   rules override Bootstrap's default alert visuals and button positioning. */
.ad-flash {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 11px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  position: relative;
}

.ad-flash.alert-dismissible {
  padding-right: 18px;
}

.ad-flash.alert-dismissible .btn-close {
  position: static;
  padding: 0;
  margin: 0 0 0 auto;
  flex: 0 0 auto;
}

.ad-flash i {
  font-size: 1rem;
}

.ad-flash.success {
  background: #e8f8f0;
  border-color: #bce8d4;
  color: #12805c;
}

.ad-flash.error {
  background: #fdeced;
  border-color: #f6cbcd;
  color: #c62b30;
}

.ad-flash .btn-close {
  margin-left: auto;
  opacity: 0.5;
}

/* ===== Empty state ===== */
.ad-empty {
  text-align: center;
  padding: 64px 24px;
}

.ad-empty-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 20px;
  background: #f1f3f7;
  color: #aab3c0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
}

.ad-empty h4 {
  font-size: 1.08rem;
  font-weight: 700;
  margin-bottom: 7px;
}

.ad-empty p {
  color: var(--ad-muted);
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* ===== Quick actions ===== */
.ad-quick {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  border: 1px solid var(--ad-border);
  border-radius: 11px;
  text-decoration: none;
  color: inherit;
  margin-bottom: 10px;
  transition: all 0.18s ease;
}

.ad-quick:last-child {
  margin-bottom: 0;
}

.ad-quick:hover {
  border-color: var(--ad-yellow-dark);
  background: #fffdf4;
  color: inherit;
  transform: translateX(3px);
}

.ad-quick i:first-child {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 10px;
  background: #fff4d1;
  color: #b07b00;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-quick .txt {
  font-weight: 600;
  font-size: 0.9rem;
}

.ad-quick .fa-chevron-right {
  margin-left: auto;
  color: #c3cad4;
  font-size: 0.75rem;
}

/* ===== Recent list ===== */
.ad-list-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 0;
  border-bottom: 1px solid #f1f3f6;
}

.ad-list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ad-list-item:first-child {
  padding-top: 0;
}

/* ===== Login screen (anonymous) ===== */
body.admin-login {
  background: linear-gradient(135deg, #16181d 0%, #2c3e50 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ad-login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 40px 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}

.ad-login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.ad-login-brand img {
  width: 62px;
  margin-bottom: 12px;
}

.ad-login-brand h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 0 5px;
}

.ad-login-brand p {
  color: var(--ad-muted);
  font-size: 0.87rem;
  margin: 0;
}

.ad-login-card .ad-btn {
  width: 100%;
  justify-content: center;
  padding: 12px;
}

.ad-back-link {
  display: block;
  text-align: center;
  margin-top: 22px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.85rem;
  text-decoration: none;
}

.ad-back-link:hover {
  color: var(--ad-yellow);
}

/* Plain shell for anonymous visitors on legacy pages */
.ad-plain-top {
  background: var(--ad-sidebar);
  padding: 15px 0;
}

.ad-plain-top .ad-brand {
  border: none;
  padding: 0;
}

/* ===== Responsive ===== */
@media (max-width: 991px) {
  .ad-sidebar {
    transform: translateX(-100%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
  }

  .ad-sidebar.open {
    transform: translateX(0);
  }

  .ad-main {
    margin-left: 0;
  }

  .ad-burger {
    display: block;
  }
}

@media (max-width: 767px) {
  .ad-content {
    padding: 18px;
  }

  .ad-topbar {
    padding: 0 16px;
  }

  .ad-viewsite span {
    display: none;
  }

  .ad-pagehead h2 {
    font-size: 1.3rem;
  }

  .ad-card-body {
    padding: 18px;
  }
}
