/**
 * RELY R8 — Stability CSS v2.0
 * ================================
 * Visual hardening + consistency fixes
 * Loaded alongside rely_stability.js
 */

/* ---- TOAST CONTAINER ---- */
#rely-toast-container {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---- NETWORK OFFLINE BANNER ---- */
.rely-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 10px;
  background: #dc2626;
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  z-index: 999999;
}

/* ---- MODAL FIXES — prevent visual glitches ---- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay.show {
  display: flex !important;
}

/* Prevent modal content from overflowing viewport */
.modal-box {
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* Scrollbar styling for modals */
.modal-box::-webkit-scrollbar {
  width: 6px;
}
.modal-box::-webkit-scrollbar-track {
  background: transparent;
}
.modal-box::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}
.modal-box::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

/* ---- BUTTON CONSISTENCY ---- */
.btn {
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Gold/Primary buttons always white text */
.btn-gold, .btn-primary {
  background: var(--gold, #FF4D0F);
  color: #ffffff !important;
}
.btn-gold:hover, .btn-primary:hover {
  background: #e6440d;
  color: #ffffff !important;
}
.btn-gold i, .btn-primary i {
  color: #ffffff !important;
}

/* Outline buttons */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border2, #333);
  color: var(--text2, #ccc);
}
.btn-outline:hover {
  border-color: var(--gold, #FF4D0F);
  color: var(--gold, #FF4D0F);
}

/* Danger buttons */
.btn-danger {
  background: #dc2626;
  color: #fff !important;
}
.btn-danger:hover {
  background: #b91c1c;
}

/* Success buttons */
.btn-success {
  background: #16a34a;
  color: #fff !important;
}
.btn-success:hover {
  background: #15803d;
}

/* ---- TABLE CONSISTENCY ---- */
table {
  width: 100%;
  border-collapse: collapse;
}

table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3, #666);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border2, #222);
  white-space: nowrap;
}

table tbody td {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text2, #ccc);
  border-bottom: 1px solid var(--border, #1a1a1f);
  vertical-align: middle;
}

table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ---- FORM CONSISTENCY ---- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
textarea,
select {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border2, #333);
  border-radius: 8px;
  background: var(--bg2, #13131a);
  color: var(--text, #fff);
  outline: none;
  transition: border-color 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold, #FF4D0F);
  box-shadow: 0 0 0 2px rgba(255, 77, 15, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text3, #666);
}

/* ---- LOADING STATES ---- */
.rely-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  color: var(--text3, #666);
  font-size: 13px;
  gap: 8px;
}

.rely-loading .fa-spinner {
  font-size: 1.2em;
}

/* ---- CARD CONSISTENCY ---- */
.card, .stat-card, .metric-card {
  border-radius: 12px;
  border: 1px solid var(--border, #1a1a1f);
  overflow: hidden;
}

/* ---- PREVENT LAYOUT SHIFT ---- */
img {
  max-width: 100%;
  height: auto;
}

/* Fix for horizontal scrollbar appearing */
.main-content, .content-area {
  overflow-x: hidden;
}

/* ---- RESPONSIVE FIXES ---- */
@media (max-width: 768px) {
  .modal-box {
    max-width: 95vw !important;
    max-height: 85vh;
    margin: 10px;
  }

  table {
    font-size: 12px;
  }

  table thead th,
  table tbody td {
    padding: 8px;
  }
}

/* ---- ANIMATION SMOOTHNESS ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- SELECTION COLOR ---- */
::selection {
  background: rgba(255, 77, 15, 0.3);
  color: #fff;
}

/* ---- SCROLLBAR GLOBAL ---- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
