/* Base Design Tokens & Variables */
:root {
  --bg-primary: #0a0d16;
  --bg-secondary: #121824;
  --bg-glass: rgba(18, 24, 36, 0.7);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-color: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --success-color: #10b981;
  --success-glow: rgba(16, 185, 129, 0.4);
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.4);
  --terminal-bg: #07090e;
  --font-sans: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* Dynamic Ambient Glow Background */
.glow-bg {
  position: absolute;
  top: -10%;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  z-index: -1;
  filter: blur(80px);
  pointer-events: none;
}

.container {
  max-width: 100%;
  margin: 0;
  padding: 1.5rem 2.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  box-sizing: border-box;
}

/* Header Component */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, var(--accent-color), #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #ffffff, #d1d5db);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Status Indicators */
.status-indicator-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.5rem 1rem;
  border-radius: 30px;
  border: 1px solid var(--border-glass);
  font-size: 0.8rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--warning-color);
}

.status-dot.online {
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-glow);
}

.status-dot.offline {
  background-color: var(--error-color);
  box-shadow: 0 0 8px var(--error-glow);
}

.status-dot.pulsing {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 380px 1fr;
  }
}

/* Card Component & Glassmorphism */
.card {
  background-color: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 1.75rem;
  border: 1px solid var(--border-glass);
}

.card.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: #ffffff;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card-header h2 {
  margin-bottom: 0;
}

/* Priority Reordering List & Up/Down Controls */
.priority-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
  width: 100%;
}

.priority-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  transition: var(--transition);
}

.priority-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(99, 102, 241, 0.4);
}

.priority-item-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.priority-badge {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  min-width: 32px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.priority-badge.p1 {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.priority-badge.p2 {
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  box-shadow: 0 2px 6px rgba(56, 189, 248, 0.3);
}

.priority-badge.p3 {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.priority-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.btn-order {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-order:hover:not(:disabled) {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

.btn-order:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-order.remove:hover {
  background: #ef4444;
  border-color: #ef4444;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.4;
}

/* Stats Component */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-item {
  background: rgba(255, 255, 255, 0.02);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-val {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

/* Progress bar */
.system-progress-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.progress-bar-container {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-color), #a855f7);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Inbound Messages Component */
.inbound-list-container {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.25rem;
}

.empty-inbound {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem 0;
  text-align: center;
}

.inbound-item {
  background: rgba(7, 9, 14, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: var(--transition);
}

.inbound-item:hover {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.04);
}

.inbound-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.inbound-sender {
  font-weight: 600;
  color: #38bdf8;
  font-family: var(--font-mono);
}

.inbound-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.inbound-badge.sms {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.inbound-badge.dlr {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.inbound-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  word-break: break-word;
}

/* Admin Tabs */
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 0.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #fff;
  background: var(--accent-color);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.tab-content {
  display: none;
}

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

/* Admin Section Header */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

/* Gateways Grid */
.gateways-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .gateways-grid {
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  }
}

.gw-badge-default {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.4rem;
  text-transform: uppercase;
}

/* Modal Overlay & Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(7, 9, 14, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-glass);
  padding: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.modal-card form {
  overflow-y: auto;
  max-height: calc(90vh - 5rem);
  padding-right: 0.35rem;
}

/* Custom Scrollbar for Modal Form */
.modal-card form::-webkit-scrollbar {
  width: 6px;
}
.modal-card form::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 3px;
}
.modal-card form::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
.modal-card form::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.1rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-group.half {
  flex: 1;
}

@media (max-width: 640px) {
  .modal-overlay {
    padding: 0.5rem;
    align-items: flex-start;
  }

  .modal-card {
    padding: 1.2rem;
    max-height: 96vh;
    border-radius: 8px;
  }

  .modal-card form {
    max-height: calc(96vh - 4.5rem);
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .priority-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .priority-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.6rem !important;
  }

  .modal-actions button {
    width: 100%;
  }

  .filter-split-grid {
    grid-template-columns: 1fr !important;
  }
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  background-color: rgba(7, 9, 14, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.form-control.code-font {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}

textarea.form-control {
  resize: vertical;
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.25rem;
}

.hidden {
  display: none !important;
}

.checkbox-group {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #fbbf24;
  cursor: pointer;
  user-select: none;
  background: rgba(245, 158, 11, 0.08);
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  border: 1px dashed rgba(245, 158, 11, 0.3);
  transition: var(--transition);
}

.checkbox-label:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.5);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #f59e0b;
  cursor: pointer;
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent-color);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  padding: 0.4rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.btn-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.btn-clear {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.btn-clear:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error-color);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-loader {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

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

/* API Playground Layout split */
.playground-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .playground-layout {
    grid-template-columns: 1fr 1fr;
  }
}

.req-builder {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* Terminal component */
.res-display {
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.terminal-header {
  background-color: #0e131f;
  border: 1px solid var(--border-glass);
  border-bottom: none;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dots .dot.red { background-color: var(--error-color); }
.terminal-dots .dot.yellow { background-color: var(--warning-color); }
.terminal-dots .dot.green { background-color: var(--success-color); }

.terminal-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
}

.terminal-body {
  background-color: var(--terminal-bg);
  border: 1px solid var(--border-glass);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  flex-grow: 1;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #a7f3d0; /* Soft neon green */
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* App Footer */
.app-footer {
  text-align: center;
  padding-top: 2rem;
  margin-top: auto;
  border-top: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: 0.8rem;
}
