/* ==========================================================================
   CardPro.vn - Main Stylesheet with Comprehensive Dark/Light Theme System
   ========================================================================== */

:root {
  /* Color Palette (Light Mode Default) */
  --primary-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --primary-color: #2563eb;
  --accent-color: #ff6b35;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  /* Theme Surfaces (Light) */
  --cp-bg: #f8fafc;
  --cp-text: #1e293b;
  --cp-text-muted: #64748b;
  --cp-card-bg: #ffffff;
  --cp-card-border: #e2e8f0;
  --cp-navbar-bg: #ffffff;
  --cp-navbar-border: #e2e8f0;
  --cp-input-bg: #ffffff;
  --cp-input-border: #cbd5e1;
  --cp-input-text: #0f172a;
  --cp-pill-bg: #ffffff;
  --cp-pill-border: #e2e8f0;
  --cp-dropdown-bg: #ffffff;
  --cp-table-border: #e2e8f0;
  --cp-modal-bg: #ffffff;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
}

[data-bs-theme="dark"] {
  /* Color Palette (Dark Mode) */
  --primary-gradient: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  --primary-color: #3b82f6;
  --accent-color: #ff8c42;
  --success-color: #10b981;
  --warning-color: #fbbf24;
  --danger-color: #f87171;

  /* Theme Surfaces (Dark - Slate Navy) */
  --cp-bg: #0b1120;
  --cp-text: #f1f5f9;
  --cp-text-muted: #94a3b8;
  --cp-card-bg: #131b2e;
  --cp-card-border: #1e293b;
  --cp-navbar-bg: #0f172a;
  --cp-navbar-border: #1e293b;
  --cp-input-bg: #0b1120;
  --cp-input-border: #2e384d;
  --cp-input-text: #f8fafc;
  --cp-pill-bg: #131b2e;
  --cp-pill-border: #2e384d;
  --cp-dropdown-bg: #131b2e;
  --cp-table-border: #1e293b;
  --cp-modal-bg: #131b2e;
  --card-bg: #131b2e;
  --card-border: #1e293b;
}

/* ==========================================================================
   Base Elements
   ========================================================================== */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--cp-bg);
  color: var(--cp-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Navbar */
.cp-navbar {
  background-color: var(--cp-navbar-bg) !important;
  border-bottom: 1px solid var(--cp-navbar-border) !important;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.navbar-brand {
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #1e3c72 !important;
  transition: color 0.2s ease;
}

.navbar-brand span {
  color: #ff6b35;
}

[data-bs-theme="dark"] .navbar-brand {
  color: #60a5fa !important;
}

.nav-link {
  font-weight: 500;
  color: var(--cp-text-muted);
  transition: all 0.2s ease;
}

.nav-link:hover, .nav-link.active {
  color: #1e3c72 !important;
}

[data-bs-theme="dark"] .nav-link {
  color: #94a3b8;
}

[data-bs-theme="dark"] .nav-link:hover,
[data-bs-theme="dark"] .nav-link.active {
  color: #60a5fa !important;
}

/* ==========================================================================
   Theme Switcher Button
   ========================================================================== */
.theme-toggle-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--cp-card-border);
  color: var(--cp-text);
  background: var(--cp-card-bg);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.theme-toggle-btn:hover {
  background: var(--cp-pill-bg);
  color: #3b82f6;
  border-color: #3b82f6;
  transform: scale(1.05);
}

[data-bs-theme="dark"] .theme-toggle-btn {
  border-color: #2e384d;
  color: #f1f5f9;
  background: #1e293b;
}

[data-bs-theme="dark"] .theme-toggle-btn:hover {
  background: #25334d;
  border-color: #60a5fa;
  color: #60a5fa;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e3c72 100%);
  color: white;
  padding: 60px 0 40px;
  border-radius: 0 0 24px 24px;
  margin-bottom: 30px;
}

/* ==========================================================================
   Cards & Components
   ========================================================================== */
.card-custom {
  border: 1px solid var(--cp-card-border);
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  background: var(--cp-card-bg);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.25s ease, border-color 0.25s ease;
}

.card-custom:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .card-custom {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .card {
  background-color: var(--cp-card-bg);
  border-color: var(--cp-card-border);
}

/* Primary Gradient Buttons */
.btn-primary-gradient {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  padding: 10px 20px;
  transition: all 0.2s;
}

.btn-primary-gradient:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  color: white;
  transform: scale(1.02);
}

.btn-accent {
  background-color: #ff6b35;
  color: white;
  border-radius: 10px;
  font-weight: 600;
}

.btn-accent:hover {
  background-color: #e85d26;
  color: white;
}

/* ==========================================================================
   Form Controls in Dark Mode
   ========================================================================== */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--cp-input-bg);
  border-color: var(--cp-input-border);
  color: var(--cp-input-text);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
  background-color: #0f172a;
  border-color: #3b82f6;
  color: #ffffff;
  box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: #64748b;
}

[data-bs-theme="dark"] .input-group-text {
  background-color: #1e293b;
  border-color: var(--cp-input-border);
  color: #94a3b8;
}

/* ==========================================================================
   Telco & Denomination Selector Buttons
   ========================================================================== */
.telco-btn {
  border: 2px solid var(--cp-card-border);
  border-radius: 12px;
  padding: 12px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--cp-card-bg);
  color: var(--cp-text);
  font-weight: 600;
}

.telco-btn:hover {
  border-color: #2563eb;
  background-color: #eff6ff;
}

[data-bs-theme="dark"] .telco-btn:hover {
  border-color: #3b82f6;
  background-color: #1e293b;
}

.telco-btn.active {
  border-color: #2563eb;
  background-color: #2563eb;
  color: white !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.denom-btn {
  border: 1px solid var(--cp-card-border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  background: var(--cp-card-bg);
  color: var(--cp-text);
  transition: all 0.2s;
  font-weight: 600;
}

.denom-btn:hover {
  border-color: #2563eb;
  background: #f8fafc;
}

[data-bs-theme="dark"] .denom-btn:hover {
  border-color: #3b82f6;
  background: #1e293b;
}

.denom-btn.active {
  background: #1e3c72;
  color: white !important;
  border-color: #1e3c72;
}

[data-bs-theme="dark"] .denom-btn.active {
  background: #2563eb;
  border-color: #3b82f6;
}

/* Balance Box */
.wallet-box {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: white;
  border-radius: 16px;
  padding: 24px;
}

.wallet-amount {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Status Badges */
.badge-pending {
  background-color: #fef3c7;
  color: #d97706;
  border: 1px solid #fde68a;
  padding: 6px 12px;
  border-radius: 20px;
}

.badge-success {
  background-color: #d1fae5;
  color: #059669;
  border: 1px solid #a7f3d0;
  padding: 6px 12px;
  border-radius: 20px;
}

.badge-failed {
  background-color: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
  padding: 6px 12px;
  border-radius: 20px;
}

[data-bs-theme="dark"] .badge-pending {
  background-color: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

[data-bs-theme="dark"] .badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

[data-bs-theme="dark"] .badge-failed {
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ==========================================================================
   Dropdowns & Modals
   ========================================================================== */
[data-bs-theme="dark"] .dropdown-menu {
  background-color: var(--cp-dropdown-bg);
  border: 1px solid var(--cp-card-border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45) !important;
}

[data-bs-theme="dark"] .dropdown-item {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
  background-color: #1e293b;
  color: #ffffff;
}

[data-bs-theme="dark"] .dropdown-item.active {
  background-color: #2563eb;
  color: #ffffff;
}

[data-bs-theme="dark"] .dropdown-divider {
  border-color: var(--cp-card-border);
}

[data-bs-theme="dark"] .modal-content {
  background-color: var(--cp-modal-bg);
  border: 1px solid var(--cp-card-border);
}

[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
  border-color: var(--cp-card-border);
}

/* ==========================================================================
   Tables in Dark Mode
   ========================================================================== */
[data-bs-theme="dark"] .table {
  color: var(--cp-text);
  border-color: var(--cp-table-border);
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
  background-color: transparent;
  border-bottom-color: var(--cp-table-border);
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: rgba(255, 255, 255, 0.02);
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] thead.table-light th {
  background-color: #131b2e !important;
  color: #94a3b8 !important;
  border-color: var(--cp-table-border) !important;
}

/* ==========================================================================
   Bootstrap Utility Overrides for Dark Mode
   ========================================================================== */
[data-bs-theme="dark"] .bg-white {
  background-color: var(--cp-card-bg) !important;
}

[data-bs-theme="dark"] .bg-light {
  background-color: rgba(255, 255, 255, 0.04) !important;
}

[data-bs-theme="dark"] .text-dark {
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .text-muted {
  color: #94a3b8 !important;
}

[data-bs-theme="dark"] .border {
  border-color: var(--cp-card-border) !important;
}

[data-bs-theme="dark"] .border-bottom {
  border-bottom-color: var(--cp-card-border) !important;
}

[data-bs-theme="dark"] .border-top {
  border-top-color: var(--cp-card-border) !important;
}

[data-bs-theme="dark"] .border-end {
  border-end-color: var(--cp-card-border) !important;
}

[data-bs-theme="dark"] .border-start {
  border-start-color: var(--cp-card-border) !important;
}

/* ==========================================================================
   Topup Specifics in Dark Mode
   ========================================================================== */
[data-bs-theme="dark"] .topup-tabs {
  background: #0b1120 !important;
  border-color: #1e293b !important;
}

[data-bs-theme="dark"] .topup-tabs .nav-link {
  color: #94a3b8;
}

[data-bs-theme="dark"] .topup-tabs .nav-link.active {
  background: #1e293b;
  color: #f8fafc !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .topup-product-item,
[data-bs-theme="dark"] .package-box {
  background-color: #131b2e !important;
  border-color: #1e293b !important;
  color: #f1f5f9 !important;
}

[data-bs-theme="dark"] .topup-product-item:hover,
[data-bs-theme="dark"] .package-box:hover {
  background-color: #1e293b !important;
  border-color: #3b82f6 !important;
}

[data-bs-theme="dark"] .topup-product-item.active,
[data-bs-theme="dark"] .package-box.active {
  border-color: #3b82f6 !important;
  background-color: #172554 !important;
}

/* ==========================================================================
   API Docs in Dark Mode
   ========================================================================== */
[data-bs-theme="dark"] .api-hub-tab {
  background: #131b2e;
  border-color: #1e293b;
}

[data-bs-theme="dark"] .api-hub-tab.is-active {
  background: linear-gradient(135deg, #1e3a5f 0%, #172554 100%);
  border-color: #3b82f6;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

[data-bs-theme="dark"] .api-hub-tab__label {
  color: #f8fafc;
}

[data-bs-theme="dark"] .api-hub-tab__desc {
  color: #94a3b8;
}

[data-bs-theme="dark"] .api-doc-card {
  background: #131b2e;
  border-color: #1e293b;
}

[data-bs-theme="dark"] .api-doc-card-title {
  color: #f8fafc;
  border-bottom-color: #1e293b;
}

[data-bs-theme="dark"] .api-doc-endpoint-box {
  background: #131b2e;
  border-color: #1e293b;
  color: #f8fafc;
}

[data-bs-theme="dark"] .api-doc-jump a,
[data-bs-theme="dark"] .api-doc-lang-links a {
  background: #1e293b;
  color: #60a5fa;
}

[data-bs-theme="dark"] .api-doc-jump a:hover,
[data-bs-theme="dark"] .api-doc-lang-links a:hover {
  background: #2563eb;
  color: #ffffff;
}

[data-bs-theme="dark"] .api-doc-values span {
  background: #1e293b;
  color: #cbd5e1;
}

[data-bs-theme="dark"] .api-doc-pre-light {
  background: #0b1120;
  border-color: #1e293b;
  color: #f8fafc;
}

/* ==========================================================================
   Footer
   ========================================================================== */
footer {
  margin-top: auto;
  background-color: #0f172a;
  color: #94a3b8;
  padding: 40px 0 20px;
}

footer a {
  color: #cbd5e1;
  text-decoration: none;
}

footer a:hover {
  color: white;
}

[data-bs-theme="dark"] footer {
  background-color: #080d1a;
  border-top: 1px solid #1e293b;
}

/* ==========================================================================
   Toast Notification System (3s Cooldown with Progress Bar)
   ========================================================================== */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.custom-toast {
  pointer-events: auto;
  position: relative;
  background: var(--cp-card-bg);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--cp-card-border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

[data-bs-theme="dark"] .custom-toast {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.custom-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.custom-toast.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast-body-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
}

.toast-icon {
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}

.toast-content {
  flex-grow: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 2px;
  color: var(--cp-text);
}

.toast-message {
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--cp-text-muted);
}

.toast-close-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--cp-text-muted);
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.toast-close-btn:hover {
  opacity: 1;
  color: var(--cp-text);
}

.toast-progress {
  height: 4px;
  width: 100%;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

[data-bs-theme="dark"] .toast-progress {
  background: rgba(255, 255, 255, 0.06);
}

.toast-progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  animation: toastProgress linear forwards;
}

@keyframes toastProgress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

/* Toast Color Themes */
.custom-toast.toast-success {
  border-left: 5px solid #10b981;
}
.custom-toast.toast-success .toast-icon {
  color: #10b981;
}
.custom-toast.toast-success .toast-title {
  color: #10b981;
}
.custom-toast.toast-success .toast-progress-bar {
  background: #10b981;
}

.custom-toast.toast-danger,
.custom-toast.toast-error {
  border-left: 5px solid #ef4444;
}
.custom-toast.toast-danger .toast-icon,
.custom-toast.toast-error .toast-icon {
  color: #ef4444;
}
.custom-toast.toast-danger .toast-title,
.custom-toast.toast-error .toast-title {
  color: #ef4444;
}
.custom-toast.toast-danger .toast-progress-bar,
.custom-toast.toast-error .toast-progress-bar {
  background: #ef4444;
}

.custom-toast.toast-warning {
  border-left: 5px solid #f59e0b;
}
.custom-toast.toast-warning .toast-icon {
  color: #f59e0b;
}
.custom-toast.toast-warning .toast-title {
  color: #f59e0b;
}
.custom-toast.toast-warning .toast-progress-bar {
  background: #f59e0b;
}

.custom-toast.toast-info {
  border-left: 5px solid #3b82f6;
}
.custom-toast.toast-info .toast-icon {
  color: #3b82f6;
}
.custom-toast.toast-info .toast-title {
  color: #3b82f6;
}
.custom-toast.toast-info .toast-progress-bar {
  background: #3b82f6;
}

/* ==========================================================================
   Admin Sidebar Navigation
   ========================================================================== */
.admin-sidebar {
  border-radius: 16px;
  background-color: var(--cp-card-bg);
  border: 1px solid var(--cp-card-border);
}

.admin-nav-pills .nav-link {
  color: var(--cp-text);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.2s ease;
}

.admin-nav-pills .nav-link:hover {
  background-color: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  transform: translateX(3px);
}

.admin-nav-pills .nav-link.active {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%) !important;
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.admin-nav-pills .nav-link.active i {
  color: #ffffff !important;
}

[data-bs-theme="dark"] .admin-nav-pills .nav-link {
  color: #cbd5e1;
}

[data-bs-theme="dark"] .admin-nav-pills .nav-link:hover {
  background-color: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
}

[data-bs-theme="dark"] .admin-nav-pills .nav-link.active {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
