/* ============================================================
   GM (Gestion Mandat) — Premium Design System
   Inspired by Apex Dashboard | Light Theme - High Contrast
   No build tools required.
   ============================================================ */

:root {
  /* Colors - Modern Apex Palette */
  --bg-page: #f1f5f9;
  /* Slate 100 (Slightly deeper for card contrast) */
  --bg-card: #ffffff;
  --bg-sidebar: #1c1c21;
  /* Apex-style neutral dark */
  --bg-topbar: rgba(255, 255, 255, 0.7);

  --text-main: #1e293b;
  /* Slate 800 */
  --text-muted: #64748b;
  /* Slate 500 */
  --text-faint: #94a3b8;
  /* Slate 400 */
  --text-on-dark: #ffffff;
  --text-on-dark-muted: rgba(255, 255, 255, 0.45);

  --primary: #2563eb;
  /* Adaptive to Logo */
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;

  --border: #e2e8f0;
  /* Slate 200 */
  --border-light: rgba(226, 232, 240, 0.4);

  /* Multi-layered Soft Shadows (Apex Style) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 24px;

  --sidebar-width: 280px;
  --sidebar-collapsed-width: 88px;
  --topbar-height: 72px;
}

/* Typography & Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
  transition: all 0.2s ease;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  transition: all 0.2s ease;
}

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

/* Sidebar - Professional & Collapsible */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 100;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  padding: 24px 16px;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar:hover {
  scrollbar-width: thin;
}

.sidebar:hover::-webkit-scrollbar {
  display: block;
  width: 4px;
}

.sidebar:hover::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* Mapping Laravel/Jetstream component classes to our premium buttons */
button.inline-flex.items-center.bg-gray-800,
button.inline-flex.items-center.px-4.py-2.bg-gray-800,
.x-primary-button {
  background-color: var(--primary) !important;
  color: white !important;
  padding: 10px 20px !important;
  border-radius: var(--radius-md) !important;
  font-weight: 600 !important;
  border: none !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2) !important;
  text-transform: none !important;
  font-size: 14px !important;
}

button.inline-flex.items-center.bg-white.border-gray-300,
button.inline-flex.items-center.px-4.py-2.bg-white.border-gray-300,
.x-secondary-button {
  background-color: white !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border) !important;
  padding: 10px 20px !important;
  border-radius: var(--radius-md) !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  text-transform: none !important;
  font-size: 14px !important;
}

button.inline-flex.items-center.bg-red-600,
button.inline-flex.items-center.px-4.py-2.bg-red-600,
.x-danger-button {
  background-color: var(--danger) !important;
  color: white !important;
  padding: 10px 20px !important;
  border-radius: var(--radius-md) !important;
  font-weight: 600 !important;
  border: none !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  text-transform: none !important;
  font-size: 14px !important;
}

/* Fallback for cases where @apply isn't processed or classes are used in plain CSS */
.profile-btn-primary {
  background: var(--primary);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.profile-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 10px -1px rgba(37, 99, 235, 0.3);
}

.profile-btn-danger {
  background: var(--danger);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.profile-btn-danger:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Sidebar Logo - Refined */
.sidebar-header {
  margin-bottom: 24px;
  padding: 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  padding: 10px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  width: auto;
  min-width: 100px;
  max-width: 160px;
  height: auto;
  min-height: 56px;
  margin-bottom: 16px;
}

.logo-img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 44px;
  object-fit: contain;
}

.sidebar-logo-text {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: white;
  white-space: nowrap;
  transition: opacity 0.2s ease;
  line-height: 1;
}

.sidebar-logo-text span {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

/* Toggle Button */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  position: absolute;
  top: -12px;
  right: -8px;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Sidebar Collapse Utilities */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  padding: 24px 8px;
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .sidebar-user,
.sidebar.collapsed .sidebar-footer-text,
.sidebar.collapsed .logo-text-full {
  display: none !important;
}

.sidebar.collapsed .sidebar-header {
  margin-bottom: 16px;
  padding: 8px 0;
  justify-content: center;
}

.sidebar.collapsed .logo-container {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px !important;
  min-height: 48px !important;
  padding: 8px !important;
  border-radius: var(--radius-md) !important;
  margin-bottom: 0 !important;
}

.sidebar.collapsed .logo-img {
  max-height: 32px !important;
  max-width: 32px !important;
}

.sidebar.collapsed .sidebar-toggle {
  position: absolute;
  right: -16px;
  top: 12px;
  background: var(--primary);
  border: 2px solid var(--bg-sidebar);
  border-radius: 50%;
  opacity: 0;
}

.sidebar:hover .sidebar-toggle {
  opacity: 1;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 12px 0;
}

.sidebar.collapsed .nav-icon {
  margin-right: 0;
}

.sidebar.collapsed .sidebar-footer {
  padding: 12px 0;
  align-items: center;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 8px;
}

.nav-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-on-dark-muted);
  margin: 16px 12px 10px;
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  transform: translateX(4px);
}

.nav-link.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.nav-icon {
  width: 22px;
  height: 22px;
  opacity: 0.85;
  flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 14px;
}

.sidebar-user-meta {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.btn-logout {
  width: 100%;
  padding: 8px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  color: #fda4af;
  border: 1px solid rgba(253, 164, 175, 0.2);
}

.btn-logout:hover {
  background: rgba(253, 164, 175, 0.1);
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.sidebar-is-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* Topbar Refined (Apex Style) */
.topbar {
  height: var(--topbar-height);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-topbar);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.topbar-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.topbar-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.search-container {
  display: flex;
  align-items: center;
  background: white;
  border-radius: var(--radius-md);
  padding: 0 16px;
  width: 100%;
  max-width: 600px;
  height: 40px;
  /* Reduced from 44px */
  border: 1px solid var(--border);
  /* Visible border by default for better definition */
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.search-container:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  /* Subtle ring instead of heavy shadow */
  /* max-width expansion removed as requested (jittery) */
}

.search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-right: 12px;
}

/* Global Search Results Dropdown */
.search-results-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  /* Shown via JS */
  padding: 8px;
  animation: dropdownFadeIn 0.2s ease;
}

.search-results-dropdown.show {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  cursor: pointer;
  text-decoration: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-page);
}

.search-result-icon {
  width: 36px;
  height: 36px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
  display: block;
}

.search-result-subtitle {
  font-size: 12px;
  color: var(--text-faint);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-type {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-faint);
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.search-no-results {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.search-loading {
  padding: 16px;
  display: flex;
  justify-content: center;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.search-input {
  border: none;
  background: transparent;
  padding: 0;
  font-size: 15px;
  width: 100%;
  height: 100%;
  color: var(--text-main);
  outline: none;
}

.search-input::placeholder {
  color: var(--text-faint);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  border-radius: 14px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.topbar-user:hover {
  background: var(--bg-page);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Page Content - Improved Margins */
.page-content {
  padding: 40px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
}

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

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.stat-card {
  background: var(--bg-card);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-light);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  flex-shrink: 0;
}

.stat-icon-success {
  background: #ecfdf5;
  color: #10b981;
}

.stat-icon-warning {
  background: #fffbeb;
  color: #f59e0b;
}

.stat-icon-purple {
  background: #f3e8ff;
  color: #9333ea;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-card .card-subtitle {
  margin-top: 0;
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.1), 0 2px 4px -1px rgba(37, 99, 235, 0.06);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.2);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: var(--bg-page);
  border-color: var(--text-faint);
}

.btn-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.1);
}

.btn-danger:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(239, 68, 68, 0.2);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.1);
}

.btn-success:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.2);
}

/* User Dropdown */
.user-dropdown {
  position: relative;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
  background: white;
  box-shadow: var(--shadow-sm);
}

.user-trigger:hover {
  background: var(--bg-page);
  box-shadow: var(--shadow-md);
}

.user-avatar {
  width: 38px;
  height: 38px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  padding: 8px;
  display: none;
  z-index: 1000;
  animation: dropdownFadeIn 0.2s ease;
}

.dropdown-menu.show {
  display: block;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  transition: all 0.2s;
}

.dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* Notification Badge */
.notification-container {
  position: relative;
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  transition: background 0.2s;
}

.notification-container:hover {
  background: var(--primary-light);
}

.notification-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* Tables - Professional & Clean */
.table-wrapper {
  overflow-x: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

th {
  text-align: left;
  padding: 14px 24px;
  background: #fcfdfe;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-main);
  vertical-align: middle;
}

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

tr:hover td {
  background: var(--primary-light);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green {
  background: #ecfdf5;
  color: #065f46;
}

.badge-yellow {
  background: #fffbeb;
  color: #92400e;
}

.badge-red {
  background: #fef2f2;
  color: #991b1b;
}

.badge-blue {
  background: #eff6ff;
  color: #1e40af;
}

/* Empty State - Scaled Down Icons */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 120px 24px;
  text-align: center;
}

.empty-icon {
  width: 44px;
  height: 44px;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.empty-text {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 280px;
}

/* Form Controls */
.form-group {
  margin-bottom: 24px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 14px;
  transition: all 0.2s ease;
  background: white;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* Auth Pages */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, #1e293b, #0f172a);
  padding: 24px;
}

.auth-card {
  background: white;
  width: 100%;
  max-width: 400px;
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
}

.auth-logo-center {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 95;
}

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

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

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

  .main-content,
  .sidebar-is-collapsed .main-content {
    margin-left: 0 !important;
  }

  .topbar {
    padding: 0 20px;
  }

  .page-content {
    padding: 24px;
  }

  .desktop-only {
    display: none !important;
  }
}

/* Custom Global Modal JS */
.custom-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.custom-modal-overlay.show {
  display: flex;
  opacity: 1;
}

.custom-modal-content {
  background: white;
  width: 100%;
  max-width: 400px;
  margin: 0 20px;
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(10px);
  transition: all 0.2s ease;
}

.custom-modal-overlay.show .custom-modal-content {
  transform: scale(1) translateY(0);
}

.modal-icon-warning {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fef2f2;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.modal-icon-warning svg {
  width: 28px;
  height: 28px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.modal-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-actions .btn {
  flex: 1;
}

/* Icon Buttons in Tables */
.btn-icon-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg-page);
  color: var(--text-main);
}

.btn-icon.text-primary:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-icon.text-danger:hover {
  background: #fef2f2;
  color: var(--danger);
}

.btn-icon.text-warning:hover {
  background: #fffbeb;
  color: var(--warning);
}

.btn-icon.text-success:hover {
  background: #ecfdf5;
  color: var(--success);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  position: relative;
  pointer-events: auto;
  min-width: 300px;
  max-width: 400px;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: flex-start;
  padding: 16px;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  transform: translateX(120%);
  animation: slideInToast 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInToast {
  from {
    transform: translateX(120%);
  }

  to {
    transform: translateX(0);
  }
}

.toast.toast-hiding {
  animation: slideOutToast 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideOutToast {
  from {
    transform: translateX(0);
    opacity: 1;
  }

  to {
    transform: translateX(120%);
    opacity: 0;
  }
}



.toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error .toast-icon {
  color: var(--danger);
}

.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-info .toast-icon {
  color: var(--primary);
}

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

.toast-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 4px;
  line-height: 1.2;
}

.toast-message {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  font-size: 1.2rem;
  border-radius: 4px;
  transition: all 0.2s;
}

.toast-close:hover {
  background: var(--bg-page);
  color: var(--text-main);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.05);
  width: 100%;
}

.toast-progress-bar {
  height: 100%;
  width: 100%;
  background: var(--primary);
  transform-origin: left;
  animation: toastProgress 5s linear forwards;
}

.toast-success .toast-progress-bar {
  background: var(--success);
}

.toast-error .toast-progress-bar {
  background: var(--danger);
}

.toast-warning .toast-progress-bar {
  background: var(--warning);
}

.toast-info .toast-progress-bar {
  background: var(--primary);
}

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

  to {
    transform: scaleX(0);
  }
}

/* Tom Select Apex Theme Overrides */
.ts-wrapper.single .ts-control {
  background-color: white !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  padding: 10px 16px !important;
  font-size: 14px !important;
  color: var(--text-main) !important;
  box-shadow: var(--shadow-sm) !important;
  transition: all 0.2s ease !important;
  display: flex !important;
  align-items: center !important;
  min-height: 42px !important;
}

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

.ts-dropdown {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  margin-top: 8px !important;
  padding: 6px !important;
  background: white !important;
  z-index: 1000 !important;
  overflow: hidden !important;
  animation: tsDropdownFadeIn 0.2s ease-out !important;
}

@keyframes tsDropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ts-dropdown .option {
  padding: 12px 14px !important;
  border-radius: var(--radius-md) !important;
  font-size: 14px !important;
  margin: 2px 0 !important;
  transition: background 0.2s ease, color 0.1s ease !important;
}

.ts-dropdown .active {
  background-color: var(--primary-light) !important;
  color: var(--primary) !important;
}

.ts-dropdown .selected {
  background-color: var(--primary-light) !important;
  color: var(--primary) !important;
  font-weight: 600 !important;
}

.ts-wrapper .ts-control input::placeholder {
  color: var(--text-faint) !important;
}


/* Show Mandate Refined Styles */
.mandate-header-hero {
  background: white;
  padding: 30px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}

.stats-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.stat-box {
  padding: 16px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.stat-box:hover {
  border-color: var(--text-faint);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/*.stat-box-accent {
    border-left: 3px solid var(--primary);
}*/

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 800;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}


/* Empty State Adjustments */
.empty-state svg {
  width: 48px !important;
  height: 48px !important;
  margin-bottom: 12px !important;
  opacity: 0.4;
}

.empty-state p {
  font-size: 0.85rem;
  color: var(--text-faint);
}

/* Collapsible Action Form -> Turned into Modal Overlay */
.action-form-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(6px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.action-form-overlay.show {
  display: flex;
  opacity: 1;
}

.action-form-card {
  background: white;
  width: 100%;
  max-width: 650px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2xl);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  overflow: hidden;
}

.action-form-overlay.show .action-form-card {
  transform: translateY(0);
}

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

.action-modal-body {
  padding: 24px;
}

.btn-close-modal {
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  transition: all 0.2s;
}

.btn-close-modal:hover {
  background: #fee2e2;
  color: var(--danger);
}

.btn-create-action {
  margin-top: 20px;
  width: 100%;
  justify-content: center;
}

/* Warning & Rejection Styles */
.btn-warning {
  background: var(--warning);
  color: white;
  box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.1);
}

.btn-warning:hover {
  background: #d97706;
  /* Slightly darker orange */
  transform: translateY(-1px);
  box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.2);
}

.text-warning {
  color: var(--warning) !important;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
  background: transparent;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.05);
}

.btn-icon.text-danger:hover {
  background: #fee2e2;
}

.btn-icon.text-warning:hover {
  background: #fef3c7;
}

/* Spinner for Global Search */
.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(37, 99, 235, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinnerRotate 0.6s linear infinite;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spinnerRotate {
  to {
    transform: rotate(360deg);
  }
}