/* E-Clinic Keygen — Dark Glassmorphism UI */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --success-color: #10b981;
  --danger-color:  #ef4444;
  --warning-color: #f59e0b;
  --bg-color:      #0f1117;
  --panel-bg:      rgba(255, 255, 255, 0.04);
  --panel-border:  rgba(255, 255, 255, 0.08);
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --input-bg:      rgba(0, 0, 0, 0.3);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg-color);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* Background shapes */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body::before {
  width: 500px; height: 500px;
  top: -150px; left: -100px;
  background: radial-gradient(circle, rgba(99,102,241,.12) 0%, transparent 70%);
}
body::after {
  width: 400px; height: 400px;
  bottom: -100px; right: -100px;
  background: radial-gradient(circle, rgba(16,185,129,.08) 0%, transparent 70%);
}

/* ======================== Layout ======================== */
.page-wrapper {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

.container {
  width: 100%;
  max-width: 1100px;
}

/* ======================== Glass Panel ======================== */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 2rem;
}

/* ======================== Header ======================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.app-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.app-header .sub {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 2px;
}

/* ======================== Tabs ======================== */
.tab-bar {
  display: flex;
  gap: 0.5rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
  padding: 6px;
  border-radius: 14px;
  margin-bottom: 1.5rem;
}
.tab-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
}
.tab-btn.active {
  background: var(--primary-color);
  color: #fff;
}
.tab-btn:hover:not(.active) {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

/* ======================== Forms ======================== */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s;
  outline: none;
}
.form-control:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
}
.form-control::placeholder { color: rgba(148,163,184,0.5); }
select.form-control { cursor: pointer; }
select.form-control option { background: #1e1e2e; }

/* ======================== Buttons ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(99,102,241,0.3); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-secondary {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.12);
  box-shadow: none;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  width: auto;
  border-radius: 8px;
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}

/* ======================== Key display ======================== */
.key-display {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--success-color);
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  word-break: break-all;
  letter-spacing: 0.02em;
}

/* ======================== Badges ======================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-primary { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-success { background: rgba(16,185,129,0.15); color: var(--success-color); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning-color); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: var(--danger-color);  }

/* ======================== Table ======================== */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead tr { background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--panel-border); }
th { padding: 0.875rem 1rem; text-align: left; font-size: 0.72rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 0.875rem 1rem; vertical-align: middle; border-bottom: 1px solid rgba(255,255,255,0.04); }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
code { font-family: monospace; font-size: 0.82rem; color: #a5b4fc; background: rgba(99,102,241,0.1); padding: 2px 6px; border-radius: 4px; }

/* ======================== Alert ======================== */
.alert { padding: 0.875rem 1rem; border-radius: 10px; font-size: 0.875rem; margin-bottom: 1rem; }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2); color: var(--success-color); }
.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.2);  color: var(--danger-color);  }

/* ======================== Spinner ======================== */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======================== Login page ======================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
}

/* ======================== Quota grid ======================== */
.quota-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; }
.quota-cell {
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 0.625rem;
  text-align: center;
}
.quota-cell .q-label { font-size: 0.7rem; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.quota-cell .q-val   { font-size: 1.1rem; font-weight: 700; }
.quota-cell .q-meta  { font-size: 0.65rem; color: rgba(148,163,184,0.5); margin-top: 2px; }

/* ======================== User card ======================== */
.user-card {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.user-card-body { padding: 0.875rem 1.25rem; }

/* ======================== Expanded key row ======================== */
.key-expand-row td { background: rgba(99,102,241,0.06); }

/* ======================== Pagination ======================== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ======================== Products & Subtabs UI ======================== */
.subtab-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.75rem;
}
.subtab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.subtab-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.05);
}
.subtab-btn.active {
  background: var(--primary-light);
  border-color: rgba(99,102,241,0.3);
  color: #a5b4fc;
}

.products-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
}

/* Image upload dropzone with 1:1 aspect ratio */
.upload-dropzone {
  border: 2px dashed rgba(99,102,241,0.35);
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  aspect-ratio: 1 / 1;
  max-width: 240px;
  margin: 0 auto 1rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: all 0.2s ease;
}
.upload-dropzone:hover {
  border-color: var(--primary-color);
  background: rgba(99,102,241,0.08);
}
.upload-dropzone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.upload-dropzone .dz-placeholder {
  text-align: center;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.upload-dropzone .dz-placeholder span.icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.25rem;
}

/* Product Card in B2B List */
.product-card {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s ease;
  position: relative;
}
.product-card:hover {
  border-color: rgba(99,102,241,0.3);
}
.product-card.inactive {
  opacity: 0.6;
}
.product-card-thumb {
  width: 110px;
  height: 110px;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: rgba(0,0,0,0.4);
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}
.product-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.product-card-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  margin-bottom: 0.25rem;
  word-break: break-word;
}
.product-card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: auto;
  font-size: 0.78rem;
}
.price-badge {
  background: rgba(16,185,129,0.15);
  color: var(--success-color);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(16,185,129,0.3);
}
.btn-tag {
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* Gateway Link Box */
.gateway-box {
  background: rgba(99,102,241,0.06);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.gateway-box code {
  color: #a5b4fc;
  font-size: 0.85rem;
  word-break: break-all;
  font-family: monospace;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 1rem;
}
.modal-card {
  width: 100%;
  max-width: 460px;
  background: #181b26;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Switch toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255,255,255,0.15);
  transition: .2s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary-color);
}
input:checked + .slider:before {
  transform: translateX(18px);
}

/* ======================== Responsive ======================== */
@media (max-width: 992px) {
  .quota-grid { grid-template-columns: repeat(3, 1fr); }
  .products-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .page-wrapper { padding: 1rem 0.5rem; }
  .glass-panel { padding: 1.25rem; border-radius: 16px; }
  
  .app-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .app-header button { width: 100%; }

  .tab-bar { flex-wrap: wrap; gap: 0.35rem; }
  .tab-btn { flex: 1 1 calc(50% - 0.35rem); font-size: 0.8rem; padding: 0.55rem 0.5rem; text-align: center; }

  .grid-2col { grid-template-columns: 1fr !important; }

  .quota-grid { grid-template-columns: repeat(2, 1fr); }

  .user-card-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .user-card-header > div:last-child { width: 100%; justify-content: space-between; }

  table { font-size: 0.8rem; min-width: 600px; }
  
  .form-control { font-size: 0.85rem; padding: 0.6rem 0.75rem; }
}

@media (max-width: 480px) {
  .tab-btn { flex: 1 1 100%; }
  .quota-grid { grid-template-columns: 1fr; }
}

