@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #6C63FF;
  --primary-dark: #5A52E0;
  --primary-light: #8B85FF;
  --secondary: #FF6584;
  --accent: #43E97B;
  --accent2: #38F9D7;
  --warning: #FFB347;
  --danger: #FF4757;
  --success: #2ED573;
  --info: #1E90FF;

  --bg-dark: #0F0E17;
  --bg-card: #1A1928;
  --bg-card2: #211F35;
  --bg-hover: #2A2845;
  --border: rgba(108, 99, 255, 0.18);
  --border-light: rgba(255, 255, 255, 0.07);
  --text-primary: #F0EFF8;
  --text-secondary: #A8A5C5;
  --text-muted: #6B6885;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(108, 99, 255, 0.3);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --font: 'Inter', sans-serif;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 260px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-card);
}

::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 99px;
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 800;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

h4 {
  font-size: 1rem;
  font-weight: 600;
}

p {
  color: var(--text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(108, 99, 255, 0.5);
}

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: linear-gradient(135deg, #FF4757, #c0392b);
  color: #fff;
}

.btn-danger:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.btn-success {
  background: linear-gradient(135deg, #2ED573, #17a550);
  color: #fff;
}

.btn-success:hover {
  transform: translateY(-2px);
}

.btn-warning {
  background: linear-gradient(135deg, #FFB347, #e07b00);
  color: #fff;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
}

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

/* Form */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
}

.form-control::placeholder {
  color: var(--text-muted);
}

select.form-control {
  cursor: pointer;
}

select.form-control option {
  background: var(--bg-card2);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-primary {
  background: rgba(108, 99, 255, 0.2);
  color: var(--primary-light);
}

.badge-success {
  background: rgba(46, 213, 115, 0.15);
  color: var(--success);
}

.badge-danger {
  background: rgba(255, 71, 87, 0.15);
  color: var(--danger);
}

.badge-warning {
  background: rgba(255, 179, 71, 0.15);
  color: var(--warning);
}

.badge-info {
  background: rgba(30, 144, 255, 0.15);
  color: var(--info);
}

.badge-muted {
  background: rgba(107, 104, 133, 0.2);
  color: var(--text-muted);
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-card2);
  padding: 13px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition);
}

tbody tr:last-child {
  border: none;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody td {
  padding: 13px 16px;
  font-size: 0.88rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 90%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.3s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.4rem;
  transition: var(--transition);
  padding: 4px;
}

.modal-close:hover {
  color: var(--danger);
  transform: rotate(90deg);
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* Alert/Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
}

.toast.success {
  background: linear-gradient(135deg, #2ED573, #17a550);
  color: #fff;
}

.toast.error {
  background: linear-gradient(135deg, #FF4757, #c0392b);
  color: #fff;
}

.toast.info {
  background: linear-gradient(135deg, #1E90FF, #0066cc);
  color: #fff;
}

.toast.warning {
  background: linear-gradient(135deg, #FFB347, #e07b00);
  color: #fff;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--grad);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.stat-icon {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--icon-bg);
  flex-shrink: 0;
}

.stat-info .stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Page layout */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  flex: 1;
  max-width: 340px;
}

.search-bar input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  width: 100%;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Section header */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-dot {
  width: 4px;
  height: 24px;
  border-radius: 99px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

/* Utility */
.text-primary {
  color: var(--primary) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-center {
  text-align: center;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.items-center {
  align-items: center;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

.fw-bold {
  font-weight: 700;
}

.fs-sm {
  font-size: 0.82rem;
}

/* Responsive & Mobile Optimization */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .form-control,
  select.form-control,
  textarea.form-control,
  input.form-control {
    font-size: 16px !important;
    /* Prevents iOS auto zoom on focus */
  }

  .btn {
    min-height: 42px;
    padding: 10px 16px;
  }

  .table-wrapper {
    -webkit-overflow-scrolling: touch;
  }

  .toast-container,
  #toastWrap {
    top: 12px !important;
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
  }

  .toast {
    max-width: 100% !important;
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .modal {
    padding: 20px 14px;
    width: 95%;
    margin: 10px;
    border-radius: var(--radius-md);
  }

  .btn-lg {
    padding: 12px 20px;
    font-size: 0.95rem;
  }
}