/* ============================================
   BLADESMITH ADMIN V2 - COMPONENTS & LAYOUT
   ============================================ */

/* ===== LAYOUT ===== */
.admin-container {
  display: grid;
  grid-template-columns: 16.25rem 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  gap: 0;
}

body.sidebar-collapsed .admin-container {
  grid-template-columns: 5.25rem 1fr;
}

body.sidebar-collapsed .admin-sidebar {
  width: 5.25rem;
}

body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-link span:not(.nav-icon) {
  display: none;
}

body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding-inline: 0;
}

body.sidebar-collapsed .nav-link {
  justify-content: center;
  padding-inline: 0;
}

body.sidebar-collapsed .sidebar-nav {
  padding-inline: 0.25rem;
}

.sidebar-toggle {
  width: 2.625rem;
  height: 2.625rem;
  border-radius: var(--radius-md);
  border: 0.0625rem solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-toggle.global-toggle {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: var(--z-fixed);
}

body:not(.sidebar-collapsed) .sidebar-toggle.global-toggle {
  left: 13.75rem;
}

/* hide the sidebar brand icon (logo) when the sidebar is collapsed */
body.sidebar-collapsed .sidebar-brand-icon {
  display: none;
}

.sidebar-toggle:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.admin-sidebar {
  grid-row: 1 / -1;
  background-color: var(--bg-secondary);
  border-right: 0.0625rem solid var(--border-color);
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.admin-header {
  grid-column: 2;
  background-color: var(--bg-secondary);
  border-bottom: 0.0625rem solid var(--border-color);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle-wrap {
  display: flex;
  align-items: center;
}

body.sidebar-collapsed .admin-header,
body.sidebar-collapsed .admin-main {
  grid-column: 2;
}

.admin-main {
  grid-column: 2;
  background-color: var(--bg-primary);
  overflow-y: auto;
  padding: 2rem;
}

/* SIDEBAR */
.sidebar-brand {
  padding: 1.5rem 1rem;
  border-bottom: 0.0625rem solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 1.2rem;
}

.sidebar-brand-text h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
  letter-spacing: .05em;
}
.sidebar-brand-text h3 span {
  color: var(--accent-500);
}

.sidebar-brand-text p {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin: 0.125rem 0 0 0;
  text-transform: uppercase;
  letter-spacing: 0.0312rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.5rem;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 1rem;
}

.nav-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  color: var(--text-tertiary);
  padding: 0.75rem 1rem;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin: 0 0.5rem 0.25rem 0.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  position: relative;
}

.nav-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-link.active {
  background: linear-gradient(90deg, var(--primary-500) 0%, var(--primary-600) 100%);
  color: white;
  font-weight: 600;
}

.nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.nav-badge {
  margin-left: auto;
  background-color: var(--accent-500);
  color: white;
  font-size: 0.7rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  min-width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 0.0625rem solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.user-card {
  background-color: var(--bg-tertiary);
  padding: 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--secondary-500), var(--accent-500));
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: white;
  font-size: 1rem;
  flex-shrink: 0;
}

.user-info {
  font-size: 0.9rem;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.user-info h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info p {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin: 0.25rem 0 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* HEADER */
.header-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
}

.header-title p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-0.0625rem);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 0.0625rem solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--neutral-700);
  border-color: var(--neutral-600);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-accent:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-0.0625rem);
}

.btn-danger {
  background: linear-gradient(135deg, var(--warn-500), var(--warn-600));
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-0.0625rem);
}

.btn-success {
  background: linear-gradient(135deg, var(--success-500), var(--success-600));
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-success:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-0.0625rem);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border: 0.0625rem solid transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-tertiary);
  border-color: var(--border-color);
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-icon {
  width: 2.5rem;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; max-width: 22rem; }
.toast { display: flex; align-items: center; gap: 0.6rem; padding: 0.75rem 1rem; border-radius: var(--radius-lg); background: var(--bg-secondary); border: 0.0625rem solid var(--border-color); box-shadow: var(--shadow-lg); animation: toast-in 0.25s ease-out; font-size: 0.85rem; color: var(--text-primary); }
.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-message { flex: 1; line-height: 1.4; }
.toast-success { border-color: var(--success-500); } .toast-success .toast-icon { color: var(--success-500); }
.toast-error { border-color: var(--error-500); } .toast-error .toast-icon { color: var(--error-500); }
.toast-warning { border-color: var(--warning-500); } .toast-warning .toast-icon { color: var(--warning-500); }
.toast-info { border-color: var(--info-500); } .toast-info .toast-icon { color: var(--info-500); }
@keyframes toast-in { from { opacity: 0; transform: translateX(1rem); } to { opacity: 1; transform: translateX(0); } }

/* ===== NOTIFICATION TOGGLE ===== */
.notif-toggle { background: none; border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 0.4rem 0.55rem; font-size: 1.1rem; cursor: pointer; transition: opacity 0.2s, border-color 0.2s; line-height: 1; }
.notif-toggle:hover { border-color: var(--primary-500); }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s; pointer-events: none; backdrop-filter: blur(2px); }
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal { background: var(--bg-secondary); border: 0.0625rem solid var(--border-color); border-radius: var(--radius-xl); width: 90%; max-width: 32rem; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-2xl); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 0.0625rem solid var(--border-light); }
.modal-close { background: none; border: none; color: var(--text-tertiary); font-size: 1.5rem; cursor: pointer; line-height: 1; padding: 0.25rem; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.5rem; }

/* Mobile hamburger toggle */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-lg);
  background: var(--bg-secondary);
  border: 0.0625rem solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.4rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md);
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 899;
  backdrop-filter: blur(2px);
}

@media (max-width: 64rem) {
  .mobile-menu-btn {
    display: flex;
  }

  .admin-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  body.sidebar-collapsed .admin-container {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 17rem;
    height: 100vh;
    z-index: 900;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 0.0625rem solid var(--border-color);
    box-shadow: var(--shadow-2xl);
  }

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

  .admin-sidebar.open ~ .mobile-overlay {
    display: block;
  }

  body.sidebar-collapsed .admin-sidebar {
    width: 17rem;
  }

  .admin-header,
  .admin-main {
    grid-column: 1;
  }

  .admin-header {
    position: sticky;
    top: 0;
    padding: 1.25rem 1.25rem 1rem;
    padding-left: 4.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .admin-main {
    padding: 1.25rem;
    overflow-x: hidden;
  }

  .header-actions,
  .sidebar-toggle-wrap {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 48rem) {
  .admin-header {
    padding: 1rem;
    padding-left: 4rem;
    flex-direction: column;
    align-items: flex-start;
  }

  .header-title h1 {
    font-size: 1.35rem;
  }

  .header-title p {
    font-size: 0.8rem;
  }

  .admin-main {
    padding: 0.75rem;
  }

  .chart-card,
  .panel,
  .table-card,
  .form-card {
    padding: 0.875rem;
    border-radius: var(--radius-lg);
  }

  .section-header,
  .dashboard-topbar,
  .logs-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .settings-grid {
    grid-template-columns: 1fr !important;
  }

  .settings-grid-half {
    grid-template-columns: 1fr !important;
  }

  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.5rem 0.625rem;
  }

  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
  }
}

/* ============================================
   UTILITY CLASSES — use instead of inline styles
   ============================================ */
.u-hidden { display: none !important; }
.u-flex { display: flex; }
.u-block { display: block; }
.u-inline-flex { display: inline-flex; }
.u-text-center { text-align: center; }
.u-text-left { text-align: left; }
.u-text-right { text-align: right; }
.u-bold { font-weight: 600; }
.u-pointer { cursor: pointer; }
.u-full-width { width: 100%; }
.u-mt-0 { margin-top: 0; }
.u-mt-sm { margin-top: 0.5rem; }
.u-mt-md { margin-top: 1rem; }
.u-mt-lg { margin-top: 1.5rem; }
.u-mb-0 { margin-bottom: 0; }
.u-mb-sm { margin-bottom: 0.5rem; }
.u-mb-md { margin-bottom: 1rem; }
.u-mb-lg { margin-bottom: 1.5rem; }
.u-muted { opacity: 0.6; }
.u-overflow-x { overflow-x: auto; }
.u-gap-sm { gap: 0.5rem; }
.u-gap-md { gap: 1rem; }
.u-p-md { padding: 1rem; }
.u-border-collapse { width: 100%; border-collapse: collapse; }