@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --phonepe: #5f259f;
  --phonepe-light: #f5edff;
  --gpay: #1a73e8;
  --gpay-light: #e8f0fe;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --bg: #090d16;
  --card-bg: #111827;
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover: rgba(255, 255, 255, 0.03);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --input-bg: #1e293b;
  --sidebar-w: 260px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* =========================================
   SIDEBAR
   ========================================= */
.sidebar {
  width: var(--sidebar-w);
  background: #0d131f;
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
}

.sidebar-brand {
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--card-border);
}

.brand-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.brand-text h2 {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
}

.nav-category {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0.6rem 0.75rem 0.3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(79, 70, 229, 0.25), rgba(79, 70, 229, 0.05));
  border-left: 3px solid var(--primary-light);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-mini-card {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1e293b;
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary-light);
}

.user-info-text .user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
}

.user-info-text .user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-icon-logout {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
}

.btn-icon-logout:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* =========================================
   MAIN CONTENT AREA
   ========================================= */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: 70px;
  background: rgba(13, 19, 31, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.page-headline h1 {
  font-size: 1.2rem;
  font-weight: 800;
}

.page-headline p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-indicator-badge {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.pulse-circle {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  border: 1px solid var(--card-border);
  padding: 0.55rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

/* Page Container */
.content-body {
  padding: 2rem;
  flex: 1;
}

.view-section {
  display: none;
  animation: fadeInView 0.25s ease-out forwards;
}

.view-section.active {
  display: block;
}

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

/* =========================================
   STATS METRICS GRID
   ========================================= */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 1.4rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.metric-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

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

.metric-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.metric-icon-bubble {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.metric-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.metric-footer {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.7rem;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

/* =========================================
   CHARTS & DUAL CARDS SECTION
   ========================================= */
.dashboard-grid-2col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.content-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  padding: 1.5rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card-title-row h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

/* Revenue Chart Container */
.chart-container {
  height: 220px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  padding-top: 1rem;
  border-bottom: 1px solid var(--card-border);
}

.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 0.5rem;
}

.chart-bar-fill {
  width: 100%;
  max-width: 44px;
  background: linear-gradient(180deg, #6366f1 0%, rgba(99, 102, 241, 0.2) 100%);
  border-radius: 8px 8px 2px 2px;
  min-height: 8px;
  transition: height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  cursor: pointer;
}

.chart-bar-fill:hover {
  background: linear-gradient(180deg, #818cf8 0%, rgba(99, 102, 241, 0.4) 100%);
}

.chart-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* Gateways Distribution Card */
.gateway-split-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.gw-progress-bar {
  height: 10px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
  display: flex;
}

.gw-bar-phonepe {
  background: var(--phonepe);
  height: 100%;
  transition: width 0.4s;
}

.gw-bar-gpay {
  background: var(--gpay);
  height: 100%;
  transition: width 0.4s;
}

.gw-item-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #151d2f;
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

.gw-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.gw-dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}

/* =========================================
   TABLE STYLES
   ========================================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

th {
  background: #151d2f;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.9rem 1.25rem;
  font-weight: 700;
  border-bottom: 1px solid var(--card-border);
}

td {
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--card-border);
  color: #e2e8f0;
}

tr:hover td {
  background: var(--card-hover);
}

.mono-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: #94a3b8;
}

/* =========================================
   SETTINGS FORM & INPUTS
   ========================================= */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.form-input, .form-select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  color: #ffffff;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.toggle-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: #151d2f;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  margin-bottom: 1.25rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* =========================================
   INTEGRATION CODE VIEWER & TABS
   ========================================= */
.code-box-container {
  background: #090e17;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 1rem;
}

.code-box-header {
  background: #121824;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
}

.code-tabs-nav {
  display: flex;
  gap: 0.5rem;
}

.code-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
}

.code-tab-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

pre {
  padding: 1.25rem;
  overflow-x: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.6;
  color: #38bdf8;
}

/* =========================================
   LOGIN MODAL OVERLAY
   ========================================= */
.auth-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 13, 22, 0.95);
  backdrop-filter: blur(16px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 2.25rem;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}

/* Generic Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 90;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  position: relative;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid var(--card-border);
  padding: 0.8rem 1.25rem;
  border-radius: 12px;
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideInToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive Component Utilities */
.btn-mobile-toggle {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.orders-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.orders-search-input {
  width: 260px;
}

.orders-filter-select {
  width: 140px;
}

.sim-inputs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.code-tabs-nav {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* =========================================
   FULL RESPONSIVE MEDIA QUERIES
   ========================================= */
@media (max-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid-2col, .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .btn-mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--card-border);
    color: #fff;
    padding: 0.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
  }

  .btn-mobile-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
  }

  /* Off-canvas mobile navigation drawer */
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 15px 0 40px rgba(0, 0, 0, 0.75);
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    z-index: 95;
    animation: fadeIn 0.2s ease;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  .main-wrapper {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .topbar {
    padding: 0.75rem 1rem;
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .content-body {
    padding: 1rem 0.75rem;
  }

  .card-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .orders-filter-bar {
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
  }

  .orders-search-input,
  .orders-filter-select {
    width: 100% !important;
  }

  .sim-inputs-grid {
    grid-template-columns: 1fr;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }

  table th, table td {
    padding: 0.75rem 0.6rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .metric-card {
    padding: 1.1rem;
  }

  .metric-value {
    font-size: 1.55rem;
  }

  .page-headline h1 {
    font-size: 1.05rem;
  }

  .page-headline p {
    font-size: 0.7rem;
  }

  .topbar-actions a,
  .topbar-actions button {
    font-size: 0.78rem;
    padding: 0.55rem 0.8rem;
  }

  .modal-card {
    padding: 1.25rem;
    border-radius: 16px;
  }

  .auth-card {
    padding: 1.5rem 1.25rem;
    border-radius: 20px;
  }

  .btn-primary, .btn-secondary {
    padding: 0.6rem 0.9rem;
    font-size: 0.82rem;
  }
}
