@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-main: #0b0f19;
  --bg-sidebar: #0e1424;
  --bg-card: rgba(18, 24, 39, 0.85);
  --border-card: rgba(255, 255, 255, 0.08);

  --primary: #38bdf8;
  --primary-glow: rgba(56, 189, 248, 0.3);
  --accent-purple: #a855f7;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  /* Tiranga Theme Tokens */
  --saffron: #FF671F;
  --white: #FFFFFF;
  --ashoka-navy: #041E42;
  --india-green: #046A38;
  --tiranga-gradient: linear-gradient(90deg, #FF671F 0%, #FF671F 33.33%, #FFFFFF 33.33%, #FFFFFF 66.66%, #046A38 66.66%, #046A38 100%);
}

/* Tiranga Top Indicator Bar */
.tiranga-top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--tiranga-gradient);
  z-index: 99999;
  box-shadow: 0 0 15px rgba(255, 103, 31, 0.45);
}

@keyframes spinChakra {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-card);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.brand-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Status Pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}

.status-dot.connected { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.status-dot.idle { background: var(--accent-amber); }
.status-dot.disconnected { background: var(--accent-red); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-card);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-sim {
  background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
  color: #fff;
}

/* Main Container */
.dashboard-container {
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Metric Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.metric-val {
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* Split Layout */
.dashboard-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 28px;
}

@media (max-width: 1024px) {
  .dashboard-split { grid-template-columns: 1fr; }
}

/* Card General */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
  margin-bottom: 24px;
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Table Styling */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-card);
}

td {
  padding: 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.code-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 8px;
  border-radius: 6px;
  color: #38bdf8;
  text-decoration: none;
}

.code-badge:hover {
  text-decoration: underline;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge.PAID { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.PENDING { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge.EXPIRED { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.3); }

/* Simulator Form */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: #fff;
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #111827;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-card);
  padding-bottom: 12px;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2) 0%, rgba(99, 102, 241, 0.2) 100%);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 15px var(--primary-glow);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Toggle Switch */
.switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch-input {
  display: none;
}

.switch-slider {
  width: 44px;
  height: 24px;
  background: #334155;
  border-radius: 30px;
  position: relative;
  transition: background 0.3s;
}

.switch-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 4px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.switch-input:checked + .switch-slider {
  background: var(--accent-green);
}

.switch-input:checked + .switch-slider::after {
  transform: translateX(18px);
}

/* Code Snippets & Developer Docs Styles */
.code-box {
  background: #060911;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  position: relative;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: #38bdf8;
  overflow-x: auto;
  line-height: 1.6;
  white-space: pre;
}

.code-subnav {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-card);
  padding-bottom: 8px;
}

.code-subtab {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.code-subtab:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.code-subtab.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
  color: #fff;
}

.copy-snippet-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--text-main);
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  z-index: 5;
}

.copy-snippet-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* ======================================================== */
/* 2-LINE / 3-LINE ADMIN SIDEBAR & MODERN LAYOUT            */
/* ======================================================== */
.admin-layout-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar-2line {
  width: 290px;
  background: #0d121d;
  border-right: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-brand-box {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-card);
}

.sidebar-user-card {
  padding: 14px 18px;
  margin: 12px 14px 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid rgba(168, 85, 247, 0.4);
  object-fit: cover;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-plan-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.4);
  text-transform: uppercase;
  margin-top: 3px;
}

.sidebar-nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-item-2line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
  color: inherit;
  position: relative;
  width: 100%;
  text-align: left;
}

.sidebar-item-2line:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-item-2line.active {
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.12), rgba(56, 189, 248, 0.02));
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.sidebar-item-2line.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3.5px;
  border-radius: 0 4px 4px 0;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
}

.sidebar-item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
  transition: all 0.2s;
}

.sidebar-item-2line.active .sidebar-item-icon {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--primary);
}

.sidebar-item-texts {
  flex: 1;
  min-width: 0;
}

.sidebar-item-line1 {
  font-size: 13.5px;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.25;
}

.sidebar-item-2line.active .sidebar-item-line1 {
  color: #38bdf8;
}

.sidebar-item-line2 {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.2;
}

.sidebar-item-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-engine-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--accent-green);
  font-weight: 600;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 8px 12px;
  border-radius: 8px;
}

.sidebar-btn-lock {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(244, 63, 94, 0.1);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.25);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  transition: all 0.2s;
}

.sidebar-btn-lock:hover {
  background: rgba(244, 63, 94, 0.2);
}

/* MAIN CONTENT AREA */
.main-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-main);
  overflow-y: auto;
}

.content-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  background: rgba(13, 18, 29, 0.85);
  border-bottom: 1px solid var(--border-card);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-page-title {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  margin: 0;
}

.topbar-quick-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-muted);
}

.admin-view-section {
  display: none;
  padding: 28px 32px 48px;
}

.admin-view-section.active {
  display: block;
  animation: fadeInView 0.25s ease forwards;
}

@keyframes fadeInView {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
.btn-topbar-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(244, 63, 94, 0.14);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 8px rgba(244, 63, 94, 0.15);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-topbar-logout:hover {
  background: rgba(244, 63, 94, 0.25);
  color: #fff;
  border-color: rgba(244, 63, 94, 0.6);
  transform: translateY(-1px);
}

.mobile-sidebar-close-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  margin-left: auto;
  transition: all 0.2s;
}

.mobile-sidebar-close-btn:hover {
  background: rgba(244, 63, 94, 0.25);
  color: #fb7185;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ======================================================== */
/* COMPREHENSIVE RESPONSIVE DESIGN (PHONE, TABLET, LAPTOP)  */
/* ======================================================== */

/* TABLETS & SMALL LAPTOPS (<= 1024px) */
@media (max-width: 1024px) {
  .admin-layout-wrapper {
    position: relative;
  }

  .sidebar-2line {
    position: fixed;
    top: 0;
    left: -310px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 12px 0 35px rgba(0, 0, 0, 0.7);
  }

  .sidebar-2line.mobile-open {
    left: 0;
  }

  .mobile-menu-toggle,
  #adminMobileMenuBtn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }

  .main-content-area {
    width: 100% !important;
    min-width: 0;
  }

  .content-topbar {
    padding: 14px 20px;
    gap: 12px;
  }

  .admin-view-section {
    padding: 20px 20px 40px;
  }

  .dashboard-split {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* MOBILE DEVICES (<= 768px) */
@media (max-width: 768px) {
  .content-topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
    gap: 10px;
  }

  .topbar-page-title {
    font-size: 17px;
  }

  .topbar-quick-stats {
    width: 100%;
    justify-content: flex-start;
    gap: 6px;
  }

  .topbar-stat-pill {
    font-size: 11px;
    padding: 4px 8px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .metric-card {
    padding: 16px;
  }

  .metric-val {
    font-size: 24px;
  }

  .admin-view-section {
    padding: 14px 14px 32px;
  }

  .panel-card {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }

  table {
    min-width: 600px;
  }

  th, td {
    padding: 10px 12px;
    font-size: 12px;
  }

  .modal-content {
    width: 95vw !important;
    max-width: 95vw !important;
    margin: 15px auto !important;
    padding: 18px !important;
  }

  .quick-filter-bar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .quick-filter-btn {
    font-size: 11px;
    padding: 5px 10px;
  }

  .form-grid-2col,
  .config-grid {
    grid-template-columns: 1fr !important;
  }

  .api-test-console {
    padding: 14px;
  }
}

/* SMALL PHONES (<= 480px) */
@media (max-width: 480px) {
  .sidebar-2line {
    width: 270px;
  }

  .topbar-page-title {
    font-size: 15px;
  }

  .btn {
    padding: 7px 12px;
    font-size: 12px;
  }

  .status-pill {
    padding: 4px 10px;
    font-size: 11px;
  }
}


