/* =====================================================
   JSKAds Design System — Premium Agency Dashboard
   ===================================================== */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;700;900&family=Inter:wght@400;500;600;700&display=swap');

/* --- CSS Custom Properties --- */
:root {
  /* Brand Colors */
  --primary: #E11D48;
  --primary-light: #FF4B72;
  --primary-dark: #BE123C;
  --primary-rgb: 225, 29, 72;
  --primary-glow: rgba(225, 29, 72, 0.4);

  /* Light Surfaces */
  --bg-body: #F3F4F6;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F9FAFB;
  --bg-input: #FFFFFF;
  --bg-table-stripe: #F9FAFB;

  /* Sidebar Surfaces */
  --sidebar-bg: #FFFFFF;
  --sidebar-hover: #F3F4F6;
  --sidebar-active: rgba(225, 29, 72, 0.08);
  --sidebar-border: #E5E7EB;
  --sidebar-text: #4B5563;
  --sidebar-text-active: #111827;

  /* Text Colors */
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-muted: #6B7280;
  --text-inverse: #FFFFFF;

  /* Borders */
  --border-light: #E5E7EB;
  --border-medium: #D1D5DB;
  --border-focus: var(--primary);

  /* Status Colors */
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --info: #3B82F6;
  --info-bg: rgba(59, 130, 246, 0.1);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Layout */
  --sidebar-width: 270px;
  --sidebar-collapsed: 72px;
  --header-height: 68px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  background: var(--bg-body);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-dark);
}

img {
  max-width: 100%;
  display: block;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
}

@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.animate-fadeInUp { animation: fadeInUp 0.5s ease forwards; }
.animate-fadeIn { animation: fadeIn 0.4s ease forwards; }

/* Stagger children */
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }


/* =====================================================
   LAYOUT SYSTEM
   ===================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition-base), width var(--transition-base);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--sidebar-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed);
}
body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed);
}
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .sidebar-section-title,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-link .badge-count {
  display: none;
}
body.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 24px 0 20px;
}
body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  font-size: 0;
  padding: 10px;
}
body.sidebar-collapsed .sidebar-link svg {
  margin: 0;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
}

.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-brand img {
  height: 40px;
  width: auto;
}

.sidebar-brand-text {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.sidebar-brand-text small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--sidebar-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-text);
  padding: 8px 14px 8px;
  margin-bottom: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 450;
  transition: all var(--transition-fast);
  position: relative;
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--primary-light);
  font-weight: 550;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.sidebar-link svg,
.sidebar-link .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active svg,
.sidebar-link.active .nav-icon {
  opacity: 1;
}

.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--sidebar-hover);
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: var(--sidebar-text);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  min-width: 0; /* Prevents flex item from overflowing screen */
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

/* --- Top Header --- */
.top-header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.top-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: block;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.menu-toggle svg {
  width: 22px;
  height: 22px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb .separator {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.breadcrumb .current {
  color: var(--text-primary);
  font-weight: 600;
}

.top-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.header-btn:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.header-btn svg {
  width: 20px;
  height: 20px;
}

/* --- Page Content --- */
.page-content {
  flex: 1;
  padding: 28px 32px;
  animation: fadeInUp 0.4s ease;
}


/* =====================================================
   COMPONENTS
   ===================================================== */

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 400;
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}


/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 550;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: var(--text-inverse);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #B91C1C;
  border-color: #B91C1C;
  color: var(--text-inverse);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 0.95rem;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
}


/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}


/* --- Stat Cards --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.5s ease forwards;
  opacity: 0;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.red {
  background: #FEE2E2;
  color: var(--primary);
}

.stat-icon.blue {
  background: #DBEAFE;
  color: #2563EB;
}

.stat-icon.green {
  background: #D1FAE5;
  color: #059669;
}

.stat-icon.amber {
  background: #FEF3C7;
  color: #D97706;
}

.stat-icon.purple {
  background: #EDE9FE;
  color: #7C3AED;
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.03em;
  animation: countUp 0.6s ease forwards;
}

.stat-trend {
  font-size: 0.78rem;
  font-weight: 500;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }


/* --- Tables --- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.table-responsive,
.table-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
  -webkit-overflow-scrolling: touch;
  display: block;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead {
  background: var(--bg-input);
  border-bottom: 2px solid var(--border-light);
}

.data-table th {
  padding: 12px 20px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  position: sticky;
  top: 0;
  background: var(--bg-input);
  z-index: 10;
  box-shadow: inset 0 -2px 0 var(--border-light);
}

.data-table td {
  padding: 14px 20px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-table-stripe);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-link {
  color: var(--text-primary);
  font-weight: 550;
  transition: color var(--transition-fast);
}

.table-link:hover {
  color: var(--primary);
}

.table-actions {
  display: flex;
  gap: 6px;
}

.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.table-empty svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  opacity: 0.3;
}

.table-empty p {
  font-size: 0.95rem;
  margin-bottom: 16px;
}


/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.73rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-neutral {
  background: #F1F5F9;
  color: #475569;
}

.badge-primary {
  background: rgba(220, 38, 38, 0.1);
  color: var(--primary);
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}


/* --- Forms --- */
.form-section {
  margin-bottom: 32px;
}

.form-section-title {
  font-size: 1rem;
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-section-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.form-group {
  margin-bottom: 0;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label,
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group label .required {
  color: var(--primary);
  margin-left: 2px;
}

.form-control,
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  padding: 8px 14px;
  height: 38px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:hover,
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):hover,
.form-group select:hover,
.form-group textarea:hover {
  border-color: var(--border-medium);
}

.form-control:focus,
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card);
}

.form-control::placeholder,
.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

select.form-control,
.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394A3B8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 20px;
  padding-right: 40px;
}

textarea.form-control,
.form-group textarea {
  resize: vertical;
  min-height: 100px;
  height: auto;
}

.form-help {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}



/* Checkbox styling */
.form-group input[type="checkbox"] {
  display: inline-block;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check label {
  margin-bottom: 0;
  cursor: pointer;
}


/* --- Formset (Inline) --- */
.formset-container {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 20px;
}

.formset-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-light);
}

.formset-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.formset-rows {
  padding: 16px 20px;
}

.formset-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 16px;
  align-items: end;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border-bottom: none;
  animation: fadeInUp 0.3s ease;
  overflow-x: auto;
}

.formset-row .form-group {
  flex: 1;
  min-width: 150px;
}

.formset-row .form-group:last-child {
  flex: 0 0 auto;
  min-width: auto;
}

.formset-row:last-child {
  border-bottom: none;
}

.formset-row .delete-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 4px;
}

.formset-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: transparent;
  color: var(--primary);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 550;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin: 12px 20px 16px;
}

.formset-add-btn:hover {
  background: rgba(220, 38, 38, 0.05);
}


/* --- Detail View --- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.detail-section {
  margin-bottom: 28px;
}

.detail-section-title {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-section-title svg {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.detail-row {
  display: flex;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  width: 160px;
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 550;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-value {
  flex: 1;
  font-size: 0.92rem;
  color: var(--text-primary);
  font-weight: 450;
}


/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  min-width: 320px;
  max-width: 420px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--info);
  animation: toastIn 0.4s ease;
  pointer-events: auto;
}

.toast.toast-out {
  animation: toastOut 0.3s ease forwards;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-info    { border-left-color: var(--info); }

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast.toast-success .toast-icon { color: var(--success); }
.toast.toast-warning .toast-icon { color: var(--warning); }
.toast.toast-error .toast-icon   { color: var(--danger); }
.toast.toast-info .toast-icon    { color: var(--info); }

.toast-body {
  flex: 1;
}

.toast-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.toast-close:hover {
  background: var(--bg-input);
  color: var(--text-primary);
}

.toast-close svg {
  width: 16px;
  height: 16px;
}


/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
}

.login-hero {
  flex: 1;
  background: linear-gradient(135deg, #0F0F1A 0%, #1A1A2E 40%, #0F3460 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.login-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(220, 38, 38, 0.12) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(220, 38, 38, 0.08) 0%, transparent 40%);
  animation: gradientShift 15s ease infinite;
  background-size: 200% 200%;
}

.login-hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 480px;
}

.login-hero img {
  height: 60px;
  margin: 0 auto 32px;
  filter: brightness(0) invert(1);
}

.login-hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  color: white;
  line-height: 1.2;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}

.login-hero h1 span {
  background: linear-gradient(135deg, var(--primary-light), #F87171);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-hero p {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
}

.login-hero-image {
  margin-top: 40px;
  max-width: 380px;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.login-form-side {
  width: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--bg-card);
}

.login-form-container {
  width: 100%;
  max-width: 380px;
}

.login-form-container h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.login-form-container .login-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form .form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-form .form-group input {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.92rem;
}

.login-form .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
  margin-top: 8px;
}

.login-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 20px;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* Login branding on mobile */
.login-mobile-brand {
  display: none;
  text-align: center;
  margin-bottom: 32px;
}

.login-mobile-brand img {
  height: 40px;
  margin: 0 auto;
}


/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 64px 32px;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  color: var(--text-muted);
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}


/* --- Sidebar Overlay for Mobile --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  backdrop-filter: blur(4px);
}

.sidebar-overlay.active {
  display: block;
  animation: fadeIn 0.2s ease;
}


/* --- Utility Classes --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }


/* =====================================================
   RESPONSIVE DESIGN (Consolidated)
   ===================================================== */

/* --- Tablet (1024px) --- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    box-shadow: var(--shadow-xl);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-base);
  }

  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  .main-content {
    margin-left: 0 !important;
  }

  body.sidebar-collapsed .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .page-content {
    padding: 20px;
  }

  .top-header {
    padding: 0 20px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Mobile (768px) --- */
@media (max-width: 768px) {
  /* Login */
  .login-page {
    flex-direction: column;
  }

  .login-hero {
    display: none;
  }

  .login-form-side {
    width: 100%;
    min-height: 100vh;
    padding: 32px 24px;
  }

  .login-mobile-brand {
    display: block;
  }

  /* Page Layout */
  .page-content {
    padding: 16px;
  }

  .top-header {
    padding: 0 16px;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-actions .btn {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }

  /* Grids */
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .detail-grid,
  .stats-grid,
  .gst-grid {
    grid-template-columns: 1fr !important;
  }

  /* Detail View */
  .detail-row {
    flex-direction: column;
    gap: 4px;
  }

  .detail-label {
    width: 100%;
  }

  /* Tables */
  .data-table {
    font-size: 0.82rem;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
  }

  .table-container {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .table-responsive,
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    display: block;
  }

  /* Formsets */
  .formset-row {
    flex-direction: column;
    align-items: stretch;
    background: rgba(255, 255, 255, 0.02);
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
  }

  .formset-row .form-group {
    min-width: 100%;
  }

  /* Card Headers */
  .card-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .card-header .card-actions {
    width: 100%;
    justify-content: flex-start !important;
  }

  /* Filter Forms (inline style overrides) */
  form[style*="display: flex"] > div[style*="width:"],
  form[style*="display: flex"] > div[style*="flex:"] {
    flex: 1 1 calc(50% - 15px) !important;
    min-width: 140px !important;
    width: auto !important;
  }

  form[style*="display: flex"] > div:last-child {
    flex: 1 1 100% !important;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }

  /* Order form groups stack */
  .order-form-instance .form-row {
    flex-direction: column;
    gap: 8px;
  }

  /* Mobile hide utility */
  .hide-mobile {
    display: none !important;
  }

  /* Select2 Mobile */
  .select2-container {
    width: 100% !important;
  }

  /* Toast Mobile */
  .toast-container {
    left: 16px;
    right: 16px;
    top: 12px;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }
}

/* --- Small Phone (480px) --- */
@media (max-width: 480px) {
  html {
    font-size: 14px;
  }

  .page-content {
    padding: 12px;
  }

  .card-body {
    padding: 16px;
  }

  .card-header {
    padding: 14px 16px;
  }

  /* Stack filter form fields fully */
  form[style*="display: flex"] > div[style*="width:"],
  form[style*="display: flex"] > div[style*="flex:"] {
    flex: 1 1 100% !important;
    min-width: 100% !important;
  }

  /* Buttons stack */
  .page-actions {
    flex-direction: column;
  }

  .page-actions .btn {
    width: 100%;
  }

  /* Table cells tighter */
  .data-table th,
  .data-table td {
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  /* Stat cards tighter */
  .stat-card {
    padding: 16px;
  }

  .stat-value {
    font-size: 1.5rem;
  }
}

/* --- Font Family Overrides --- */
h1, h2, h3, h4, h5, h6, .page-title, .card-title, .stat-value {
  font-family: 'Outfit', sans-serif;
}

/* --- Ambient BG Animations --- */
@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-50px, 50px) scale(1.1); }
}

.ambient-bg {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.ambient-blob {
  position: absolute;
  filter: blur(120px);
  opacity: 0.5;
  border-radius: 50%;
}

.ambient-blob.red {
  top: -10%; right: -5%;
  width: 50vw; height: 50vw;
  background: radial-gradient(circle, rgba(225,29,72,0.4) 0%, rgba(0,0,0,0) 70%);
  animation: float 20s ease-in-out infinite alternate;
}

.ambient-blob.dark {
  bottom: -20%; left: -10%;
  width: 60vw; height: 60vw;
  background: radial-gradient(circle, rgba(200,200,220,0.4) 0%, rgba(255,255,255,0) 70%);
  animation: float 25s ease-in-out infinite alternate-reverse;
}

/* =====================================================
   Select2 Theme Integration
   ===================================================== */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  background-color: var(--bg-input) !important;
  border: 1.5px solid var(--border-light) !important;
  border-radius: var(--radius-sm) !important;
  min-height: 42px !important;
  color: var(--text-primary) !important;
  display: flex !important;
  align-items: center !important;
  transition: all var(--transition-fast);
}

.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-glow) !important;
  background-color: var(--bg-card) !important;
}

.select2-container--default:hover .select2-selection--single {
  border-color: var(--border-medium) !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text-primary) !important;
  line-height: normal !important;
  padding-left: 14px !important;
  font-size: 0.9rem !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px !important;
  right: 12px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: #94A3B8 transparent transparent transparent !important;
  border-width: 5px 4px 0 4px !important;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent #94A3B8 transparent !important;
  border-width: 0 4px 5px 4px !important;
}

.select2-dropdown {
  background-color: var(--bg-card) !important;
  border: 1.5px solid var(--border-light) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
  color: var(--text-primary) !important;
  z-index: 9999 !important;
  margin-top: 4px !important;
}

.select2-search--dropdown {
  padding: 10px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  background-color: var(--bg-input) !important;
  border: 1.5px solid var(--border-light) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  padding: 8px 12px !important;
  font-size: 0.9rem !important;
  outline: none !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  border-color: var(--primary) !important;
}

.select2-container--default .select2-results__option {
  padding: 10px 14px !important;
  color: var(--text-muted) !important;
  font-size: 0.9rem !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: rgba(0,0,0,0.03) !important;
  color: var(--text-primary) !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--primary) !important;
  color: white !important;
}

/* --- GST Grid --- */
.gst-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* --- Standardized Filter Forms --- */
.filter-form {
  display: flex;
  gap: 15px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filter-group-fluid {
  flex: 1;
  min-width: 200px;
}
.filter-group-fixed {
  width: 150px;
}
.filter-label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  font-size: 0.9em;
}

@media (max-width: 768px) {
  .filter-form .filter-group-fluid,
  .filter-form .filter-group-fixed {
    flex: 1 1 calc(50% - 15px) !important;
    min-width: 140px !important;
    width: auto !important;
  }
  .filter-form > div:last-child {
    flex: 1 1 100% !important;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
  }
}
