/* General avatar styling */
.user-avatar {
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Main styles for BlobLogic */
.sidebar {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  position: relative;
  width: 256px;
  flex-shrink: 0;
}

/* Dark mode sidebar */
.dark .sidebar {
  background: linear-gradient(135deg, #1e1b4b 0%, #581c87 100%);
}

/* Only add transitions after initial load */
html:not(.sidebar-loading) .sidebar {
  transition: all 0.3s ease;
}

/* Disable all transitions during initial load */
html.sidebar-loading * {
  transition: none !important;
  animation: none !important;
}

.sidebar.collapsed {
  width: 70px;
}

/* Apply collapsed styles immediately based on localStorage - highest priority */
html.sidebar-collapsed .sidebar {
  width: 70px !important;
}

html.sidebar-collapsed .sidebar .nav-text {
  display: none !important;
}

html.sidebar-collapsed .sidebar .logo-text {
  display: none !important;
}

html.sidebar-collapsed .sidebar .logo-image {
  display: block !important;
  height: 4rem !important;
  width: auto !important;
  margin: 0 auto !important;
}

html.sidebar-collapsed .sidebar .logo-image + * {
  margin-top: 0 !important;
}

html.sidebar-collapsed .sidebar .nav-item {
  justify-content: center !important;
  padding: 12px 8px !important;
}

html.sidebar-collapsed .sidebar .section-title {
  display: none !important;
}

html.sidebar-collapsed .sidebar .user-info {
  display: none !important;
}

html.sidebar-collapsed .sidebar .user-avatar {
  display: block !important;
  margin: 0 auto !important;
  width: 40px !important;
  height: 40px !important;
  flex-shrink: 0 !important;
}

html.sidebar-collapsed .sidebar .collapse-icon {
  transform: rotate(180deg) !important;
}

html.sidebar-collapsed .sidebar #sidebar-toggle {
  justify-content: center !important;
  padding: 8px !important;
}

html.sidebar-collapsed .sidebar a[href="/profile"] {
  justify-content: center !important;
  padding: 8px !important;
  position: relative !important;
  flex-direction: column !important;
  align-items: center !important;
  min-height: 56px !important;
  width: 100% !important;
}

html.sidebar-collapsed .sidebar a[href="/profile"] .user-avatar {
  margin: 0 !important;
  width: 40px !important;
  height: 40px !important;
  object-fit: cover !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
}

.sidebar.collapsed .nav-text {
  display: none;
}

.sidebar.collapsed .logo-text {
  display: none;
}

.sidebar.collapsed .logo-image {
  display: block;
  height: 4rem;
  width: auto;
  margin: 0 auto;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 12px 8px;
}

.sidebar.collapsed .section-title {
  display: none;
}

.sidebar.collapsed .user-info {
  display: none;
}

.sidebar.collapsed .user-avatar {
  display: block;
  margin: 0 auto;
  width: 40px !important;
  height: 40px !important;
  flex-shrink: 0;
}

/* Profile section in sidebar */
.sidebar a[href="/profile"] {
  transition: all 0.2s ease;
}

.sidebar.collapsed a[href="/profile"] {
  justify-content: center;
  padding: 8px;
  position: relative;
  flex-direction: column;
  align-items: center;
  min-height: 56px;
  width: 100%;
}

.sidebar.collapsed a[href="/profile"] .user-avatar {
  margin: 0;
  width: 40px !important;
  height: 40px !important;
  object-fit: cover;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar.collapsed a[href="/profile"]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  margin-left: 10px;
  font-size: 14px;
}

.sidebar.collapsed a[href="/profile"]:hover::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: rgba(0, 0, 0, 0.8);
  margin-left: 4px;
  z-index: 1000;
}

.sidebar.collapsed .toggle-icon {
  transform: rotate(180deg);
}

.sidebar.collapsed #sidebar-toggle {
  justify-content: center;
  padding: 8px;
}

.sidebar.collapsed .collapse-icon {
  transform: rotate(180deg);
  margin-right: 0 !important;
}

.sidebar.collapsed #sidebar-toggle:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  margin-left: 10px;
  font-size: 14px;
}

.sidebar.collapsed #sidebar-toggle:hover::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: rgba(0, 0, 0, 0.8);
  margin-left: 4px;
  z-index: 1000;
}

.collapse-icon {
  transition: transform 0.3s ease;
}

#sidebar-toggle {
  position: relative;
}

.toggle-icon {
  transition: transform 0.3s ease;
}

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .nav-item {
  position: relative;
}

.sidebar.collapsed .nav-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 1000;
  margin-left: 10px;
  font-size: 14px;
}

.sidebar.collapsed .nav-item:hover::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: rgba(0, 0, 0, 0.8);
  margin-left: 4px;
  z-index: 1000;
}

.content {
  transition: all 0.3s ease;
  flex: 1;
  min-width: 0;
}

.chart-container {
  height: 300px;
}

.carrier-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  border-color: rgba(99, 102, 241, 0.3);
}

.carrier-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background-color: white;
  min-width: 160px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  z-index: 1;
  border-radius: 0.5rem;
  transform-origin: top right;
  animation: scaleIn 0.15s ease-out;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* Additional responsive improvements */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    transform: translateX(-100%);
    width: 256px !important; /* Force full width on mobile */
  }
  
  .sidebar.collapsed {
    width: 256px !important; /* Don't collapse on mobile */
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  /* Hide tooltips on mobile */
  .sidebar.collapsed .nav-item:hover::after,
  .sidebar.collapsed .nav-item:hover::before {
    display: none;
  }
}

/* Chart responsiveness */
.chart-container canvas {
  max-height: 300px;
}

/* Smooth animations for all interactive elements */
button, a {
  transition: all 0.2s ease-in-out;
}

/* Focus states for accessibility */
button:focus, a:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid #4f46e5 !important;
  outline-offset: 2px !important;
}

/* Dark mode focus states */
.dark button:focus, .dark a:focus, .dark input:focus, .dark select:focus, .dark textarea:focus {
  outline: 2px solid #818cf8 !important;
  outline-offset: 2px !important;
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #4f46e5;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

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

/* Dark Mode Styles */
.dark {
  color-scheme: dark;
}

/* Dark mode components */
.dark .bg-white {
  background-color: #1f2937 !important;
}

.dark .text-gray-900 {
  color: #f9fafb !important;
}

.dark .text-gray-800 {
  color: #f3f4f6 !important;
}

.dark .text-gray-700 {
  color: #e5e7eb !important;
}

.dark .text-gray-600 {
  color: #d1d5db !important;
}

.dark .text-gray-500 {
  color: #9ca3af !important;
}

.dark .border-gray-200 {
  border-color: #374151 !important;
}

.dark .border-gray-300 {
  border-color: #4b5563 !important;
}

.dark .shadow {
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2) !important;
}

/* Cards and containers */
.dark .carrier-card {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
}

.dark .carrier-card:hover {
  background-color: #111827 !important;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.4), 0 10px 10px -5px rgba(0,0,0,0.2) !important;
  border-color: rgba(99, 102, 241, 0.5) !important;
}

/* Form inputs */
.dark input,
.dark select,
.dark textarea {
  background-color: #374151 !important;
  border-color: #4b5563 !important;
  color: #f9fafb !important;
}

.dark input:focus,
.dark select:focus,
.dark textarea:focus {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

.dark input::placeholder {
  color: #9ca3af !important;
}

/* Buttons */
.dark button:not(.bg-indigo-600):not(.bg-green-600):not(.bg-red-600):not(.bg-blue-600) {
  background-color: #374151 !important;
  color: #f9fafb !important;
  border-color: #4b5563 !important;
}

.dark button:not(.bg-indigo-600):not(.bg-green-600):not(.bg-red-600):not(.bg-blue-600):hover {
  background-color: #4b5563 !important;
}

/* Tables */
.dark table {
  background-color: #1f2937 !important;
}

.dark th {
  background-color: #374151 !important;
  color: #f9fafb !important;
}

.dark td {
  border-color: #374151 !important;
  color: #e5e7eb !important;
}

/* Header */
.dark header {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
}

/* Dropdown */
.dark .dropdown-content {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3), 0 4px 6px -2px rgba(0,0,0,0.2) !important;
}

.dark .dropdown-content a {
  color: #e5e7eb !important;
}

.dark .dropdown-content a:hover {
  background-color: #374151 !important;
}

/* Status badges */
.dark .bg-green-100 {
  background-color: #065f46 !important;
}

.dark .text-green-800 {
  color: #a7f3d0 !important;
}

.dark .bg-yellow-100 {
  background-color: #92400e !important;
}

.dark .text-yellow-800 {
  color: #fde68a !important;
}

.dark .bg-red-100 {
  background-color: #991b1b !important;
}

.dark .text-red-800 {
  color: #fca5a5 !important;
}

.dark .bg-blue-100 {
  background-color: #1e3a8a !important;
}

.dark .text-blue-600 {
  color: #93c5fd !important;
}

.dark .bg-gray-100 {
  background-color: #374151 !important;
}

.dark .text-gray-800 {
  color: #d1d5db !important;
}

/* Icon backgrounds */
.dark .bg-indigo-100 {
  background-color: #3730a3 !important;
}

.dark .bg-purple-100 {
  background-color: #6b21a8 !important;
}

.dark .bg-orange-100 {
  background-color: #c2410c !important;
}

/* Lines Management Dark Mode Styles */
.dark .bg-gray-50 {
  background-color: #374151 !important;
}

/* Stats cards icon backgrounds for dark mode */
.dark .bg-blue-100 {
  background-color: #1e3a8a !important;
}

.dark .bg-green-100 {
  background-color: #14532d !important;
}

.dark .bg-yellow-100 {
  background-color: #92400e !important;
}

.dark .bg-red-100 {
  background-color: #991b1b !important;
}

/* Icon colors for dark mode */
.dark .text-blue-600 {
  color: #3b82f6 !important;
}

.dark .text-green-600 {
  color: #10b981 !important;
}

.dark .text-yellow-600 {
  color: #f59e0b !important;
}

.dark .text-red-600 {
  color: #ef4444 !important;
}

/* Badge and pill components for status */
.dark .bg-blue-100.text-blue-800 {
  background-color: #1e40af !important;
  color: #bfdbfe !important;
}

.dark .bg-green-100.text-green-800 {
  background-color: #166534 !important;
  color: #bbf7d0 !important;
}

.dark .bg-yellow-100.text-yellow-800 {
  background-color: #a16207 !important;
  color: #fef3c7 !important;
}

.dark .bg-red-100.text-red-800 {
  background-color: #dc2626 !important;
  color: #fecaca !important;
}

/* Filter labels and form elements */
.dark label {
  color: #d1d5db !important;
}

.dark .text-xs {
  color: #9ca3af !important;
}

/* Button variants for dark mode */
.dark .bg-blue-600 {
  background-color: #2563eb !important;
}

.dark .bg-blue-600:hover {
  background-color: #1d4ed8 !important;
}

.dark .bg-green-600 {
  background-color: #059669 !important;
}

.dark .bg-green-600:hover {
  background-color: #047857 !important;
}

/* Advanced filter and toolbar styles */
.dark .border-t {
  border-color: #4b5563 !important;
}

/* Table specific dark mode */
.dark .divide-gray-200 > * {
  border-color: #374151 !important;
}

.dark thead {
  background-color: #374151 !important;
}

.dark tbody tr:nth-child(even) {
  background-color: #1f2937 !important;
}

.dark tbody tr:nth-child(odd) {
  background-color: #111827 !important;
}

/* Checkbox styling for dark mode */
.dark input[type="checkbox"] {
  background-color: #374151 !important;
  border-color: #4b5563 !important;
}

.dark input[type="checkbox"]:checked {
  background-color: #2563eb !important;
  border-color: #2563eb !important;
}

/* Status badges in table rows */
.dark .inline-flex.items-center {
  background-color: #374151 !important;
  color: #d1d5db !important;
}

.dark .bg-green-500 {
  background-color: #10b981 !important;
}

.dark .bg-yellow-500 {
  background-color: #f59e0b !important;
}

.dark .bg-red-500 {
  background-color: #ef4444 !important;
}

/* Disabled state for dark mode */
.dark button:disabled {
  background-color: #4b5563 !important;
  color: #6b7280 !important;
  opacity: 0.5 !important;
}

/* Search and filter specific styles */
.dark .focus\:ring-blue-500:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3) !important;
}

.dark .focus\:border-blue-500:focus {
  border-color: #2563eb !important;
}

/* Toolbar and header backgrounds */
.dark .bg-white.border-b {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
}

/* Advanced filter toggle */
.dark .text-blue-600 {
  color: #60a5fa !important;
}

.dark .hover\:text-blue-800:hover {
  color: #3b82f6 !important;
}

/* Settings page dark mode toggles and form elements */
.dark .peer {
  background-color: #4b5563 !important;
  border-color: #6b7280 !important;
}

.dark .peer:checked {
  background-color: #2563eb !important;
}

.dark .peer-checked\:bg-indigo-600:checked {
  background-color: #2563eb !important;
}

.dark .peer-focus\:ring-indigo-300:focus {
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2) !important;
}

/* Navigation tabs and settings nav */
.dark .bg-indigo-50 {
  background-color: #312e81 !important;
}

.dark .text-indigo-700 {
  color: #a5b4fc !important;
}

/* Modal and dropdown improvements */
.dark .fixed.inset-0 {
  background-color: rgba(0, 0, 0, 0.8) !important;
}

.dark .max-h-96 {
  background-color: #1f2937 !important;
}

/* Search results and global search */
.dark #search-results {
  background-color: #1f2937 !important;
  border-color: #374151 !important;
}

.dark #search-results .border-b {
  border-color: #374151 !important;
}

/* Chart containers */
.dark .chart-container {
  background-color: transparent !important;
}

/* Logo container styling for collapsed state */
html.sidebar-collapsed .sidebar .p-4:first-child {
  padding: 1rem 0.5rem !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
}

html.sidebar-collapsed .sidebar .p-4:first-child > div:first-child {
  display: none !important;
}

html.sidebar-collapsed .sidebar .p-4:first-child > div:last-child {
  width: 100% !important;
  display: flex !important;
  justify-content: center !important;
}

.sidebar.collapsed .p-4:first-child {
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar.collapsed .p-4:first-child > div:first-child {
  display: none;
}

.sidebar.collapsed .p-4:first-child > div:last-child {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Column Resize Functionality */
.resizable-table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.resizable-column {
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  background: transparent;
  border-right: 2px solid transparent;
  z-index: 10;
  user-select: none;
  transition: all 0.2s ease;
}

.resize-handle:hover {
  border-right-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
  width: 10px;
}

.resize-handle:active {
  border-right-color: #1d4ed8;
  background: rgba(59, 130, 246, 0.2);
  width: 10px;
}

.dark .resize-handle:hover {
  border-right-color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
  width: 10px;
}

.dark .resize-handle:active {
  border-right-color: #3b82f6;
  background: rgba(96, 165, 250, 0.2);
  width: 10px;
}

/* Prevent text selection during resize */
.resizing {
  user-select: none;
  cursor: col-resize;
}

.resizing * {
  user-select: none;
  pointer-events: none;
}

/* Table cell content wrapping */
.resizable-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-left: 8px;
  padding-right: 8px;
}

/* Auto-resize indicator */
.auto-resize-indicator {
  position: absolute;
  top: 50%;
  right: 2px;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  background: #3b82f6;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.resizable-column:hover .auto-resize-indicator {
  opacity: 1;
}

.dark .auto-resize-indicator {
  background: #60a5fa;
}

/* Column Management Styles */
.resizing {
  cursor: col-resize !important;
  user-select: none !important;
}

.resize-handle {
  transition: background-color 0.2s ease;
}

.resize-handle:hover {
  background-color: #3b82f6 !important;
}

.dark .resize-handle:hover {
  background-color: #60a5fa !important;
}

/* Drag and drop styles */
.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
}

.drag-over {
  border-top: 3px solid #3b82f6;
}

/* Column modal animations */
#column-management-modal.flex {
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Table column transitions */
.resizable-column {
  transition: width 0.1s ease-out;
}

/* Sortable list styles */
.sortable-ghost {
  background-color: #f3f4f6;
  border: 2px dashed #d1d5db;
}

.dark .sortable-ghost {
  background-color: #374151;
  border-color: #6b7280;
}
