/* MujeStore Payment Gateway — Binance-style Design System */
/* Based on DESIGN.md */

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

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

:root {
  --canvas: #0b0e11;
  --surface: #1e2329;
  --elevated: #2b3139;
  --primary: #FCD535;
  --primary-active: #f0b90b;
  --primary-disabled: #3a3a1f;
  --on-primary: #181a20;
  --on-dark: #ffffff;
  --body: #eaecef;
  --muted: #707a8a;
  --muted-strong: #929aa5;
  --green: #0ecb81;
  --red: #f6465d;
  --info: #3b82f6;
  --hairline: #2b3139;

  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-number: 'JetBrains Mono', monospace;

  --rounded-sm: 4px;
  --rounded-md: 6px;
  --rounded-lg: 8px;
  --rounded-xl: 12px;
  --rounded-pill: 9999px;
}

html, body { height: 100%; }

body {
  font-family: var(--font-display);
  background: var(--canvas);
  color: var(--body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ APP LAYOUT ============ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--hairline);
}

.sidebar-logo {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--on-dark);
}

.sidebar-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--rounded-lg);
  color: var(--muted-strong);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--elevated);
  color: var(--on-dark);
}

.nav-item.active {
  background: rgba(252, 213, 53, 0.1);
  color: var(--primary);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.stat-icon {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  margin-right: 6px;
}

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

.user-label {
  font-size: 13px;
  color: var(--muted);
}

.btn-logout {
  background: none;
  border: 1px solid var(--hairline);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: var(--rounded-md);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ============ MAIN CONTENT ============ */

.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  min-height: 100vh;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--on-dark);
  margin-bottom: 24px;
}

/* ============ STAT CARDS ============ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--rounded-xl);
  padding: 20px;
  border: 1px solid var(--hairline);
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-number);
  font-size: 24px;
  font-weight: 700;
  color: var(--on-dark);
}

.stat-value.primary { color: var(--primary); }
.stat-value.green { color: var(--green); }

.stat-count {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ============ CHART ============ */

.chart-container {
  background: var(--surface);
  border-radius: var(--rounded-xl);
  padding: 24px;
  border: 1px solid var(--hairline);
  margin-bottom: 32px;
}

.chart-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--on-dark);
  margin-bottom: 16px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 8px;
}

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

.chart-bar {
  width: 100%;
  max-width: 48px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s ease;
}

.chart-bar:hover {
  background: var(--primary-active);
}

.chart-bar-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
}

.chart-bar-value {
  font-family: var(--font-number);
  font-size: 11px;
  color: var(--muted-strong);
  margin-bottom: 4px;
}

/* ============ TABLE ============ */

.table-container {
  background: var(--surface);
  border-radius: var(--rounded-xl);
  border: 1px solid var(--hairline);
  overflow: hidden;
}

.table-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.table-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--on-dark);
}

.table-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-input, .filter-select {
  background: var(--elevated);
  border: 1px solid var(--hairline);
  color: var(--body);
  padding: 6px 12px;
  border-radius: var(--rounded-md);
  font-size: 13px;
  font-family: var(--font-display);
  outline: none;
}

.filter-input:focus, .filter-select:focus {
  border-color: var(--primary);
}

.filter-input::placeholder {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

td {
  padding: 12px 20px;
  font-size: 13px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.td-amount {
  font-family: var(--font-number);
  font-weight: 500;
}

.td-ref {
  font-family: var(--font-number);
  font-size: 12px;
  color: var(--muted-strong);
}

/* ============ BADGES ============ */

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--rounded-pill);
  font-size: 12px;
  font-weight: 600;
}

.badge-paid { background: rgba(14, 203, 129, 0.12); color: var(--green); }
.badge-pending { background: rgba(252, 213, 53, 0.12); color: var(--primary); }
.badge-expired { background: rgba(246, 70, 93, 0.12); color: var(--red); }
.badge-active { background: rgba(14, 203, 129, 0.12); color: var(--green); }
.badge-unknown { background: rgba(112, 122, 138, 0.12); color: var(--muted); }

/* ============ BUTTONS ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border-radius: var(--rounded-md);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover { background: var(--primary-active); }

.btn-secondary {
  background: var(--elevated);
  color: var(--on-dark);
  border: 1px solid var(--hairline);
}
.btn-secondary:hover { border-color: var(--muted); }

.btn-danger {
  background: rgba(246, 70, 93, 0.12);
  color: var(--red);
  border: 1px solid transparent;
}
.btn-danger:hover { border-color: var(--red); }

.btn-sm {
  padding: 4px 12px;
  font-size: 12px;
}

/* ============ FORMS ============ */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-input, .form-textarea {
  width: 100%;
  background: var(--elevated);
  border: 1px solid var(--hairline);
  color: var(--body);
  padding: 10px 14px;
  border-radius: var(--rounded-md);
  font-size: 14px;
  font-family: var(--font-display);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* ============ MODAL ============ */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

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

.modal {
  background: var(--surface);
  border-radius: var(--rounded-xl);
  padding: 32px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--hairline);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--on-dark);
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ============ PAGINATION ============ */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 20px;
}

.page-btn {
  padding: 6px 12px;
  border-radius: var(--rounded-md);
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-display);
  transition: all 0.15s;
}

.page-btn:hover { border-color: var(--muted); color: var(--body); }
.page-btn.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* ============ LOADING ============ */

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--hairline);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============ LOGIN PAGE ============ */

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--rounded-xl);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  border: 1px solid var(--hairline);
}

.login-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--on-dark);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-error {
  background: rgba(246, 70, 93, 0.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 8px 14px;
  border-radius: var(--rounded-md);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

.login-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
}

/* ============ TOAST ============ */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--rounded-lg);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--body);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

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

/* ============ TOGGLE SWITCH ============ */

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

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

.toggle-slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--elevated);
  border-radius: 24px;
  transition: background-color 0.3s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--muted);
  border-radius: 50%;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--green);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background-color: white;
}

.badge-active {
  background: rgba(14, 203, 129, 0.15);
  color: var(--green);
}

.badge-unknown {
  background: rgba(112, 122, 138, 0.15);
  color: var(--muted);
}

/* ============ SETTINGS FEATURE CARDS ============ */

.settings-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.settings-feature-card {
  background: var(--surface);
  border-radius: var(--rounded-xl);
  border: 1px solid var(--hairline);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease;
}

.settings-feature-card:hover {
  border-color: var(--primary);
}

.sfc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sfc-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--elevated);
  border-radius: 10px;
  flex-shrink: 0;
}

.sfc-info {
  flex: 1;
  min-width: 0;
}

.sfc-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-dark);
}

.sfc-status {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.sfc-edit-btn {
  margin-top: auto;
  align-self: flex-end;
  font-size: 13px;
  padding: 6px 16px;
}

.sfc-panel {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
  margin-top: 0;
}

.sfc-panel.open {
  max-height: 400px;
  opacity: 1;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
}

/* ============ RESPONSIVE ============ */


@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -240px;
    transition: left 0.3s ease;
  }
  .sidebar.open { left: 0; }
  .main-content { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: 1fr; }
  .settings-cards { grid-template-columns: 1fr; }
}
