/* Alpine.js x-cloak for preventing flash of unstyled content */
[x-cloak] {
  display: none !important;
}

/* HTMX loading indicators */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.htmx-request.htmx-indicator {
  display: inline-block;
}

p:last-child {
  margin-bottom: 0;
}

/* Dashboard Widget Styles */
.card.card-widget {
  transition: box-shadow 0.2s ease-in-out;
  margin-bottom: 1.5rem;
}

.card.card-widget:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Widget Card Body Spacing */
.card-body {
  padding: 1.5rem;
}

@media (max-width: 768px) {
  .card-body {
    padding: 1rem;
  }
}

/* Single Metric Display */
.display-3 {
  font-size: 3rem;
  font-weight: 700;
}

@media (max-width: 768px) {
  .display-3 {
    font-size: 2rem;
  }
}

/* Multiple Metrics Grid */
.row.g-3 > .col-md-6,
.row.g-3 > .col-md-4,
.row.g-3 > .col-md-3 {
  transition: transform 0.2s ease-in-out;
}

.metric-card {
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* Responsive metric cards */
@media (max-width: 576px) {
  .metric-card {
    margin-bottom: 0.75rem;
  }
  
  .metric-card .h3 {
    font-size: 1.5rem;
  }
}

/* Table Styles */
.table-responsive {
  border-radius: 0.375rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  margin-bottom: 0;
}

.table thead th {
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  white-space: nowrap;
  padding: 0.75rem 1rem;
}

.table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.table tbody tr:hover {
  background-color: rgba(0, 123, 255, 0.05);
}

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

/* Responsive table adjustments */
@media (max-width: 768px) {
  .table thead th,
  .table tbody td {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
  
  .table thead th {
    font-size: 0.75rem;
  }
}

/* Chart Container */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 300px;
}

canvas {
  max-width: 100%;
  height: auto !important;
}

/* Responsive chart adjustments */
@media (max-width: 768px) {
  .chart-container {
    min-height: 250px;
    height: 250px !important;
  }
}

@media (max-width: 576px) {
  .chart-container {
    min-height: 200px;
    height: 200px !important;
  }
}

/* Widget Title */
.card-subtitle {
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1rem;
}

@media (max-width: 768px) {
  .card-subtitle {
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
  }
}

/* Empty State Styles */
.text-muted.text-center.py-4 {
  padding: 2rem 1rem;
  color: #6c757d;
  font-style: italic;
}

/* Currency and Number Formatting */
.text-primary {
  color: #0d6efd !important;
}

/* Better spacing for widget rows */
.mb-4 {
  margin-bottom: 1.5rem !important;
}

@media (max-width: 768px) {
  .mb-4 {
    margin-bottom: 1rem !important;
  }
}

/* Improved card shadows */
.card {
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.shadow-sm {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

/* Table row count indicator */
.text-muted.small.text-center.mt-2 {
  padding-top: 0.5rem;
  font-size: 0.875rem;
}

/* Ensure tables don't break layout on small screens */
@media (max-width: 576px) {
  .table-responsive {
    font-size: 0.875rem;
  }
  
  .table-responsive table {
    min-width: 600px; /* Allow horizontal scroll for wide tables */
  }
}

/* Message Bubble Responsive Width */
.message-bubble {
  max-width: 100%;
}

@media (min-width: 576px) {
  .message-bubble {
    max-width: 75%;
  }
}

/* Messages Container Responsive Height */
.messages-container {
  max-height: 600px;
}

@media (max-width: 768px) {
  .messages-container {
    max-height: 400px;
  }
}

@media (max-width: 576px) {
  .messages-container {
    max-height: 300px;
  }
}

/* Mobile Touch Targets - Ensure minimum 44x44px for better usability */
@media (max-width: 768px) {
  .btn {
    min-height: 44px;
    padding: 0.5rem 1rem;
  }
  
  .btn-sm {
    min-height: 36px;
    padding: 0.375rem 0.75rem;
  }
  
  /* Ensure form inputs are touch-friendly */
  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  /* Make links and clickable elements easier to tap */
  a.btn,
  button.btn {
    min-width: 44px;
  }
  
  /* Improve spacing for mobile */
  .gap-2 {
    gap: 0.5rem !important;
  }
  
  /* Better text sizing on mobile */
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  h3 {
    font-size: 1.25rem;
  }
  
  h4 {
    font-size: 1.1rem;
  }
  
  h5 {
    font-size: 1rem;
  }
}

/* Prevent horizontal scroll on mobile */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }
  
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* Improve badge and button wrapping on mobile */
@media (max-width: 576px) {
  .badge {
    font-size: 0.7rem;
    padding: 0.35em 0.65em;
  }
  
  /* Ensure buttons in flex containers wrap properly */
  .d-flex.flex-wrap {
    gap: 0.5rem;
  }
}