/* ============================================================
   Spondias Fintech — Admin Web Panel
   Design tokens: v2 Safari (Abdimalik)
   Primary: #1E9ED6 | Text: #0D0D0D | Base: #FFFFFF
   ============================================================ */

:root {
  /* Brand */
  --primary: #1E9ED6;
  --primary-hover: #198bc0;
  --primary-light: rgba(30, 158, 214, 0.12);
  --primary-surface: rgba(30, 158, 214, 0.08);
  --primary-gradient: linear-gradient(180deg, #1E9ED6, rgba(30, 158, 214, 0.85));

  /* Text — #0D0D0D at opacities */
  --text: #0D0D0D;
  --text-primary: rgba(13, 13, 13, 1);
  --text-secondary: rgba(13, 13, 13, 0.6);
  --text-tertiary: rgba(13, 13, 13, 0.4);
  --text-muted: rgba(13, 13, 13, 0.3);

  /* Surfaces */
  --bg-page: rgba(13, 13, 13, 0.04);
  --bg-card: #FFFFFF;
  --bg-sidebar: #0D0D0D;
  --bg-input: #FFFFFF;
  --bg-hover: rgba(13, 13, 13, 0.04);
  --bg-row-hover: rgba(30, 158, 214, 0.04);

  /* Borders */
  --border: rgba(13, 13, 13, 0.08);
  --border-light: rgba(13, 13, 13, 0.04);

  /* Semantic */
  --success: #1E9ED6;
  --success-bg: rgba(30, 158, 214, 0.1);
  --warning: #FF9800;
  --warning-bg: rgba(255, 152, 0, 0.1);
  --error: #E53935;
  --error-bg: rgba(229, 57, 53, 0.1);
  --info: #1E9ED6;
  --info-bg: rgba(30, 158, 214, 0.1);

  /* Radius */
  --radius-card: 16px;
  --radius-btn: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-dropdown: 0 4px 16px rgba(0, 0, 0, 0.1);

  /* Spacing */
  --sidebar-w: 240px;
  --topbar-h: 64px;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

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

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  padding: 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}

.nav-item.active {
  background: var(--primary);
  color: #FFFFFF;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--error);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Top Bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
}

.topbar-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--bg-input);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease;
}

.topbar-search input::placeholder {
  color: var(--text-tertiary);
}

.topbar-search input:focus {
  border-color: var(--primary);
}

.topbar-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.topbar-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-btn);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: background 0.15s ease;
  position: relative;
}

.topbar-btn:hover {
  background: var(--bg-hover);
}

.topbar-btn .notif-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

.topbar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease;
}

.topbar-profile:hover {
  background: var(--bg-hover);
}

.topbar-profile .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.topbar-profile .name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* --- Page Content --- */
.page-content {
  padding: 28px 32px;
  flex: 1;
}

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.page-header .page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
}

/* --- KPI / Stats Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.stat-card .stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
}

.stat-card .stat-icon.blue {
  background: var(--primary-surface);
  color: var(--primary);
}

.stat-card .stat-icon.green {
  background: var(--success-bg);
  color: var(--success);
}

.stat-card .stat-icon.orange {
  background: var(--warning-bg);
  color: var(--warning);
}

.stat-card .stat-icon.red {
  background: var(--error-bg);
  color: var(--error);
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.stat-card .stat-change {
  font-size: 12px;
  margin-top: 8px;
  font-weight: 500;
}

.stat-card .stat-change.up {
  color: var(--primary);
}

.stat-card .stat-change.down {
  color: var(--error);
}

/* --- Section --- */
.section {
  margin-bottom: 32px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-header .section-actions {
  display: flex;
  gap: 8px;
}

/* --- Card --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.card-body {
  padding: 20px 24px;
}

.card-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Table --- */
.table-container {
  overflow-x: auto;
}

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

.data-table th {
  padding: 14px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: var(--bg-row-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.data-table .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-surface);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.data-table .user-name {
  font-weight: 500;
}

.data-table .user-email {
  font-size: 13px;
  color: var(--text-secondary);
}

.table-empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.table-empty .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-primary {
  background: var(--info-bg);
  color: var(--primary);
}

.badge-success {
  background: var(--success-bg);
  color: var(--primary);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
}

.badge-neutral {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-btn);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

.btn-success {
  background: var(--success);
  color: #FFFFFF;
}

.btn-success:hover:not(:disabled) {
  background: #198bc0;
}

.btn-danger {
  background: var(--error);
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  background: #c62828;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-surface);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* --- Filters --- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-bar select,
.filter-bar input {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
}

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

.filter-bar select {
  min-width: 140px;
}

.filter-bar input {
  min-width: 200px;
}

/* --- KYC Review --- */
.kyc-queue {
  display: grid;
  gap: 16px;
}

.kyc-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-light);
  transition: transform 0.1s ease;
}

.kyc-item:hover {
  transform: translateX(4px);
}

.kyc-item .kyc-docs {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.kyc-item .kyc-doc-thumb {
  width: 72px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-tertiary);
}

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

.kyc-item .kyc-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.kyc-item .kyc-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.kyc-item .kyc-time {
  font-size: 12px;
  color: var(--text-tertiary);
}

.kyc-item .kyc-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}

/* --- Transaction Log --- */
.tx-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
}

.tx-item:last-child {
  border-bottom: none;
}

.tx-item .tx-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.tx-item .tx-icon.incoming {
  background: var(--success-bg);
  color: var(--success);
}

.tx-item .tx-icon.outgoing {
  background: var(--error-bg);
  color: var(--error);
}

.tx-item .tx-icon.internal {
  background: var(--info-bg);
  color: var(--info);
}

.tx-item .tx-details {
  flex: 1;
  min-width: 0;
}

.tx-item .tx-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.tx-item .tx-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.tx-item .tx-amount {
  text-align: right;
  font-weight: 600;
  font-size: 14px;
}

.tx-item .tx-amount.positive {
  color: var(--success);
}

.tx-item .tx-amount.negative {
  color: var(--error);
}

.tx-item .tx-time {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: right;
  min-width: 64px;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 0;
}

.pagination button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s ease;
}

.pagination button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 12px;
}

/* --- Loading & Empty States --- */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--text-secondary);
}

.loading-state .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 16px;
}

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

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  color: var(--error);
}

.error-state .error-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

/* --- Responsive --- */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 64px;
  }
  .sidebar-brand .brand-text,
  .nav-item .nav-text,
  .nav-item .nav-badge,
  .sidebar-footer {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: 12px;
  }
  .main-content {
    margin-left: 64px;
  }
  .topbar {
    padding: 0 16px;
  }
  .page-content {
    padding: 20px 16px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .topbar-search {
    max-width: 200px;
  }
}

@media (max-width: 480px) {
  .topbar-profile .name {
    display: none;
  }
  .topbar-search {
    display: none;
  }
}
