/* =====================================================================
   HOÀN TIỀN OULI - USER DASHBOARD & ADMIN STYLING
===================================================================== */

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

/* Sidebar */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.app-sidebar {
  width: 270px;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.sidebar-close-btn {
  display: none;
}

.sidebar-wallet-card {
  margin: 14px 16px 6px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
  border: 1px solid #bfdbfe;
}

.sidebar-nav {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.8px;
  padding: 12px 10px 4px;
  text-transform: uppercase;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 650;
  font-size: 0.9rem;
  color: #475569;
  transition: all 0.2s ease;
  text-decoration: none;
}

.sidebar-item i {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  color: #64748b;
  transition: color 0.2s ease;
}

.sidebar-item:hover,
.sidebar-item.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 750;
}

.sidebar-item:hover i,
.sidebar-item.active i {
  color: var(--primary);
}

/* User Profile Card in Sidebar */
.sidebar-user {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
}

.user-avatar-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
  flex-shrink: 0;
}

/* Main Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-body);
}

.app-topbar {
  height: 70px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 99;
}

.topbar-toggle-btn {
  display: none;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.wallet-badge-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--success-light);
  color: var(--success);
  font-weight: 700;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.92rem;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.app-content {
  padding: 32px;
  flex: 1;
}

/* Card & Tables */
.card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 750;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.data-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: #f8fafc;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-pending {
  background: #fef3c7;
  color: #b45309;
}

.badge-completed {
  background: #ecfdf5;
  color: #047857;
}

.badge-canceled {
  background: #fef2f2;
  color: #b91c1c;
}

.badge-failed {
  background: #f1f5f9;
  color: #475569;
}

/* Wheel Canvas container */
.wheel-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 20px 0;
  position: relative;
}

.wheel-pointer {
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 26px solid #ef4444;
  position: absolute;
  top: -8px;
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

#wheelCanvas {
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  border: 8px solid #ffffff;
  transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

/* Form inputs */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
  background: #ffffff;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Flash alerts */
.alert {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  margin-bottom: 24px;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ═══════════════════════════════════════════════════════════
   MODAL & BACKDROP OVERLAYS
═══════════════════════════════════════════════════════════ */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1055;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.sidebar-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Responsive Dashboard for All Devices (320px - 1024px) */
@media (max-width: 992px) {
  .topbar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: #1e293b;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
  }

  .topbar-toggle-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
  }

  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
  }

  .sidebar-close-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
  }

  .topbar-btn-create {
    display: none;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 86vw);
    height: 100vh;
    z-index: 1060;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 6px 0 32px rgba(15, 23, 42, 0.2);
    display: flex;
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  /* Universal collapse for multi-column grids in user dashboard */
  div[style*="grid-template-columns"]:not(.keep-grid),
  form[style*="grid-template-columns"]:not(.keep-grid) {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)) !important;
    gap: 14px !important;
  }

  .app-content {
    padding: 20px 16px;
  }
}

@media (max-width: 600px) {
  .app-topbar {
    padding: 0 12px;
    height: 60px;
    gap: 8px;
  }

  .topbar-title {
    font-size: 1.05rem;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-actions {
    gap: 8px;
  }

  .wallet-badge-pill {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .wallet-badge-pill span {
    display: none;
  }

  .d-none-mobile {
    display: none !important;
  }

  .app-content {
    padding: 14px 10px;
  }

  .card {
    padding: 16px 12px;
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .stat-card {
    padding: 14px 14px;
    border-radius: 14px;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  .data-table-wrapper {
    border-radius: 10px;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 0.82rem;
  }
}

@media (max-width: 380px) {
  .topbar-title {
    max-width: 120px;
    font-size: 0.95rem;
  }

  .wallet-badge-pill {
    font-size: 0.75rem;
    padding: 3px 6px;
  }
}