/* Custom CSS styles for Tax Client Tracker */

/* Base styles */
:root {
  --bs-primary: #007bff;
  --bs-secondary: #6c757d;
  --bs-success: #28a745;
  --bs-info: #17a2b8;
  --bs-warning: #ffc107;
  --bs-danger: #dc3545;
  
  /* Theme transitions */
  --theme-transition: all 0.3s ease-in-out;
}

/* Add some padding to body */
body {
  padding-bottom: 70px; /* For the fixed footer */
  transition: var(--theme-transition);
}

/* Style for card headers */
.card-header {
  font-weight: 500;
}

/* Card enhancements */
.card {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  border-radius: 0.5rem;
  overflow: hidden;
  transition: var(--theme-transition);
}

/* Status badges */
.badge {
  font-weight: 500;
  padding: 0.35em 0.65em;
}

/* Footer styling */
.footer {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 60px;
  line-height: 60px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 100;
  transition: var(--theme-transition);
}

/* Table styling */
.table {
  margin-bottom: 0;
  transition: var(--theme-transition);
}

.table th {
  border-bottom-width: 2px;
  font-weight: 600;
}

.table-hover tbody tr {
  transition: background-color 0.15s ease-in-out;
}

/* Form tweaks */
.form-control, .form-select {
  border-radius: 0.375rem;
  transition: var(--theme-transition), border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus, .form-select:focus {
  box-shadow: 0 0 0 0.25rem rgba(var(--theme-accent), 0.25);
}

/* Buttons styling */
.btn {
  border-radius: 0.375rem;
  transition: all 0.2s ease-in-out;
}

.btn-primary {
  transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-outline-secondary {
  border-width: 1px;
}

.btn-outline-secondary:hover {
  transform: translateY(-1px);
}

/* Add animations for alerts */
.alert {
  animation: fadeIn 0.5s;
  border-radius: 0.5rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Navbar enhancements */
.navbar {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: var(--theme-transition);
}

.navbar-brand {
  font-weight: 600;
}

.nav-link {
  position: relative;
  transition: all 0.2s ease;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0.5rem;
  right: 0.5rem;
  height: 2px;
  background-color: var(--theme-accent);
  border-radius: 1px;
}

/* Theme customizer specific styles */
.theme-grid-item {
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.theme-grid-item.active {
  border-color: var(--theme-accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.theme-preview {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.2s ease;
}

.theme-grid-item:hover .theme-preview {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.font-size-btn.active {
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  color: white;
}

/* Responsive Mobile Styles */
@media (max-width: 767.98px) {
  body[data-font-size="large"], 
  body[data-font-size="xlarge"] {
    --base-font-size: 16px;
  }
  
  .table-responsive {
    max-height: 400px;
    overflow-y: auto;
  }
  
  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Performance Cards for Mobile */
  .performance-card {
    margin-bottom: 1rem;
  }
  
  /* Stacked display for metrics on mobile */
  .performance-metrics-row {
    flex-direction: column;
  }
  
  .performance-metrics-row .col-md-3,
  .performance-metrics-row .col-md-4,
  .performance-metrics-row .col-md-6 {
    width: 100%;
    margin-bottom: 1rem;
  }
  
  /* Adjust card titles for better mobile display */
  .performance-card .card-title {
    font-size: 1.1rem;
  }
  
  /* Enhance touch targets for mobile */
  .btn, .nav-link, .accordion-button {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
  }
  
  /* Modify progress bars for mobile */
  .progress {
    height: 20px;
  }
  
  /* Adjust table text for mobile */
  .table-sm {
    font-size: 0.85rem;
  }
  
  .table-sm th, .table-sm td {
    padding: 0.5rem 0.5rem;
  }
  
  /* Charts and visualizations on mobile */
  .performance-chart-container {
    height: 250px !important;
  }
  
  /* Collapse spacing on mobile */
  .performance-section .card-body {
    padding: 0.75rem;
  }
  
  /* Mobile menu styling */
  .navbar-collapse {
    background-color: var(--bs-dark);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 0.5rem;
  }
}

/* Pagination enhancements */
.pagination {
  margin-top: 1.5rem;
}

.page-link {
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  margin: 0 0.125rem;
  transition: all 0.2s ease;
}

.page-item.active .page-link {
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
}

/* Search form toggle button animation */
[data-bs-toggle="collapse"] {
  transition: transform 0.2s ease;
}

[aria-expanded="true"][data-bs-toggle="collapse"] {
  transform: rotate(180deg);
}

/* Enhanced scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--theme-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--theme-accent);
}

/* Performance metrics specific styles */
.performance-card {
  transition: all 0.3s ease;
  border: none;
}

.performance-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.performance-metric-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.performance-metric-label {
  font-size: 0.875rem;
  color: var(--bs-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.performance-progress {
  height: 8px;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
  border-radius: 4px;
}

.performance-comparison {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.comparison-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.performance-tab-content {
  transition: all 0.3s ease-in-out;
  animation: fadeIn 0.5s;
}

/* Sparkline chart container */
.sparkline-container {
  height: 30px;
  margin-top: 0.5rem;
}

/* Mobile optimizations for cards */
@media (max-width: 767.98px) {
  .metric-card-columns {
    column-count: 1;
  }
  
  .performance-metric-value {
    font-size: 1.5rem;
  }
  
  .performance-section {
    padding: 0.5rem;
  }
  
  .mobile-scroll-container {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
  }
  
  .mobile-scroll-item {
    display: inline-block;
    width: 85%;
    margin-right: 0.75rem;
  }
  
  .mobile-scroll-item:last-child {
    margin-right: 0;
  }
  
  .mobile-compact {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
  
  .mobile-stats-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 1rem;
  }
  
  .mobile-stats-card {
    flex: 0 0 auto;
    width: 180px;
    margin-right: 1rem;
  }
}

/* Dashboard widgets animations */
.dashboard-widget {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Notes card styling */
.note-card {
  min-height: 200px; /* Increased minimum height to ensure dropdown menu is accessible */
  position: relative; /* Ensure proper positioning context for dropdown */
}

.note-card .card-body {
  min-height: 140px; /* Increased content area minimum height */
  padding-bottom: 2.5rem; /* Add extra padding at bottom for dropdown */
}

.note-card .card-text {
  min-height: 80px; /* Increased minimum height for text area */
  word-break: break-word; /* Ensure long words don't overflow */
}

/* Position the dropdown menu toggle button properly */
.note-card .dropdown {
  position: absolute;
  bottom: 10px;
  right: 10px;
}

/* Simple dropdown styling */
.dropdown-menu {
  min-width: 220px; /* Further increased width to fully accommodate all menu items */
  max-height: 240px; /* Ensure dropdown doesn't get cut off with multiple items */
  overflow-y: auto; /* Add scrolling if many items */
}

/* Make dropdowns in notes open upward to prevent being cut off */
.note-card .dropdown-menu {
  top: auto !important; /* Override Bootstrap's top positioning */
  bottom: 100% !important; /* Position above the toggle button */
  margin-bottom: 5px; /* Add some space between button and menu */
}

.dropdown-menu .dropdown-item {
  padding: 0.5rem 1rem; /* Add more padding to dropdown items for better touch targets */
  white-space: normal; /* Allow text to wrap if needed */
}

.delete-note-item {
  background-color: rgba(255, 220, 220, 0.1); /* Subtle highlight for delete item */
}

/* Staggered animation delays */
.dashboard-widget:nth-child(1) { animation-delay: 0.1s; }
.dashboard-widget:nth-child(2) { animation-delay: 0.2s; }
.dashboard-widget:nth-child(3) { animation-delay: 0.3s; }
.dashboard-widget:nth-child(4) { animation-delay: 0.4s; }

/* Mobile Performance Quick Access Button */
.mobile-performance-button {
  display: none;
  position: fixed;
  bottom: 75px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background-color: var(--bs-primary);
  color: white;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  z-index: 999;
  text-align: center;
  line-height: 60px;
  font-size: 24px;
  transition: all 0.3s ease;
}

.mobile-performance-button:hover,
.mobile-performance-button:focus {
  transform: translateY(-3px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
  color: white;
}

@media (max-width: 992px) {
  .mobile-performance-button {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ── AI Note rendered HTML ────────────────────────────────────────────────────
   Notes posted from the AI assistant capture bubble.innerHTML from the chat
   panel. Mirror the exact same dark-bubble styling so the note looks
   identical to how it appeared in FirmFlow AI.
───────────────────────────────────────────────────────────────────────────── */
.ai-note-rendered {
  background: #1e2530;
  color: #e2e8f0;
  font-size: 0.86rem;
  line-height: 1.55;
  padding: 10px 14px;
  border-radius: 10px;
  word-break: break-word;
}
/* Paragraphs */
.ai-note-rendered p  { margin: 4px 0; }
/* Bold / italic */
.ai-note-rendered strong { color: #f9fafb; }
.ai-note-rendered em     { font-style: italic; }
/* Lists */
.ai-note-rendered ul { padding-left: 18px; margin: 4px 0; }
.ai-note-rendered ol { padding-left: 20px; margin: 4px 0; }
.ai-note-rendered li { margin: 2px 0; }
/* Inline code */
.ai-note-rendered code {
  background: #0f1117;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: #f472b6;
}
/* Code blocks */
.ai-note-rendered pre {
  background: #0f1117;
  padding: 10px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8rem;
  color: #e2e8f0;
  margin: 6px 0;
}
/* Headings (.ai-h class + bare h1-h4) */
.ai-note-rendered .ai-h,
.ai-note-rendered h1,
.ai-note-rendered h2,
.ai-note-rendered h3,
.ai-note-rendered h4 {
  color: #e2e8f0;
  margin: 8px 0 4px;
  line-height: 1.3;
  font-weight: 700;
}
.ai-note-rendered h1.ai-h, .ai-note-rendered h1 { font-size: 1.05rem; border-bottom: 1px solid #374151; padding-bottom: 3px; }
.ai-note-rendered h2.ai-h, .ai-note-rendered h2 { font-size: 0.97rem; color: #93c5fd; }
.ai-note-rendered h3.ai-h, .ai-note-rendered h3 { font-size: 0.9rem;  color: #a5b4fc; }
.ai-note-rendered h4.ai-h, .ai-note-rendered h4 { font-size: 0.85rem; color: #c4b5fd; }
/* HR */
.ai-note-rendered hr { border: none; border-top: 1px solid #374151; margin: 8px 0; }
/* Blockquote */
.ai-note-rendered .ai-bq,
.ai-note-rendered blockquote {
  border-left: 3px solid #4b5563;
  margin: 4px 0;
  padding: 2px 10px;
  color: #9ca3af;
  font-style: italic;
}
/* Tables */
.ai-note-rendered .ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin: 8px 0;
}
.ai-note-rendered .ai-table th {
  background: #0f1117;
  color: #93c5fd;
  font-weight: 600;
  padding: 6px 10px;
  text-align: left;
  border: 1px solid #374151;
  white-space: nowrap;
}

/* Muted record ids (#409) beside project and return names. Color comes from .text-muted. */
.record-number {
  font-size: 0.85em;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.record-number-header {
  font-size: 0.55em;
  font-weight: 500;
  vertical-align: middle;
}
.record-number-sep {
  font-size: 0.55em;
  font-weight: 400;
  margin: 0 0.28em;
  vertical-align: middle;
}
.ai-note-rendered .ai-table td {
  padding: 5px 10px;
  border: 1px solid #2d3748;
  color: #e2e8f0;
  vertical-align: top;
}
.ai-note-rendered .ai-table tr:nth-child(even) td {
  background: rgba(255,255,255,0.03);
}
