/* ===============================
   BRANDKIT COMPONENTS - Buttons, Cards, Alerts, Badges, Forms, Tables
   =============================== */

/* ---------- LAYOUT CARDS ---------- */
.card {
  background: var(--brand-white);
  border-radius: var(--brand-radius-md);
  box-shadow: var(--brand-shadow-sm);
  transition: var(--brand-transition);
  border: 1px solid var(--brand-grey-200);
  /* No padding on card - let card-body handle it */
}

.card-body {
  padding: 1rem;
}

.card:hover {
  box-shadow: var(--brand-shadow-md);
  transform: translateY(-0.125rem);
}

/* Card with built-in padding (no card-body needed) */
.card-padded {
  padding: 1.5rem;
}

/* Minimal card - no padding, no hover effects */
.card-minimal {
  padding: 0;
  box-shadow: none;
  border: none;
}

.card-minimal:hover {
  transform: none;
  box-shadow: none;
}

/* Compact card body */
.card-body-sm {
  padding: 0.75rem;
}

.card-body-xs {
  padding: 0.5rem;
}

.card-highlight {
  background: var(--brand-gradient-yellow-white);
  box-shadow: var(--brand-shadow-md);
  border: none;
}

.card-dark {
  background: var(--brand-gradient-black-grey);
  color: var(--brand-white);
  border: none;
}

/* ---------- SIDEBAR / PANEL ---------- */
.sidebar {
  background: var(--brand-grey-200);
  border-right: 1px solid var(--brand-grey-300);
  padding: 1rem;
}

.sidebar a {
  color: var(--brand-grey-700);
  text-decoration: none;
  display: block;
  padding: 0.6rem 1rem;
  border-radius: var(--brand-radius-sm);
  transition: var(--brand-transition);
  font-weight: var(--brand-font-weight-normal);
}

.sidebar a.active,
.sidebar a:hover {
  background: var(--brand-secondary);
  color: var(--brand-black);
  font-weight: var(--brand-font-weight-bold);
}

.sidebar a:hover {
  transform: translateX(0.25rem);
}

/* Dashboard Sidebar Specific */
.the-sidebar {
  background: var(--brand-white);
  border-right: 1px solid var(--brand-grey-200);
  box-shadow: var(--brand-shadow-sm);
}

.the-sidebar .btn {
  transition: var(--brand-transition);
}

.the-sidebar .btn:hover {
  background: var(--brand-secondary) !important;
  transform: translateX(0.25rem);
  box-shadow: var(--brand-shadow-sm);
}

.the-sidebar .nav-item.active .btn {
  background: var(--brand-yellow) !important;
  font-weight: var(--brand-font-weight-bold);
  border-color: var(--brand-primary);
}

/* ---------- BUTTONS ---------- */
.btn {
  font-weight: var(--brand-font-weight-bold);
  border-radius: var(--brand-radius-md);
  transition: var(--brand-transition);
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border: none;
  font-size: var(--brand-font-size-base);
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

/* CTA (Primary Buttons) */
.btn-primary,
.btn-brand-primary {
  background: var(--brand-primary);
  color: var(--brand-grey-800);
  border: none;
  box-shadow: var(--brand-shadow-sm);
}

.btn-primary:hover,
.btn-brand-primary:hover {
  background: var(--brand-primary-dark);
  box-shadow: var(--brand-shadow-md);
  transform: translateY(-0.125rem);
  color: var(--brand-grey-800);
}

/* Secondary Buttons */
.btn-secondary,
.btn-brand-secondary {
  background: var(--brand-grey-200);
  color: var(--brand-grey-700);
  border: 1px solid var(--brand-grey-300);
}

.btn-secondary:hover,
.btn-brand-secondary:hover {
  background: var(--brand-grey-300);
  transform: translateY(-0.125rem);
}

/* Outline Buttons */
.btn-outline-dark {
  background: transparent;
  color: var(--brand-grey-700);
  border: 1px solid var(--brand-grey-300);
  transition: var(--brand-transition);
}

.btn-outline-dark:hover {
  background: var(--brand-secondary);
  color: var(--brand-grey-800);
  border-color: var(--brand-primary);
}

/* Gradient Buttons */
.btn-gradient {
  background: var(--brand-gradient-yellow-white);
  color: var(--brand-grey-800);
  border: none;
  box-shadow: var(--brand-shadow-md);
}

.btn-gradient:hover {
  box-shadow: var(--brand-shadow-lg);
  transform: translateY(-0.125rem);
}

/* Success Button */
.btn-success,
.btn-brand-success {
  background: #38ef7d;
  color: var(--brand-black);
  border: none;
}

.btn-success:hover,
.btn-brand-success:hover {
  background: #2dd36f;
  transform: translateY(-0.125rem);
}

/* Danger Button */
.btn-danger,
.btn-brand-danger {
  background: #ff6b6b;
  color: var(--brand-white);
  border: none;
}

.btn-danger:hover,
.btn-brand-danger:hover {
  background: #ff5252;
  transform: translateY(-0.125rem);
}

/* ---------- FORMS ---------- */
input, select, textarea {
  background: var(--brand-white);
  border: 1px solid var(--brand-grey-300);
  border-radius: var(--brand-radius-sm);
  padding: 0.5rem 0.8rem;
  transition: var(--brand-transition);
  font-family: var(--brand-font-primary);
  font-size: var(--brand-font-size-base);
  color: var(--brand-grey-700);
}

/* ---------- CHECKBOXES ---------- */
.form-check-input,
input[type="checkbox"].form-check-input {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px !important;
  border: 2px solid var(--brand-grey-400) !important;
  border-radius: 3px !important;
  background-color: var(--brand-white) !important;
  background-image: none !important;
  cursor: pointer;
  transition: var(--brand-transition);
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  padding: 0 !important;
  flex-shrink: 0;
}

.form-check-input:hover,
input[type="checkbox"].form-check-input:hover {
  border-color: var(--brand-primary) !important;
}

.form-check-input:focus,
input[type="checkbox"].form-check-input:focus {
  border-color: var(--brand-primary) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(255, 211, 59, 0.3) !important;
}

.form-check-input:checked,
input[type="checkbox"].form-check-input:checked {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  background-image: none !important;
}

.form-check-input:checked::after,
input[type="checkbox"].form-check-input:checked::after {
  content: '' !important;
  display: block !important;
  width: 5px;
  height: 9px;
  border: solid var(--brand-grey-800);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-bottom: 2px;
}

.form-check-input:indeterminate,
input[type="checkbox"].form-check-input:indeterminate {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  background-image: none !important;
}

.form-check-input:indeterminate::after,
input[type="checkbox"].form-check-input:indeterminate::after {
  content: '' !important;
  display: block !important;
  width: 10px;
  height: 2px;
  background-color: var(--brand-grey-800);
  border: none;
  transform: none;
  margin: 0;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-primary);
  outline: none;
  box-shadow: 0 0 0 0.1875rem rgba(255, 211, 59, 0.3);
}

input::placeholder, textarea::placeholder {
  color: var(--brand-grey-400);
}

label {
  color: var(--brand-grey-700);
  font-weight: var(--brand-font-weight-bold);
  margin-bottom: 0.2rem;
  display: block;
}

/* ---------- TABLES ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: var(--brand-white);
  border-radius: var(--brand-radius-md);
  overflow: hidden;
  box-shadow: var(--brand-shadow-sm);
}

.table th {
  background: var(--brand-grey-200);
  font-weight: var(--brand-font-weight-bold);
  text-align: left;
  padding: 0.8rem;
  color: var(--brand-grey-700);
  border-bottom: 0.125rem solid var(--brand-grey-300);
}

.table td {
  padding: 0.8rem;
  border-top: 1px solid var(--brand-grey-200);
  color: var(--brand-grey-600);
}

.table tr:hover {
  background: var(--brand-accent);
  transition: var(--brand-transition);
}

/* Striped tables */
.table-striped tbody tr:nth-child(odd) {
  background: var(--brand-grey-100);
}

.table-striped tbody tr:hover {
  background: var(--brand-accent);
}

/* ---------- BADGES ---------- */
.badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--brand-radius-sm);
  font-size: 0.85rem;
  font-weight: var(--brand-font-weight-bold);
  line-height: 1;
}

.badge-primary,
.badge-brand-primary {
  background: var(--brand-primary);
  color: var(--brand-grey-800);
}

.badge-success,
.badge-brand-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-warning,
.badge-brand-warning {
  background: #fff7d6;
  color: #d4a200;
}

.badge-error,
.badge-brand-error {
  background: #fee2e2;
  color: #991b1b;
}

.badge-info,
.badge-brand-info {
  background: #e0e7ff;
  color: #3730a3;
}

/* ---------- ALERTS ---------- */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--brand-radius-md);
  border-left: 0.25rem solid;
  margin-bottom: 1rem;
  font-weight: var(--brand-font-weight-normal);
}

.alert-success {
  background: #d1fae5;
  border-color: #38ef7d;
  color: #065f46;
}

.alert-warning {
  background: var(--brand-secondary);
  border-color: var(--brand-primary);
  color: #854d0e;
}

.alert-error {
  background: #fee2e2;
  border-color: #ff6b6b;
  color: #991b1b;
}

.alert-info {
  background: #e0e7ff;
  border-color: #667eea;
  color: #3730a3;
}

/* ---------- NAVBAR ---------- */
.navbar {
  background: var(--brand-white);
  box-shadow: var(--brand-shadow-sm);
  border-bottom: 1px solid var(--brand-grey-200);
}

.navbar-brand {
  font-weight: var(--brand-font-weight-bold);
  color: var(--brand-grey-800);
}

.nav-link {
  color: var(--brand-grey-700);
  transition: var(--brand-transition);
  font-weight: var(--brand-font-weight-normal);
}

.nav-link:hover {
  color: var(--brand-grey-900);
  background: var(--brand-accent);
}

.nav-link.active {
  color: var(--brand-grey-800);
  font-weight: var(--brand-font-weight-bold);
  background: var(--brand-secondary);
}

/* ---------- DASHBOARD STATS CARDS ---------- */
.stat-card {
  background: var(--brand-white);
  border-radius: var(--brand-radius-md);
  padding: 1.5rem;
  box-shadow: var(--brand-shadow-sm);
  border-left: 0.25rem solid var(--brand-primary);
  transition: var(--brand-transition);
}

.stat-card:hover {
  box-shadow: var(--brand-shadow-md);
  transform: translateY(-0.25rem);
}

.stat-card-title {
  color: var(--brand-grey-600);
  font-size: 0.875rem;
  font-weight: var(--brand-font-weight-normal);
  text-transform: uppercase;
  letter-spacing: 0.0312rem;
  margin-bottom: 0.5rem;
}

.stat-card-value {
  color: var(--brand-grey-800);
  font-size: 2rem;
  font-weight: var(--brand-font-weight-bold);
  margin-bottom: 0.25rem;
}

.stat-card-change {
  font-size: 0.875rem;
  font-weight: var(--brand-font-weight-bold);
}

.stat-card-change.positive {
  color: #38ef7d;
}

.stat-card-change.negative {
  color: #ff6b6b;
}

/* ---------- TOASTS ---------- */
.toast-container {
  z-index: 9999 !important;
}

.toast {
  border-radius: var(--brand-radius-md);
  box-shadow: var(--brand-shadow-lg);
  border: none;
  overflow: hidden;
}

.toast .toast-body {
  padding: 1rem 1.25rem;
  font-weight: var(--brand-font-weight-normal);
  font-size: var(--brand-font-size-base);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast .toast-body i {
  font-size: 1.1rem;
}

.toast .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.8;
}

.toast .btn-close:hover {
  opacity: 1;
}

/* Toast Success */
.toast-success,
.toast.toast-success {
  background: #065f46;
  color: var(--brand-white);
}

.toast-success .toast-body i {
  color: #38ef7d;
}

/* Toast Error/Danger */
.toast-error,
.toast-danger,
.toast.toast-error,
.toast.toast-danger {
  background: #991b1b;
  color: var(--brand-white);
}

.toast-error .toast-body i,
.toast-danger .toast-body i {
  color: #fca5a5;
}

/* Toast Warning */
.toast-warning,
.toast.toast-warning {
  background: #854d0e;
  color: var(--brand-white);
}

.toast-warning .toast-body i {
  color: var(--brand-primary);
}

/* Toast Info */
.toast-info,
.toast.toast-info {
  background: #3730a3;
  color: var(--brand-white);
}

.toast-info .toast-body i {
  color: #a5b4fc;
}

/* ---------- MOBILE RESPONSIVE COMPONENTS ---------- */
@media (max-width: 768px) {
  .card {
    padding: 1rem;
  }

  .btn {
    padding: 0.5rem 1rem;
  }

  .toast .toast-body {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }
}

/* ===============================
   LISTING TABLES - Minimal data tables
   =============================== */

/* Listing Container */
.listing-container {
  border: 1px solid var(--brand-grey-300, #e5e7eb);
  border-radius: var(--brand-radius-sm, 6px);
  overflow: hidden;
  background: var(--brand-white, #fff);
}

.listing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--brand-grey-100, #f9fafb);
  border-bottom: 1px solid var(--brand-grey-300, #e5e7eb);
}

.listing-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0;
  color: var(--brand-grey-700, #374151);
}

.listing-title i {
  margin-right: 6px;
}

.listing-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.listing-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--brand-grey-300, #e5e7eb);
  color: var(--brand-grey-700, #374151);
}

/* Listing Table */
.listing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  margin: 0;
}

.listing-table thead {
  background: var(--brand-grey-100, #f9fafb);
  position: sticky;
  top: 0;
  z-index: 1;
}

.listing-table th {
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--brand-grey-500, #6b7280);
  border-bottom: 1px solid var(--brand-grey-300, #e5e7eb);
  white-space: nowrap;
}

.listing-table th:first-child { padding-left: 12px; }
.listing-table th:last-child { padding-right: 12px; }

.listing-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--brand-grey-200, #f3f4f6);
  vertical-align: top;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
  line-height: 1.4;
}

.listing-table td:first-child { padding-left: 12px; }
.listing-table td:last-child { padding-right: 12px; }

.listing-table tbody tr:hover {
  background: var(--brand-grey-100, #f9fafb);
}

.listing-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table Footer */
.listing-table tfoot {
  background: var(--brand-grey-100, #f9fafb);
}

.listing-table tfoot td {
  padding: 8px;
  font-weight: 600;
  border-top: 1px solid var(--brand-grey-300, #e5e7eb);
  border-bottom: none;
}

/* Scrollable Table Body */
.listing-scroll {
  max-height: 350px;
  overflow-y: auto;
}

/* Text Utilities for Tables */
.listing-table .text-end { text-align: right; }
.listing-table .text-center { text-align: center; }
.listing-table .text-muted { color: var(--brand-grey-400, #9ca3af); }
.listing-table .text-success { color: #059669; }
.listing-table .text-warning { color: #d97706; }
.listing-table .text-danger { color: #dc2626; }
.listing-table .text-primary { color: #2563eb; }
.listing-table .fw-bold { font-weight: 600; }

/* Code/Monospace */
.listing-table code {
  font-family: monospace;
  font-size: 0.7rem;
  color: var(--brand-grey-500, #6b7280);
  background: none;
  padding: 0;
}

/* Status Icons */
.listing-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
}

.listing-status.success { color: #059669; }
.listing-status.warning { color: #d97706; }
.listing-status.danger { color: #dc2626; }
.listing-status.primary { color: #2563eb; }
.listing-status.muted { color: var(--brand-grey-400, #9ca3af); }

/* Checkbox */
.listing-table .form-check-input {
  margin: 0;
  cursor: pointer;
}

/* Empty State */
.listing-empty {
  text-align: center;
  padding: 24px;
  color: var(--brand-grey-400, #9ca3af);
}

.listing-empty i {
  font-size: 1.5rem;
  margin-bottom: 8px;
  display: block;
}

/* 2-line text clamp with hover tooltip */
.listing-table .text-2line {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 200px;
  position: relative;
  cursor: default;
}

.listing-table .text-2line[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 100;
  background: #1f2937;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  line-height: 1.4;
  max-width: 280px;
  white-space: normal;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* No wrap utility (for dates, amounts, codes) */
.listing-table .text-nowrap {
  white-space: nowrap;
  max-width: none;
}

/* Compact variant */
.listing-table.listing-compact th,
.listing-table.listing-compact td {
  padding: 4px 6px;
}

.listing-table.listing-compact th:first-child,
.listing-table.listing-compact td:first-child { padding-left: 8px; }

.listing-table.listing-compact th:last-child,
.listing-table.listing-compact td:last-child { padding-right: 8px; }

/* Section Title */
.listing-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--brand-grey-700, #374151);
}

.listing-section-title i {
  margin-right: 6px;
}

/* Form Panel */
.listing-form-panel {
  border: 1px solid var(--brand-grey-300, #e5e7eb);
  border-radius: var(--brand-radius-sm, 6px);
  padding: 12px;
  background: var(--brand-grey-100, #f9fafb);
}

.listing-form-panel .form-label {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.listing-form-panel .form-control {
  font-size: 0.875rem;
}

.listing-form-panel .form-control-sm {
  font-size: 0.75rem;
  padding: 4px 8px;
}

/* Selection Bar */
.listing-selection-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  background: #eff6ff;
  border-bottom: 1px solid #dbeafe;
  font-size: 0.75rem;
}

.listing-selection-bar .form-check-input {
  margin-right: 6px;
}

.listing-selection-count {
  color: var(--brand-grey-500, #6b7280);
}

.listing-selection-total {
  color: #059669;
  font-weight: 600;
}
