/* ==========================================================================
   BokjiBot Admin Dashboard Modern Styles
   ========================================================================== */

:root {
  --admin-bg: #07090e;
  --admin-surface: #0f172a;
  --admin-surface-card: rgba(15, 23, 42, 0.75);
  --admin-surface-hover: rgba(30, 41, 59, 0.8);
  --admin-border: rgba(255, 255, 255, 0.08);
  --admin-border-focus: #6366f1;
  --admin-text-main: #f8fafc;
  --admin-text-muted: #94a3b8;
  --admin-accent-primary: #6366f1;
  --admin-accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --admin-badge-success-bg: rgba(16, 185, 129, 0.15);
  --admin-badge-success-text: #34d399;
  --admin-badge-danger-bg: rgba(239, 68, 68, 0.15);
  --admin-badge-danger-text: #f87171;
  --admin-badge-info-bg: rgba(99, 102, 241, 0.15);
  --admin-badge-info-text: #818cf8;
}

body.admin-body {
  background-color: var(--admin-bg);
  color: var(--admin-text-main);
  font-family: 'Pretendard', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Atmosphere Glows */
.glow-sphere {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}
.glow-1 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
  top: -150px;
  left: 10%;
}
.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
  bottom: -200px;
  right: 5%;
}

.admin-wrapper {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px 48px;
}

/* Header */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--admin-surface-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--admin-border);
  border-radius: 18px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  background: var(--admin-accent-gradient);
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 1px;
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  display: block;
  font-size: 12px;
  color: var(--admin-text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.source-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--admin-border);
}

.source-label {
  font-size: 12px;
  color: var(--admin-text-muted);
}

.select-styled {
  background: transparent;
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}
.select-styled option {
  background: #0f172a;
  color: #fff;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-primary {
  background: var(--admin-accent-gradient);
  color: white;
  border: none;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--admin-text-main);
  border: 1px solid var(--admin-border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}
.btn-outline {
  background: transparent;
  color: var(--admin-text-muted);
  border: 1px solid var(--admin-border);
  text-decoration: none;
}
.btn-outline:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

/* KPI Metrics Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--admin-surface-card);
  backdrop-filter: blur(14px);
  border: 1px solid var(--admin-border);
  border-radius: 18px;
  padding: 20px 22px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.16);
}

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

.kpi-label {
  font-size: 13px;
  color: var(--admin-text-muted);
  font-weight: 500;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--admin-border);
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #fff;
  margin-bottom: 8px;
}

.kpi-footer {
  font-size: 12px;
  color: var(--admin-text-muted);
}

/* Main Panel & Tabs */
.admin-main {
  background: var(--admin-surface-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--admin-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 40px -15px rgba(0, 0, 0, 0.6);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--admin-border);
  background: rgba(0, 0, 0, 0.2);
}

.tabs-nav {
  display: flex;
  gap: 8px;
}

.tab-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--admin-text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}
.tab-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}
.tab-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.4);
}

.tab-badge {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
}
.tab-item.active .tab-badge {
  background: #6366f1;
}

.panel-search {
  width: 320px;
}
.input-search {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s ease;
}
.input-search:focus {
  border-color: #6366f1;
}

/* Data Table */
.table-container {
  overflow-x: auto;
  max-height: 600px;
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background: rgba(15, 23, 42, 0.9);
  color: var(--admin-text-muted);
  font-weight: 600;
  padding: 12px 18px;
  border-bottom: 1px solid var(--admin-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  vertical-align: middle;
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.025);
  color: #fff;
}

.empty-cell {
  text-align: center;
  padding: 40px !important;
  color: var(--admin-text-muted);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-success {
  background: var(--admin-badge-success-bg);
  color: var(--admin-badge-success-text);
}
.badge-danger {
  background: var(--admin-badge-danger-bg);
  color: var(--admin-badge-danger-text);
}
.badge-info {
  background: var(--admin-badge-info-bg);
  color: var(--admin-badge-info-text);
}
.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

/* Detail Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--admin-border);
  border-radius: 20px;
  width: 100%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--admin-border);
}
.modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--admin-text-muted);
  cursor: pointer;
}
.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 24px;
  font-size: 14px;
  line-height: 1.6;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 14px 20px;
  background: #1e1b4b;
  border: 1px solid #6366f1;
  color: #fff;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 200;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

/* Footer */
.admin-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 24px;
  font-size: 12px;
  color: var(--admin-text-muted);
  padding: 0 10px;
}

@media (max-width: 1024px) {
  .admin-wrapper {
    padding: 20px 20px 40px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .admin-header {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }
}

@media (max-width: 768px) {
  .admin-wrapper {
    padding: 12px 12px 32px;
  }
  .admin-header {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
  }
  .header-brand {
    gap: 10px;
  }
  .brand-title {
    font-size: 17px;
  }
  .brand-subtitle {
    font-size: 11px;
  }
  .header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .source-selector {
    flex: 1 1 100%;
    width: 100%;
    justify-content: space-between;
    padding: 8px 12px;
  }
  .header-actions .btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    font-size: 12px;
    padding: 9px 10px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
  }
  .kpi-card {
    padding: 14px 12px;
    border-radius: 14px;
  }
  .kpi-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
    border-radius: 8px;
  }
  .kpi-value {
    font-size: 22px;
    margin-bottom: 4px;
  }
  .kpi-label {
    font-size: 11.5px;
  }
  .kpi-footer {
    font-size: 10.5px;
  }
  .admin-main {
    border-radius: 16px;
  }
  .panel-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 14px;
  }
  .tabs-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    width: 100%;
  }
  .tabs-nav::-webkit-scrollbar {
    display: none;
  }
  .tab-item {
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: 13px;
  }
  .panel-search {
    width: 100%;
  }
  .input-search {
    font-size: 16px; /* Prevents auto-zoom on iOS */
    padding: 10px 14px;
    width: 100%;
  }
  .table-container {
    -webkit-overflow-scrolling: touch;
  }
  .data-table th, .data-table td {
    padding: 10px 12px;
    font-size: 12px;
  }
  .modal-card {
    width: 95%;
    max-height: 90vh;
    border-radius: 16px;
  }
  .modal-header {
    padding: 14px 16px;
  }
  .modal-title {
    font-size: 15px;
  }
  .modal-body {
    padding: 16px;
    font-size: 13px;
  }
  .modal-body div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  .admin-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    margin-top: 18px;
  }
}

@media (max-width: 480px) {
  #btn-run-pipeline {
    flex: 1 1 100%;
  }
  .header-actions .btn {
    font-size: 11.5px;
  }
  .kpi-card {
    padding: 12px 10px;
  }
  .kpi-value {
    font-size: 20px;
  }
}
