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

:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #12131a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --border-color: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(138, 43, 226, 0.5);
  
  --text-primary: #f5f6f9;
  --text-secondary: #8e92a8;
  --text-muted: #53566b;
  
  --accent-purple: #8e2de2;
  --accent-purple-light: #4a00e0;
  --accent-blue: #00d2ff;
  --accent-blue-light: #0066ff;
  
  --status-pending-bg: rgba(255, 193, 7, 0.1);
  --status-pending-color: #ffc107;
  --status-approved-bg: rgba(40, 167, 69, 0.1);
  --status-approved-color: #28a745;
  --status-rejected-bg: rgba(220, 53, 69, 0.1);
  --status-rejected-color: #dc3545;
  
  --font-main: 'Outfit', sans-serif;
  
  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --border-radius-sm: 8px;
  --border-radius-md: 14px;
  --border-radius-lg: 20px;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(142, 45, 226, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(0, 210, 255, 0.05) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-purple);
}

/* Common UI Elements */
a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: all 0.3s ease;
}
a:hover {
  color: var(--accent-purple);
  text-shadow: 0 0 8px rgba(142, 45, 226, 0.5);
}

button {
  cursor: pointer;
  font-family: var(--font-main);
  border: none;
  outline: none;
  transition: all 0.3s ease;
}

input, select, textarea {
  font-family: var(--font-main);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  outline: none;
  transition: all 0.3s ease;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 10px rgba(142, 45, 226, 0.2);
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 24px;
  box-shadow: var(--shadow-glow);
}

/* Auth Pages */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-header h1 {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-blue) 70%, var(--accent-purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-purple-light) 100%);
  color: #fff;
  font-weight: 600;
  padding: 14px;
  border-radius: var(--border-radius-sm);
  display: block;
  text-align: center;
  box-shadow: 0 4px 15px rgba(142, 45, 226, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(142, 45, 226, 0.6);
}

.btn-primary:active {
  transform: translateY(0);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Dashboard Layout */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo h2 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-blue) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-menu {
  list-style: none;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-weight: 500;
  border-radius: var(--border-radius-sm);
  transition: all 0.3s ease;
}

.sidebar-item a:hover,
.sidebar-item.active a {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-item.active a {
  border-left: 3px solid var(--accent-purple);
  background: rgba(142, 45, 226, 0.1);
}

.sidebar-user {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.2);
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.user-name {
  font-weight: 600;
  font-size: 1rem;
}

.user-role {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: rgba(220, 53, 69, 0.1);
  color: var(--status-rejected-color);
  border: 1px solid rgba(220, 53, 69, 0.2);
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-logout:hover {
  background: rgba(220, 53, 69, 0.25);
  color: #fff;
}

/* Main Content Area */
.main-content {
  margin-left: 260px;
  flex-grow: 1;
  padding: 40px;
  min-height: 100vh;
}

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

.page-title h1 {
  font-size: 2rem;
  font-weight: 700;
}

.page-title p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* Stat Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-purple);
}

.stat-card.blue::after {
  background: var(--accent-blue);
}

.stat-card.green::after {
  background: var(--status-approved-color);
}

.stat-card.yellow::after {
  background: var(--status-pending-color);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

/* Grid Layout for Panels */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 2fr 3fr;
  }
}

.panel-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.panel-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

th, td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-color);
  border: 1px solid rgba(255, 193, 7, 0.2);
}

.badge-approved {
  background: var(--status-approved-bg);
  color: var(--status-approved-color);
  border: 1px solid rgba(40, 167, 69, 0.2);
}

.badge-rejected {
  background: var(--status-rejected-bg);
  color: var(--status-rejected-color);
  border: 1px solid rgba(220, 53, 69, 0.2);
}

/* Form layouts */
.btn-submit {
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-blue) 100%);
  color: #fff;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 210, 255, 0.2);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 210, 255, 0.4);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 640px) {
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Admin Actions Buttons */
.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-action {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
}

.btn-action-acc {
  background: rgba(40, 167, 69, 0.15);
  color: var(--status-approved-color);
  border-color: rgba(40, 167, 69, 0.3);
}

.btn-action-acc:hover {
  background: var(--status-approved-color);
  color: #fff;
}

.btn-action-reject {
  background: rgba(220, 53, 69, 0.15);
  color: var(--status-rejected-color);
  border-color: rgba(220, 53, 69, 0.3);
}

.btn-action-reject:hover {
  background: var(--status-rejected-color);
  color: #fff;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background: rgba(5, 5, 8, 0.8);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-glow);
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.btn-close-modal {
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close-modal:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(0,0,0,0.1);
}

.btn-cancel {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 20px;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
}

.btn-cancel:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
  width: 100%;
}

.toast {
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent-blue);
  border-right: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  color: var(--text-primary);
  box-shadow: var(--shadow-glow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.toast-error {
  border-left-color: var(--status-rejected-color);
}

.toast.toast-success {
  border-left-color: var(--status-approved-color);
}

.toast-close {
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

/* Hide sections for SPA */
.dashboard-section {
  display: none;
}

.dashboard-section.active-section {
  display: block;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

/* ====================================================
   MOBILE RESPONSIVENESS — FULL OVERHAUL
   ==================================================== */

/* Sidebar Overlay (backdrop) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  animation: fadeIn 0.2s ease;
}

.sidebar-overlay.active {
  display: block;
}

/* Hamburger always visible on mobile */
.hamburger {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---- Breakpoint: Tablet & Mobile (max 1024px) ---- */
@media (max-width: 1024px) {
  .main-content {
    padding: 24px 20px;
  }
}

/* ---- Breakpoint: Mobile (max 768px) ---- */
@media (max-width: 768px) {

  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
    width: 260px;
  }

  .sidebar.active {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

  /* Main content full width */
  .main-content {
    margin-left: 0;
    padding: 16px 14px;
  }

  /* Header bar */
  .header-bar {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    margin-bottom: 20px;
  }

  .hamburger {
    display: flex;
  }

  .page-title h1 {
    font-size: 1.3rem;
  }

  .page-title p {
    font-size: 0.8rem;
  }

  /* Balance in header — compact */
  .header-balance {
    font-size: 0.9rem !important;
    flex-shrink: 0;
  }

  /* Stats grid — 2 columns on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
  }

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

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

  .stat-card {
    padding: 16px;
  }

  /* Cards */
  .card {
    padding: 16px;
  }

  /* Panel header — wrap on small screens */
  .panel-header {
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
  }

  .panel-header > div {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Tables — mobile card style */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius-sm);
  }

  /* Make table text smaller on mobile */
  table {
    font-size: 0.82rem;
    min-width: 500px;
  }

  th, td {
    padding: 10px 12px;
  }

  /* Admin table — allow horizontal scroll */
  #adminSubmissionTableBody tr td,
  #adminUsersTableBody tr td,
  #adminWithdrawalTableBody tr td {
    white-space: nowrap;
  }

  /* Form row always single column on mobile */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Dashboard grid always single column */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Button touch targets */
  .btn-submit,
  .btn-action,
  .btn-logout {
    min-height: 40px;
  }

  .btn-action {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  /* Toast — full width at bottom */
  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
    max-width: 100%;
  }

  /* Modal */
  .modal {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .modal-footer button {
    width: 100%;
    justify-content: center;
  }

  /* Auth pages */
  .auth-header h1 {
    font-size: 1.8rem;
  }

  /* Tab buttons wrap */
  .tab-buttons {
    flex-wrap: wrap !important;
  }

  /* Admin action buttons in user table */
  #adminUsersTableBody .btn-action,
  #adminSubmissionTableBody .btn-action,
  #adminWithdrawalTableBody .btn-action {
    padding: 5px 8px;
    font-size: 0.75rem;
  }

  /* Bulk action card buttons */
  #btnBulkApprove, #btnBulkReject {
    flex: unset;
    width: 100%;
  }

  /* Select filters wrap */
  #submissionFilter,
  #withdrawalFilter {
    width: 100%;
  }
}

/* ---- Breakpoint: Very Small (max 480px) ---- */
@media (max-width: 480px) {
  .main-content {
    padding: 12px 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card {
    padding: 12px 10px;
  }

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

  .page-title h1 {
    font-size: 1.1rem;
  }

  .card {
    padding: 14px;
  }

  .auth-header h1 {
    font-size: 1.6rem;
  }

  /* Stack panel-header buttons vertically */
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-header > div {
    width: 100%;
    justify-content: flex-start;
  }

  /* Toast smaller */
  .toast {
    font-size: 0.85rem;
    padding: 12px;
  }
}


