/* ==========================================================================
   ELSWEFY API CONSOLE - STYLESHEET
   Harmonious Glassmorphic Aesthetics, Dark Mode slate, & Micro-animations
   ========================================================================== */

/* 1. CORE CSS CUSTOM PROPERTIES & THEME TOKENS */
:root {
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', "Courier New", Courier, monospace;

  /* HSL Color Palette - Sleek Professional Violet & Slate Accents */
  --bg-app: hsl(230, 25%, 8%);
  --bg-sidebar: hsl(230, 25%, 6%);
  
  /* Glassmorphic Surfaces */
  --glass-surface: rgba(30, 35, 50, 0.45);
  --glass-border: rgba(255, 255, 255, 0.05);
  --glass-glow: rgba(99, 102, 241, 0.15);
  
  /* Solid Brand Gradients */
  --primary-gradient: linear-gradient(135deg, hsl(263, 85%, 65%) 0%, hsl(230, 90%, 60%) 100%);
  --success-gradient: linear-gradient(135deg, hsl(142, 70%, 45%) 0%, hsl(160, 80%, 40%) 100%);
  --danger-gradient: linear-gradient(135deg, hsl(350, 75%, 55%) 0%, hsl(340, 85%, 50%) 100%);
  --info-gradient: linear-gradient(135deg, hsl(190, 80%, 50%) 0%, hsl(210, 85%, 55%) 100%);

  /* Base Semantic Palette */
  --color-primary: hsl(245, 82%, 67%);
  --color-success: hsl(150, 75%, 45%);
  --color-danger: hsl(345, 80%, 55%);
  --color-info: hsl(195, 85%, 48%);
  --color-warning: hsl(35, 85%, 55%);
  
  --text-main: hsl(220, 20%, 94%);
  --text-muted: hsl(220, 15%, 65%);
  --text-dark: hsl(230, 20%, 15%);
  
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* 2. BASE RESET & INITIAL STYLING */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  display: flex;
}

/* Ambient glow bubbles in the background */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(100px);
  z-index: -1;
  opacity: 0.18;
  pointer-events: none;
}

.glow-1 {
  width: 400px;
  height: 400px;
  background: var(--color-primary);
  top: -100px;
  right: -50px;
}

.glow-2 {
  width: 350px;
  height: 350px;
  background: var(--color-info);
  bottom: -50px;
  left: -100px;
}

.glow-3 {
  width: 500px;
  height: 500px;
  background: hsl(280, 80%, 60%);
  top: 40%;
  left: 30%;
  opacity: 0.08;
}

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 3. CORE LAYOUT FRAMEWORK */
.app-workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  width: 100vw;
  min-height: 100vh;
  animation: fadeIn 0.4s ease-out;
}

.hidden {
  display: none !important;
}

/* 4. SIDEBAR CONSOLE NAVIGATION */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: 24px;
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.user-badge {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

.nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
  color: var(--text-main);
  background: var(--primary-gradient);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.nav-item .icon {
  font-size: 1.1rem;
}

.sidebar-footer {
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* 5. MAIN WORKSPACE CONTENT PANELS */
.main-content {
  padding: 40px;
  height: 100vh;
  overflow-y: auto;
  position: relative;
}

.tab-panel {
  display: none;
  animation: tabFadeIn 0.3s ease-out forwards;
}

.tab-panel.active {
  display: block;
}

.panel-header {
  margin-bottom: 32px;
}

.panel-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.panel-header p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* 6. GENERAL REUSABLE UI ELEMENTS (BUTTONS, CARDS, INPUTS) */
.grid-card {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-premium);
  backdrop-filter: blur(16px);
  margin-bottom: 24px;
  overflow: hidden;
  transition: var(--transition-smooth);
}

.grid-card:hover {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

.card-body.no-padding {
  padding: 0;
}

.card-divider {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 24px 0;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-primary);
  margin-bottom: 16px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-primary {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-danger {
  background: var(--danger-gradient);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 1rem;
  padding: 8px;
  border-radius: var(--border-radius-sm);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

input {
  width: 100%;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 12px 16px;
  font-size: 0.95rem;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* 7. KPI SCORECARD COMPONENT */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-premium);
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary-gradient);
}

.stat-card.success::before {
  background: var(--success-gradient);
}

.stat-card.danger::before {
  background: var(--danger-gradient);
}

.stat-card.info::before {
  background: var(--info-gradient);
}

.stat-icon {
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.03);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-details h3 {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Layout configurations */
.layout-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 24px;
}

.layout-grid.grid-1-3 {
  grid-template-columns: 380px 1fr;
}

/* 8. AUDIT LOGS TABLES & BADGES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 16px 24px;
}

.data-table th {
  background: rgba(255, 255, 255, 0.01);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-size: 0.92rem;
}

.data-table tbody tr {
  transition: var(--transition-smooth);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
}

.text-center {
  text-align: center;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.success {
  background: rgba(16, 185, 129, 0.15);
  color: hsl(150, 75%, 45%);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.15);
  color: hsl(345, 80%, 55%);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.status-badge.no_actions {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(107, 114, 128, 0.25);
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.view-all-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.view-all-link:hover {
  text-decoration: underline;
}

/* Info Alert */
.info-alert {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.15);
  border-radius: var(--border-radius-sm);
  padding: 18px;
  margin-bottom: 20px;
}

.info-alert h4 {
  color: var(--text-main);
  margin-bottom: 8px;
  font-weight: 600;
}

.info-alert p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.code-block-container {
  background: #0f111a;
  border-radius: var(--border-radius-sm);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  overflow-x: auto;
  color: var(--color-info);
  margin-bottom: 12px;
}

.quick-stats-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quick-stat-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
}

/* 9. API TOKEN REVEAL WIDGET */
.key-reveal-alert {
  margin-top: 24px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.18);
  padding: 16px;
  border-radius: var(--border-radius-sm);
  animation: pulseGlow 2s infinite alternate;
}

.alert-icon {
  font-weight: 700;
  color: var(--color-warning);
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.key-reveal-alert p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.api-token-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0f111a;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(245, 158, 11, 0.25);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.token-text {
  word-break: break-all;
  user-select: all;
  color: var(--color-warning);
}

/* 10. AUTH GATEWAY AND CARDS */
.auth-gateway {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.auth-container {
  width: 440px;
  padding: 20px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo img {
  width: 80px;
  height: 80px;
  border-radius: var(--border-radius-md);
  margin-bottom: 16px;
  box-shadow: var(--shadow-premium);
  border: 2px solid rgba(255, 255, 255, 0.1);
  object-fit: cover;
}

.auth-logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-card {
  display: none;
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-premium);
  backdrop-filter: blur(20px);
}

.auth-card.active {
  display: block;
  animation: authCardSlide 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 24px;
}

.auth-switch {
  text-align: center;
  margin-top: 24px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* 11. SLIDING EVENT INSPECTOR DRAWER */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  animation: fadeIn 0.25s ease-out;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 800px;
  height: 100vh;
  background: hsl(230, 25%, 8%);
  border-left: 1px solid var(--glass-border);
  box-shadow: -10px 0 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  animation: drawerSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.drawer-header {
  padding: 30px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-close:hover {
  color: var(--text-main);
  transform: rotate(90deg);
}

.drawer-content {
  padding: 30px;
  overflow-y: auto;
  flex-grow: 1;
}

.drawer-section {
  margin-bottom: 30px;
}

.drawer-section h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 8px;
}

.properties-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  background: rgba(255, 255, 255, 0.01);
  padding: 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
}

.property-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.property-item span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.property-item strong {
  font-size: 0.9rem;
}

.code-view-container {
  background: #090a0f;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--glass-border);
  padding: 16px;
  max-height: 250px;
  overflow-y: auto;
}

.code-view-container pre {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-info);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Action Log List card details */
.action-box {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  margin-bottom: 16px;
  overflow: hidden;
}

.action-box-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.01);
}

.action-box-header strong {
  font-size: 0.95rem;
}

.action-box-body {
  padding: 20px;
}

.action-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.sub-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.no-actions-indicator {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  font-style: italic;
  font-size: 0.88rem;
}

/* 12. TOAST ALERTS & ANIMATIONS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--glass-surface);
  border: 1px solid var(--glass-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--border-radius-sm);
  padding: 14px 24px;
  color: var(--text-main);
  box-shadow: var(--shadow-premium);
  backdrop-filter: blur(12px);
  min-width: 280px;
  font-weight: 500;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: toastSlide 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.success {
  border-left-color: var(--color-success);
}

.toast.error {
  border-left-color: var(--color-danger);
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}

/* Keyframe Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes authCardSlide {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes drawerSlide {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes toastSlide {
  from { transform: translateY(30px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes pulseGlow {
  from { border-color: rgba(245, 158, 11, 0.18); box-shadow: 0 0 0 rgba(245, 158, 11, 0); }
  to { border-color: rgba(245, 158, 11, 0.35); box-shadow: 0 0 10px rgba(245, 158, 11, 0.1); }
}
