/**
 * Custom styles for Expense Tracker App
 */

:root {
  --brand-gradient: linear-gradient(135deg, #3f37c9 0%, #4895ef 100%);
  --glass-bg: rgba(255,255,255,0.6);
  --glass-border: rgba(255,255,255,0.35);
}

[data-bs-theme="dark"] {
  --glass-bg: rgba(25,25,30,0.5);
  --glass-border: rgba(255,255,255,0.12);
}

.navbar-gradient {
  background: var(--brand-gradient);
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: saturate(120%) blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 1rem;
}

/* Remove backdrop-filter from the specific container that holds the export dropdown */
#filtersContainer {
  backdrop-filter: none;
}

/* Ensure export dropdown appears above all elements */
.dropdown-menu {
  z-index: 1080 !important;
}

.table-responsive {
  max-height: 46vh;
}

.form-floating > label > .hint {
  opacity: .6;
  font-weight: 400;
  margin-left: .25rem;
}


.chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  transition: all 0.2s ease;
}

.chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#ratesChip {
  position: relative;
}

#ratesChip.text-bg-warning {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

#ratesChip .bi-exclamation-triangle {
  color: var(--bs-warning-text);
  margin-left: 0.25rem;
}

.pointer {
  cursor: pointer;

/* Currency Filter Styles */
.currency-filter-container {
  background: var(--bs-gray-50);
  border-radius: var(--bs-border-radius);
  padding: 1rem;
}

[data-bs-theme="dark"] .currency-filter-container {
  background: var(--bs-gray-800);
}

.currency-filter-buttons-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--bs-gray-400) var(--bs-gray-100);
  padding-bottom: 0.5rem;
}

.currency-filter-buttons {
  display: flex;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  min-width: max-content;
}

.currency-filter-btn {
  min-width: 85px;
  min-height: 44px; /* iOS touch target */
  height: 40px;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.875rem;
  border-radius: 22px;
  transition: all 0.2s ease;
  margin: 0.25rem 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  white-space: nowrap;
  border: 1.5px solid transparent;
  position: relative;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  backdrop-filter: blur(4px);
}

.currency-filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  border-color: rgba(255,255,255,0.2);
}

.currency-filter-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.currency-filter-btn:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.currency-filter-btn .currency-code {
  font-weight: 600;
  letter-spacing: 0.025em;
}

.currency-filter-btn .currency-symbol {
  opacity: 0.85;
  font-size: 0.9em;
  font-weight: 400;
}

.currency-filter-btn .currency-count {
  font-size: 0.7rem;
  font-weight: 600;
  min-width: 1.6em;
  height: 1.6em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  margin-left: 0.25rem;
}

.currency-filter-btn.btn-primary {
  background: linear-gradient(135deg, var(--bs-primary), var(--bs-primary-dark, #0056b3));
  border-color: var(--bs-primary);
  color: white;
  box-shadow: 0 2px 6px rgba(0, 123, 255, 0.25);
}

.currency-filter-btn.btn-primary:hover {
  background: linear-gradient(135deg, var(--bs-primary-dark, #0056b3), var(--bs-primary));
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.35);
}

.currency-filter-btn.btn-primary .currency-count {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
  color: white;
}

.currency-filter-btn.btn-outline-secondary {
  background: rgba(108, 117, 125, 0.1);
  border-color: rgba(108, 117, 125, 0.3);
  color: var(--bs-secondary);
}

.currency-filter-btn.btn-outline-secondary:hover {
  background: rgba(108, 117, 125, 0.15);
  border-color: rgba(108, 117, 125, 0.5);
  color: var(--bs-secondary-dark);
}

.currency-filter-btn.btn-outline-secondary .currency-count {
  background: rgba(108, 117, 125, 0.2);
  border-color: rgba(108, 117, 125, 0.3);
  color: var(--bs-secondary);
}

/* Custom scrollbar for webkit browsers */
.currency-filter-buttons-wrapper::-webkit-scrollbar {
  height: 4px;
}

.currency-filter-buttons-wrapper::-webkit-scrollbar-track {
  background: var(--bs-gray-100);
  border-radius: 2px;
}

.currency-filter-buttons-wrapper::-webkit-scrollbar-thumb {
  background: var(--bs-gray-400);
  border-radius: 2px;
}

.currency-filter-buttons-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--bs-gray-500);
}

/* Dark mode scrollbar */
[data-bs-theme="dark"] .currency-filter-buttons-wrapper::-webkit-scrollbar-track {
  background: var(--bs-gray-700);
}

[data-bs-theme="dark"] .currency-filter-buttons-wrapper::-webkit-scrollbar-thumb {
  background: var(--bs-gray-500);
}

[data-bs-theme="dark"] .currency-filter-buttons-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--bs-gray-400);
}

/* Enhanced table display for currencies */
.original-amount {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.currency-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  background-color: var(--bs-gray-200);
  color: var(--bs-gray-700);
  font-weight: 500;
}

[data-bs-theme="dark"] .currency-badge {
  background-color: var(--bs-gray-600);
  color: var(--bs-gray-200);
}

.converted-amount {
  font-size: 0.8em;
  opacity: 0.8;
}

/* Screen reader only content */
.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;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .currency-filter-btn {
    border-width: 2px;
    font-weight: 600;
  }
  
  .currency-filter-btn.btn-primary {
    background-color: ButtonText;
    border-color: ButtonText;
    color: ButtonFace;
  }
  
  .currency-filter-btn.btn-outline-secondary {
    background-color: ButtonFace;
    border-color: ButtonText;
    color: ButtonText;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .currency-filter-btn {
    transition: none;
  }
  
  .currency-filter-btn:hover {
    transform: none;
    box-shadow: none;
  }
  
  /* Enhanced Currency Filter Styles */
  .currency-group-header {
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--bs-border-color);
  }
  
  .currency-group-header:first-child {
    margin-top: 0;
  }
  
  .currency-group-icon {
    font-size: 1.1em;
    margin-right: 0.25rem;
  }
  
  .currency-group-name {
    color: var(--bs-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
  }
  
  .currency-group-count {
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
  }
  
  /* Currency search input */
  #currencySearch {
    transition: all 0.2s ease;
  }
  
  #currencySearch:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    border-color: var(--bs-primary);
  }
  
  /* Group actions buttons */
  #groupActions .btn {
    transition: all 0.2s ease;
  }
  
  #groupActions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
  
  /* Enhanced filter info display */
  .currency-filter-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--bs-border-color);
  }
  
  .currency-filter-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
  }
  
  .currency-filter-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
  }
  
  .currency-filter-stat-label {
    color: var(--bs-secondary);
  }
  
  .currency-filter-stat-value {
    font-weight: 600;
    color: var(--bs-primary);
  }
  
  /* Responsive design for enhanced currency filters */
  @media (max-width: 768px) {
    .currency-filter-info {
      flex-direction: column;
      align-items: flex-start;
      gap: 0.5rem;
    }
    
    .currency-filter-stats {
      flex-wrap: wrap;
      gap: 0.5rem;
    }
    
    #currencySearch {
      width: 100% !important;
      margin-top: 0.5rem;
    }
    
    .currency-group-header {
      margin-top: 0.75rem;
    }
    
    .currency-group-name {
      font-size: 0.85rem;
    }
  }
  
  /* Dark mode enhancements for currency groups */
  [data-bs-theme="dark"] .currency-group-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }
  
  [data-bs-theme="dark"] .currency-group-name {
    color: rgba(255, 255, 255, 0.7);
  }
  
  [data-bs-theme="dark"] .currency-filter-info {
    border-top-color: rgba(255, 255, 255, 0.1);
  }
  
  /* Animation for group headers */
  .currency-group-header {
    animation: groupHeaderAppear 0.4s ease-out;
  }
  
  @keyframes groupHeaderAppear {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
  
  /* Hover effects for group actions */
  #groupActions .btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  
  /* Search input clear button */
  #currencySearch::-webkit-search-cancel-button {
    cursor: pointer;
  }
  
  /* Loading state for currency filters */
  .currency-filter-buttons.loading {
    opacity: 0.6;
    pointer-events: none;
  }
  
  .currency-filter-buttons.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--bs-primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }
}

/* Responsive design for currency filters */
@media (min-width: 576px) {
  .currency-filter-container {
    padding: 1rem;
  }
  
  .currency-filter-btn {
    min-width: 95px;
    min-height: 40px; /* Standard size on tablet+ */
    margin: 0;
    font-size: 0.9rem;
  }
}

@media (min-width: 768px) {
  .currency-filter-buttons {
    flex-wrap: nowrap;
    overflow-x: visible;
  }
  
  .currency-filter-buttons-wrapper {
    overflow-x: visible;
    padding-bottom: 0;
  }
  
  .currency-filter-btn {
    min-width: 105px;
    font-size: 0.9rem;
  }
}

@media (min-width: 992px) {
  .currency-filter-btn {
    min-width: 115px;
    font-size: 0.925rem;
  }
}

@media (max-width: 380px) {
  .currency-filter-btn .currency-count {
    display: none;
  }
  
  .currency-filter-btn {
    min-width: 75px;
    font-size: 0.8rem;
    height: 36px;
    padding: 0.375rem 0.75rem;
  }
}

/* Dark mode enhancements for currency filter buttons */
[data-bs-theme="dark"] .currency-filter-btn.btn-primary {
  background: linear-gradient(135deg, var(--bs-primary), var(--bs-primary-dark, #0056b3));
  box-shadow: 0 2px 6px rgba(0, 123, 255, 0.3);
}

[data-bs-theme="dark"] .currency-filter-btn.btn-outline-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
}

[data-bs-theme="dark"] .currency-filter-btn.btn-outline-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.9);
}

/* Animation for currency selection changes */
.currency-filter-btn {
  animation: tagAppear 0.3s ease-out;
}

@keyframes tagAppear {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
}
