/* ==================== SIDEBAR LINKS ==================== */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.sidebar-link:hover { background: #f1f5f9; color: #1e293b; }
.sidebar-link.active { background: #eff6ff; color: #2563eb; font-weight: 600; }

.sidebar-link-admin {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.sidebar-link-admin:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link-admin.active { background: rgba(59,130,246,0.25); color: #93c5fd; }

/* ==================== BUTTONS ==================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #f1f5f9;
  color: #334155;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #ef4444;
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}
.btn-danger:hover { background: #dc2626; }

/* ==================== FORM ==================== */
.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: #0f172a;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.form-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.form-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.375rem;
}

/* ==================== CARDS ==================== */
.card {
  background: #fff;
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* ==================== BADGE ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* ==================== TOAST ==================== */
#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  padding: 0.75rem 1.25rem;
  border-radius: 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  min-width: 200px;
}

/* ==================== MODAL ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

/* ==================== TABLE ==================== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.data-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}
.data-table tr:hover td { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }

/* ==================== TOGGLE ==================== */
.toggle-wrapper { display: flex; align-items: center; gap: 0.75rem; }
.toggle {
  position: relative;
  width: 2.75rem;
  height: 1.5rem;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 9999px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 1.1rem;
  height: 1.1rem;
  left: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: #2563eb; }
.toggle input:checked + .toggle-slider::before { transform: translateY(-50%) translateX(1.25rem); }

/* ==================== AVATAR ==================== */
.avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ==================== RESPONSIVE SIDEBAR ==================== */

/* Mobile topbar: hidden by default (desktop), shown via media query on mobile */
.mobile-topbar { display: none; }

@media (max-width: 767px) {
  /* Sidebar slides off-canvas by default on mobile */
  .sidebar-responsive {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar-responsive.sidebar-open {
    transform: translateX(0);
  }
  /* Main content has no left margin on mobile */
  .main-responsive {
    margin-left: 0 !important;
  }
  /* Mobile top bar */
  .mobile-topbar {
    display: flex;
  }
  /* Section header: stack on mobile */
  .section-header-flex {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

@media (min-width: 768px) {
  /* Sidebar always visible on desktop */
  .sidebar-responsive {
    transform: translateX(0) !important;
  }
  /* Main content offset */
  .main-responsive {
    margin-left: 16rem;
  }
  .mobile-topbar {
    display: none !important;
  }
  .section-header-flex {
    flex-direction: row;
    align-items: center;
  }
}

/* Sidebar overlay (mobile only) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 25;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ==================== RESPONSIVE TABLES (stacked cards on mobile) ==================== */
@media (max-width: 767px) {
  /* Hide the horizontal scroll wrapper's scrollbar need by stacking */
  .data-table thead { display: none; }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td {
    display: block;
    width: 100%;
  }
  .data-table tr {
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
    background: #fff;
    padding: 0.25rem 0;
  }
  .data-table tr:hover td { background: transparent; }
  .data-table tr:last-child { margin-bottom: 0; }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.55rem 0.875rem;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    text-align: right;
  }
  .data-table td:last-child { border-bottom: none; }
  /* Show the column name as a label before each value */
  .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    text-align: left;
    flex-shrink: 0;
  }
  /* Empty-state / loading rows (single colspan cell) stay centered */
  .data-table td[colspan] {
    justify-content: center;
    text-align: center;
  }
  .data-table td[colspan]::before { content: none; }
}

/* ==================== RESPONSIVE MODAL FORMS ==================== */
@media (max-width: 480px) {
  /* Stack two-column form grids into one column on small phones */
  .modal-backdrop .grid-cols-2 {
    grid-template-columns: 1fr;
  }
  .modal-backdrop .grid-cols-2 .col-span-2 {
    grid-column: span 1 / span 1;
  }
}
