/* ==========================================================================
   Credential Hub - Central Identity Broker & Session Tokens Manager
   Replicating 1:1 Architecture from admin.kaywat with Credential Hub Dark Palette
   ========================================================================== */

:root {
  --ch-purple: #a855f7;
  --ch-purple-glow: rgba(168, 85, 247, 0.35);
  --ch-purple-hover: #9333ea;
  --ch-green: #10b981;
  --ch-red: #ef4444;
  --ch-amber: #f59e0b;
  --ch-blue: #38bdf8;
  --ch-bg: #090412;
  --ch-panel: #130a24;
  --ch-panel-header: rgba(19, 10, 36, 0.85);
  --ch-border: rgba(168, 85, 247, 0.22);
  --ch-text: #e2e8f0;
  --ch-text-muted: #94a3b8;
  --ch-card-bg: rgba(19, 10, 36, 0.65);
}

#panel-tokens {
  background: var(--ch-bg);
  background-image: 
    radial-gradient(at 10% 10%, rgba(168, 85, 247, 0.12) 0px, transparent 50%),
    radial-gradient(at 90% 90%, rgba(99, 102, 241, 0.08) 0px, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
  padding: 0;
  box-sizing: border-box;
  color: var(--ch-text);
  overflow-y: auto;
}

/* Nav Tabs across top */
.unraid-nav {
  background: #0d061c;
  border-bottom: 1px solid var(--ch-border);
  padding: 0 1.5rem;
  display: flex;
  gap: 20px;
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.unraid-nav::-webkit-scrollbar {
  height: 4px;
}
.unraid-nav::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 4px;
}

.nav-tab {
  background: none;
  border: none;
  color: var(--ch-text-muted);
  padding: 1rem 0;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
  text-transform: uppercase;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.nav-tab:hover {
  color: #ffffff;
}

.nav-tab.active {
  color: var(--ch-purple);
  border-bottom-color: var(--ch-purple);
  text-shadow: 0 0 12px var(--ch-purple-glow);
}

/* Content Container */
.tokens-broker-content {
  padding: 2rem 2.5rem 4rem 2.5rem;
  max-width: 1440px;
  margin: 0 auto;
}

/* Panels */
.panel {
  background: var(--ch-panel);
  border: 1px solid var(--ch-border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.panel-header {
  background: var(--ch-panel-header);
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--ch-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #f1f5f9;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-body {
  padding: 1.25rem;
}

/* Status Pills */
.status-pill {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-missing {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-empty {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Dashboard Grid */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.5rem;
}

.platform-card {
  background: var(--ch-card-bg);
  border: 1px solid var(--ch-border);
  border-radius: 10px;
  padding: 1.4rem;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.platform-card:hover {
  transform: translateY(-2px);
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 15px rgba(168, 85, 247, 0.15);
}

.platform-title {
  margin: 0 0 1.1rem 0;
  font-size: 1.05rem;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.platform-title:hover {
  color: var(--ch-purple);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
  color: var(--ch-text-muted);
}

.stat-row span:last-child {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
}

/* Code Textarea */
.textarea-code {
  width: 100%;
  box-sizing: border-box;
  padding: 14px;
  background: #080312;
  border: 1px solid var(--ch-border);
  border-radius: 8px;
  color: #3ecf8e;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  resize: vertical;
  margin-top: 10px;
}

.textarea-code:focus {
  outline: none;
  border-color: var(--ch-purple);
  box-shadow: 0 0 10px var(--ch-purple-glow);
}

/* Buttons */
.btn-outline {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e2e8f0;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter', sans-serif;
}

.btn-outline:hover {
  background: rgba(168, 85, 247, 0.12);
  border-color: var(--ch-purple);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

.btn-primary {
  background: var(--ch-purple);
  border: 1px solid #c084fc;
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.35);
  font-family: 'Inter', sans-serif;
}

.btn-primary:hover {
  background: var(--ch-purple-hover);
  box-shadow: 0 4px 18px rgba(168, 85, 247, 0.55);
}

.btn-primary:disabled, .btn-outline:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mode toggles */
.toggle-mode {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--ch-text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Inter', sans-serif;
}

.toggle-mode:hover {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.toggle-mode.active {
  background: rgba(168, 85, 247, 0.16);
  color: #ffffff;
  border-color: var(--ch-purple);
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.25);
}

/* Accounts List & Cards */
.account-card {
  background: rgba(10, 4, 20, 0.6);
  border: 1px solid var(--ch-border);
  border-radius: 8px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  transition: all 0.15s ease;
}

.account-card:hover {
  border-color: rgba(168, 85, 247, 0.45);
  background: rgba(19, 10, 36, 0.85);
}

.acc-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.acc-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7 0%, #6d28d9 100%);
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.acc-details {
  display: flex;
  flex-direction: column;
}

.acc-name {
  color: #ffffff;
  font-weight: 600;
  font-size: 0.95rem;
}

.acc-meta {
  font-size: 0.75rem;
  color: var(--ch-text-muted);
  margin-top: 2px;
}

.acc-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(6px);
  z-index: 99999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: #130a24;
  border: 1px solid var(--ch-border);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7);
  max-width: 520px;
  width: 90%;
  box-sizing: border-box;
}

/* Toast */
.ch-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #190c30;
  border: 1px solid var(--ch-purple);
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 15px rgba(168, 85, 247, 0.3);
  font-size: 0.88rem;
  z-index: 100000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.ch-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.ch-toast.error {
  border-color: #ef4444;
  background: #250912;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.spin {
  animation: spin 1s linear infinite;
}
