/* Shared components */

/* Smooth scrollbars everywhere */
* {
  scrollbar-color: rgba(157, 181, 168, 0.18) transparent;
  scrollbar-width: thin;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(157, 181, 168, 0.18); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(157, 181, 168, 0.35); }

/* Selection color */
::selection {
  background: rgba(52, 214, 160, 0.25);
  color: #F1F8F4;
}

/* Respect the OS "reduce motion" preference. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Alert success */
.alert-success {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.08);
  color: #a7f3d0;
}

/* Alert warning */
.alert-warning {
  border-color: rgba(250, 204, 21, 0.45);
  background: rgba(250, 204, 21, 0.08);
  color: #fef08a;
}

/* Validation summary without bullet points */
.validation-plain ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Page header */
.page-header {
  margin-bottom: 1.25rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #F1F8F4;
  margin: 0;
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--apex-muted);
  margin: 0.2rem 0 0;
}

/* Admin section heading */
.admin-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1.75rem 0 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--apex-muted);
}

.admin-section-title svg {
  color: var(--apex-accent, #34D6A0);
  flex-shrink: 0;
}

/* Admin workspace */
.admin-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.admin-alerts:empty {
  display: none;
}

.admin-alerts .alert {
  margin-bottom: 0.75rem;
}

.admin-alerts .alert:last-child {
  margin-bottom: 0;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.6rem;
  padding: 0.24rem 0.58rem;
  border: 1px solid rgba(157, 181, 168, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #B9CDBF;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.admin-badge {
  min-width: 2rem;
  color: #E6F0EA;
  font-variant-numeric: tabular-nums;
}

.admin-badge--accent {
  border-color: rgba(52, 214, 160, 0.28);
  background: rgba(52, 214, 160, 0.09);
  color: #A7E8CF;
}

.admin-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 1rem;
  align-items: start;
}

.admin-section {
  margin-top: 0.25rem;
}

.admin-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--apex-border);
  border-radius: 12px;
  background: var(--apex-card);
  box-shadow: var(--apex-shadow);
}

.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.6rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(157, 181, 168, 0.14);
  background: rgba(255, 255, 255, 0.025);
}

.admin-panel-header--inline {
  border-bottom: 0;
  padding-bottom: 0.25rem;
}

.admin-panel-header h2 {
  margin: 0;
  color: #F1F8F4;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
}

.admin-panel-header p {
  margin: 0.2rem 0 0;
  color: var(--apex-muted);
  font-size: 0.78rem;
}

.admin-table-wrap {
  border-radius: 0;
}

.admin-table {
  --bs-table-cell-padding-y: 0.72rem;
  --bs-table-cell-padding-x: 1rem;
}

.admin-table thead th {
  border-bottom: 1px solid rgba(157, 181, 168, 0.16);
  background: rgba(255, 255, 255, 0.025);
}

.admin-table tbody tr:hover {
  background: rgba(52, 214, 160, 0.035);
}

.admin-user-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.62rem;
  min-width: 0;
  color: #F1F8F4;
  font-weight: 650;
}

.admin-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  border: 1px solid rgba(52, 214, 160, 0.2);
  border-radius: 999px;
  background: rgba(52, 214, 160, 0.08);
  color: #A7E8CF;
  font-size: 0.75rem;
  font-weight: 800;
  flex: 0 0 auto;
}

.admin-form,
.admin-inline-form {
  padding: 1rem;
}

.admin-form {
  display: grid;
  gap: 0.85rem;
}

.admin-form-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 0.75rem;
}

.admin-inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  padding-top: 0.6rem;
}

.admin-inline-field {
  min-width: 0;
}

.admin-form .form-label,
.admin-inline-form .form-label,
.admin-formula-row .form-label {
  margin-bottom: 0.32rem;
  color: #B9CDBF;
  font-size: 0.76rem;
  font-weight: 600;
}

.admin-formula-list {
  display: grid;
  gap: 0;
}

.admin-formula-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: end;
  padding: 1rem;
  border-top: 1px solid rgba(157, 181, 168, 0.14);
}

.admin-formula-row:first-child {
  border-top: 0;
}

.admin-formula-row:hover {
  background: rgba(255, 255, 255, 0.018);
}

.admin-formula-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 0.75rem;
  align-items: end;
  min-width: 0;
}

.admin-formula-meta {
  display: flex;
  align-items: center;
  width: 13rem;
  padding-bottom: 0.1rem;
}

.admin-formula-actions {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

.admin-formula-actions .btn {
  min-width: 5.25rem;
}

.admin-page .btn:disabled {
  opacity: 0.42;
}

@media (max-width: 992px) {
  .admin-main-grid {
    grid-template-columns: 1fr;
  }

  .admin-formula-row {
    grid-template-columns: 1fr;
  }

  .admin-formula-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 640px) {
  .admin-form-row,
  .admin-inline-form,
  .admin-formula-fields {
    grid-template-columns: 1fr;
  }

  .admin-inline-form .btn,
  .admin-formula-actions .btn {
    width: 100%;
  }

  .admin-formula-meta {
    width: auto;
  }

  .admin-formula-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

/* Footer */
.site-footer {
  padding: 1.5rem 0 1rem;
  text-align: center;
  color: rgba(157, 181, 168, 0.4);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.site-footer a {
  color: rgba(157, 181, 168, 0.5);
  text-decoration: none;
  transition: color 0.15s;
}

.site-footer a:hover {
  color: var(--apex-muted);
}

.card-hover {
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.card-hover:hover {
  border-color: rgba(52, 214, 160, 0.35);
  background-color: #1C261F;
}

.feature-card {
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
  border-color: rgba(52, 214, 160, 0.4);
  background-color: #1C261F;
  box-shadow: var(--apex-shadow);
}

/* Table row clickable style */
.table-clickable tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.table-clickable tbody tr:hover {
  background: rgba(52, 214, 160, 0.04);
}

/* Empty state for tables */
.table-empty {
  padding: 3rem 1.5rem;
  text-align: center;
}

.table-empty-icon {
  font-size: 2rem;
  opacity: 0.4;
  margin-bottom: 0.75rem;
  display: block;
}

.table-empty-text {
  color: var(--apex-muted);
  font-size: 0.9rem;
}

/* Better btn-close for dark theme */
.btn-close {
  filter: invert(1) grayscale(100%);
  opacity: 0.6;
  transition: opacity 0.15s;
}

.btn-close:hover {
  opacity: 1;
}

/* Modal improvements */
.modal-content {
  border-radius: 12px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
}

.modal-body {
  padding: 1.25rem 1.5rem;
}

/* Access denied / error page styling */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 1.5rem;
  min-height: 50vh;
}

.error-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
  font-size: 1.75rem;
}

.error-icon--danger {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fca5a5;
}

.error-icon--warning {
  background: rgba(250, 204, 21, 0.1);
  border: 1px solid rgba(250, 204, 21, 0.25);
  color: #fde68a;
}

.error-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #F1F8F4;
  margin-bottom: 0.5rem;
}

.error-description {
  color: var(--apex-muted);
  font-size: 0.95rem;
  max-width: 400px;
  margin-bottom: 1.5rem;
}

/* Breadcrumb-style back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--apex-muted);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.15s;
  margin-bottom: 0.75rem;
}

.back-link:hover {
  color: var(--apex-primary);
}

/* Card header with icon */
.card-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(52, 214, 160, 0.1);
  border: 1px solid rgba(52, 214, 160, 0.2);
  color: var(--apex-primary);
  flex-shrink: 0;
}

/* Transition for form controls */
.form-control,
.form-select {
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

/* Clamp long free-text columns (location / notes) so one verbose entry
   can't stretch the whole table; phone cards re-wrap them in full. */
.table td.cell-clamp {
  max-width: 16rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .table-cards td.cell-clamp {
    max-width: none;
    white-space: normal;
  }
}

/* Table header refinement */
.table thead th {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--apex-muted);
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.discord-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 44px;
}

.discord-button svg {
  flex-shrink: 0;
}
