/* SH CRM Custom Styles */

:root {
  --bs-primary: #0d6efd;
  --bs-primary-rgb: 13, 110, 253;
}

/* Font Awesome icon styling */
.fas, .far, .fab {
  display: inline-block;
  font-style: normal;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  vertical-align: middle;
}

/* Layout adjustments */
.min-vh-100 {
  min-height: 100vh !important;
}

/* Card enhancements */
.card {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  border: 1px solid rgba(0, 0, 0, 0.125);
}

/* Table improvements */
.table th {
  border-top: none;
  font-weight: 600;
}

/* Badge styles */
.badge {
  font-size: 0.75em;
}

/* Status badge colors */
.badge.status-pending {
  background-color: #6c757d;
}

.badge.status-in-progress {
  background-color: #fd7e14;
}

.badge.status-on-hold {
  background-color: #dc3545;
}

.badge.status-completed {
  background-color: #198754;
}

.badge.status-cancelled {
  background-color: #343a40;
}

/* Priority badge colors */
.badge.priority-low {
  background-color: #20c997;
}

.badge.priority-medium {
  background-color: #0dcaf0;
}

.badge.priority-high {
  background-color: #fd7e14;
}

.badge.priority-urgent {
  background-color: #dc3545;
}

/* Phone number formatting prevention */
input[name="phone"] {
  font-family: monospace;
  letter-spacing: 0.5px;
}

/* Prevent automatic phone formatting */
input[name="phone"]::-webkit-outer-spin-button,
input[name="phone"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[name="phone"] {
  -moz-appearance: textfield;
}

/* Country code dropdown styling */
#country_code {
  font-weight: 600;
  color: #495057;
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .table-responsive {
    border: none;
  }
  
  .btn-group-vertical .btn {
    margin-bottom: 0.5rem;
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
  }
}

/* Barcode scanner modal */
#barcode-scanner {
  background: rgba(0, 0, 0, 0.9);
}

#barcode-scanner video {
  width: 100%;
  height: auto;
  max-width: 500px;
}

#barcode-scanner .scanner-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 250px;
  height: 250px;
  border: 2px solid #fff;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}

/* Loading states */
.btn-loading {
  position: relative;
}

.btn-loading:disabled {
  color: transparent;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: btn-loading-spinner 1s ease infinite;
}

@keyframes btn-loading-spinner {
  from {
    transform: rotate(0turn);
  }
  to {
    transform: rotate(1turn);
  }
}

/* Form enhancements */
.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label {
  opacity: 0.65;
  transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
}

/* Print styles */
@media print {
  .navbar,
  .btn,
  .card-footer,
  .no-print {
    display: none !important;
  }
  
  .card {
    border: 1px solid #000;
    box-shadow: none;
  }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  .card {
    background-color: var(--bs-dark);
    border-color: #495057;
  }
}

/* Accessibility improvements */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus improvements */
.btn:focus,
.form-control:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Sticky elements */
.sticky-top {
  z-index: 1020;
}

/* Quick actions */
.quick-actions {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1030;
}

.quick-actions .btn {
  margin-bottom: 0.5rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Inventory level indicators */
.stock-level-low {
  color: #dc3545;
  font-weight: bold;
}

.stock-level-medium {
  color: #fd7e14;
}

.stock-level-good {
  color: #198754;
}

/* Job timeline */
.timeline {
  position: relative;
  padding: 0;
  list-style: none;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2rem;
  width: 2px;
  background: #e9ecef;
}

.timeline-item {
  position: relative;
  margin-bottom: 2rem;
  padding-left: 4rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 1.5rem;
  top: 0.5rem;
  width: 1rem;
  height: 1rem;
  background: #fff;
  border: 2px solid #0d6efd;
  border-radius: 50%;
}

/* Responsive tables */
.table-responsive-stack tr {
  display: block;
  border: 1px solid #ccc;
  margin-bottom: 0.5rem;
}

.table-responsive-stack td {
  display: block;
  text-align: right;
  border: none;
  padding: 0.5rem;
}

.table-responsive-stack td::before {
  content: attr(data-label) ": ";
  float: left;
  font-weight: bold;
  text-transform: uppercase;
}

@media (min-width: 768px) {
  .table-responsive-stack tr {
    display: table-row;
    border: none;
    margin: 0;
  }
  
  .table-responsive-stack td {
    display: table-cell;
    text-align: left;
    border-top: 1px solid #dee2e6;
  }
  
  .table-responsive-stack td::before {
    display: none;
  }
}

/* Ensure actions column has proper width */
.table th:last-child,
.table td:last-child {
  width: 120px;
  min-width: 120px;
  text-align: center;
}

/* Jobs table specific styles */
.table th:last-child {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #495057;
}

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

/* Ensure consistent spacing in table cells */
.table td {
  vertical-align: middle;
  padding: 0.75rem;
}

/* Actions column specific styling */
.table td:last-child {
  padding: 0.5rem;
  text-align: center;
}

/* Button group container */
.btn-group {
  display: inline-flex;
  align-items: center;
}

/* Ensure buttons are properly sized */
.btn-group-sm .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 0.2rem;
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Actions button group improvements */
.btn-group .btn {
  margin-right: 2px;
  border-radius: 0.375rem !important;
}

.btn-group .btn:first-child {
  border-top-left-radius: 0.375rem !important;
  border-bottom-left-radius: 0.375rem !important;
}

.btn-group .btn:last-child {
  margin-right: 0;
  border-top-right-radius: 0.375rem !important;
  border-bottom-right-radius: 0.375rem !important;
}

.btn-group .btn:not(:first-child):not(:last-child) {
  border-radius: 0 !important;
}

/* Button sizing consistency */
.btn-group-sm .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 0.2rem;
}

/* Hover effects for action buttons */
.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
}

/* Delete button hover effects */
.btn-outline-danger:hover {
  background-color: #dc3545;
  border-color: #dc3545;
  color: white;
}

/* Modal improvements */
.modal-header {
  border-bottom: 1px solid #dee2e6;
}

.modal-footer {
  border-top: 1px solid #dee2e6;
}

/* Responsive button group for mobile */
@media (max-width: 768px) {
  .btn-group {
    display: flex;
    flex-direction: column;
  }
  
  .btn-group .btn {
    margin-right: 0;
    margin-bottom: 2px;
    border-radius: 0.375rem !important;
  }
  
  .btn-group .btn:first-child {
    border-top-left-radius: 0.375rem !important;
    border-top-right-radius: 0.375rem !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }
  
  .btn-group .btn:last-child {
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
    border-bottom-left-radius: 0.375rem !important;
    border-bottom-right-radius: 0.375rem !important;
    margin-bottom: 0;
  }
  
  .btn-group .btn:not(:first-child):not(:last-child) {
    border-radius: 0 !important;
  }
}
