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

:root {
  --sidebar-w: 260px;
  --brand-primary: #ed1c24;
  --brand-navy: #052d42;
  --brand-gradient: linear-gradient(135deg, #ed1c24 0%, #c81017 100%);
  --sidebar-bg: #052d42;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text: #94a3b8;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: linear-gradient(90deg, rgba(237, 28, 36, 0.22) 0%, rgba(237, 28, 36, 0.06) 100%);
  
  --bg-app: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --text-main: #1e293b;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

body {
  background-color: var(--bg-app);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  margin: 0;
  letter-spacing: -0.01em;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

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

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar .brand {
  padding: 1rem 1.15rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.app-sidebar .brand img {
  max-width: 100%;
  transition: transform 0.2s ease;
}

.app-sidebar .nav-list {
  padding: 1rem 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.app-sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 0.92rem;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}

.app-sidebar .nav-link i {
  font-size: 1.15rem;
  margin-right: 0.75rem;
  color: #64748b;
  transition: color 0.15s;
}

.app-sidebar .nav-link:hover {
  color: #f1f5f9;
  background-color: var(--sidebar-hover);
}

.app-sidebar .nav-link:hover i {
  color: #93c5fd;
}

.app-sidebar .nav-link.active {
  color: #ffffff;
  background: var(--sidebar-active-bg);
  border-left: 3px solid #ed1c24;
  font-weight: 600;
}

.app-sidebar .nav-link.active i {
  color: #ed1c24;
}

.app-sidebar .sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}

/* Main Area */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.app-navbar {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-navbar .page-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.user-pill {
  background: #f1f5f9;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Cards & UI Elements */
.card {
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--card-border) !important;
  box-shadow: var(--card-shadow) !important;
  background: var(--card-bg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-header {
  background: #ffffff !important;
  border-bottom: 1px solid var(--card-border) !important;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.98rem;
  color: #1e293b;
}

.card-body {
  padding: 1.25rem;
}

/* Stat Cards */
.card.stat-card {
  border: 1px solid var(--card-border) !important;
  border-radius: var(--radius-md) !important;
  margin-bottom: 0;
  overflow: hidden;
}

.card.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover) !important;
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  flex-shrink: 0;
}

/* Enhanced Form controls */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
  transition: all 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Custom Modern Toggle Switch */
.form-check-input[role="switch"] {
  height: 1.55rem;
  width: 3rem;
  cursor: pointer;
  border-color: #cbd5e1;
  background-color: #e2e8f0;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.form-check-input[role="switch"]:checked {
  background-color: #10b981;
  border-color: #10b981;
}

.form-check-input[role="switch"]:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.form-switch .form-check-label {
  padding-left: 0.5rem;
  line-height: 1.55rem;
  user-select: none;
  cursor: pointer;
}

/* Tables */
.table {
  color: #334155;
  font-size: 0.92rem;
}

.table thead th {
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--card-border);
}

.table tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.table-hover tbody tr:hover {
  background-color: #f8fafc;
}

/* Badges */
.badge {
  padding: 0.35em 0.65em;
  font-weight: 600;
  border-radius: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

/* Buttons */
.btn {
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.95rem;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.15s ease-in-out;
}

.btn-primary {
  background: var(--brand-gradient);
  border: none;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
  transform: translateY(-1px);
}

/* Modern Action Icon Buttons */
.btn-action {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
}

.btn-action:hover {
  transform: translateY(-2px);
}

.btn-action-view {
  color: #0284c7;
  background-color: #f0f9ff;
  border-color: #bae6fd;
}
.btn-action-view:hover {
  color: #ffffff;
  background-color: #0284c7;
  border-color: #0284c7;
  box-shadow: 0 4px 6px -1px rgba(2, 132, 199, 0.25);
}

.btn-action-edit {
  color: #4f46e5;
  background-color: #eef2ff;
  border-color: #c7d2fe;
}
.btn-action-edit:hover {
  color: #ffffff;
  background-color: #4f46e5;
  border-color: #4f46e5;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.25);
}

.btn-action-delete {
  color: #e11d48;
  background-color: #fff1f2;
  border-color: #fecdd3;
}
.btn-action-delete:hover {
  color: #ffffff;
  background-color: #e11d48;
  border-color: #e11d48;
  box-shadow: 0 4px 6px -1px rgba(225, 29, 72, 0.25);
}

.btn-action-whatsapp {
  color: #15803d;
  background-color: #f0fdf4;
  border-color: #bbf7d0;
}
.btn-action-whatsapp:hover {
  color: #ffffff;
  background-color: #16a34a;
  border-color: #16a34a;
  box-shadow: 0 4px 6px -1px rgba(22, 163, 74, 0.3);
}

.btn-whatsapp-sm {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: #25d366;
  color: #ffffff;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}
.btn-whatsapp-sm:hover {
  background-color: #1ea952;
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-whatsapp {
  background-color: #25d366 !important;
  color: #ffffff !important;
  border: none;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(37, 211, 102, 0.25);
}
.btn-whatsapp:hover {
  background-color: #1ea952 !important;
  color: #ffffff !important;
  box-shadow: 0 4px 8px rgba(37, 211, 102, 0.35);
  transform: translateY(-1px);
}

/* Login Page UI */
.login-body {
  background: radial-gradient(circle at top left, #1e293b, #0f172a);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  overflow: hidden;
}

.login-icon-box {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem auto;
}

/* Mobile Sidebar */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
}

/* Select2 Bootstrap 5 Theme Full-Width & Clean Styling */
.select2-container {
  width: 100% !important;
}

.select2-container--bootstrap-5 .select2-selection {
  min-height: 40px !important;
  padding: 0.45rem 0.85rem !important;
  font-size: 0.92rem !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: var(--radius-sm) !important;
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15) !important;
}

.select2-container--bootstrap-5 .select2-dropdown {
  border-color: #cbd5e1 !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05) !important;
  z-index: 99999 !important;
}

.select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
  border-radius: 6px !important;
  border: 1px solid #cbd5e1 !important;
  padding: 0.45rem 0.75rem !important;
  font-size: 0.9rem !important;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
  background-color: #eff6ff !important;
  color: #1d4ed8 !important;
  font-weight: 500;
}

/* ========================================================
   TABLE SORTING & RESPONSIVE MOBILE CARDS (PROJECT-WIDE)
   ======================================================== */

/* Desktop Table Sort Headers */
th.sortable-header {
  cursor: pointer !important;
  user-select: none !important;
  white-space: nowrap !important;
  transition: background-color 0.15s ease, color 0.15s ease;
  position: relative;
}

th.sortable-header:hover {
  background-color: #f1f5f9 !important;
  color: #2563eb !important;
}

th.sortable-header .sort-icon {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.8rem;
  vertical-align: middle;
  color: #94a3b8;
  transition: transform 0.15s ease, color 0.15s ease;
}

th.sortable-header.sorted-asc .sort-icon,
th.sortable-header.sorted-desc .sort-icon {
  color: #2563eb !important;
  font-weight: bold;
}

/* Mobile Card View (< 768px): Hide table & show attractive cards */
@media (max-width: 767.98px) {
  /* Hide standard table container styling */
  main .card.card-has-table,
  main .card:has(> .table-responsive:not(.no-mobile-card)),
  main .card:has(> form > .table-responsive:not(.no-mobile-card)) {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  main .table-responsive:not(.no-mobile-card) {
    border: none !important;
    background: transparent !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  main .table-responsive:not(.no-mobile-card) > table.table {
    display: block !important;
    width: 100% !important;
    background: transparent !important;
    border: none !important;
    margin-bottom: 0 !important;
  }

  /* Completely hide table thead on mobile */
  main .table-responsive:not(.no-mobile-card) > table.table thead {
    display: none !important;
  }

  /* Table Body as Card Grid / Stack */
  main .table-responsive:not(.no-mobile-card) > table.table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.85rem !important;
    width: 100% !important;
  }

  /* Each Row TR rendered as an Attractive Floating Card */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr {
    display: block !important;
    background: #ffffff !important;
    border-radius: 14px !important;
    border: 1px solid #e2e8f0 !important;
    padding: 0.9rem 1.1rem !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05) !important;
    width: 100% !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    position: relative;
  }

  main .table-responsive:not(.no-mobile-card) > table.table tbody tr:hover,
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr:active {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.09) !important;
  }

  /* Each cell TD inside the Card */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    text-align: right !important;
    padding: 0.45rem 0 !important;
    border: none !important;
    border-bottom: 1px dashed #f1f5f9 !important;
    font-size: 0.88rem !important;
    width: 100% !important;
    background: transparent !important;
  }

  /* Top ID / header cell inside the Card */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td:first-child {
    font-weight: 700 !important;
    padding-bottom: 0.55rem !important;
    margin-bottom: 0.25rem !important;
    border-bottom: 1.5px solid #f1f5f9 !important;
  }

  /* Label on Left from data-label */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td::before {
    content: attr(data-label);
    font-weight: 600 !important;
    font-size: 0.72rem !important;
    color: #64748b !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    text-align: left !important;
    margin-right: 0.75rem !important;
    flex-shrink: 0 !important;
  }

  /* If TD has no label or shouldn't have label */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td:empty::before,
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td[data-label=""]::before,
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td.mobile-actions-td::before,
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td:last-child::before {
    display: none !important;
  }

  /* Actions TD (Bottom of Card) */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td.mobile-actions-td,
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td:last-child {
    border-bottom: none !important;
    margin-top: 0.5rem !important;
    padding-top: 0.75rem !important;
    border-top: 1px solid #f1f5f9 !important;
    justify-content: flex-end !important;
    gap: 0.5rem !important;
  }

  /* Action buttons inside mobile card */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td:last-child .btn,
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td:last-child .btn-action {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.85rem !important;
  }

  /* Empty State Cell */
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td[colspan],
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td.mobile-empty-td {
    display: block !important;
    text-align: center !important;
    padding: 2.5rem 1rem !important;
    border: none !important;
  }

  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td[colspan]::before,
  main .table-responsive:not(.no-mobile-card) > table.table tbody tr td.mobile-empty-td::before {
    display: none !important;
  }

  /* Mobile Sort Bar */
  .mobile-table-sort {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0.6rem 0.9rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  }

  .mobile-table-sort select {
    font-size: 0.82rem !important;
    border-color: #cbd5e1 !important;
    border-radius: 8px !important;
  }
}


