/* Calculators.im - Tailwind CSS Custom Styles */

/* Base resets and custom properties */
:root {
  --color-primary: #1a56db;
  --color-primary-container: #2170e4;
  --color-on-surface: #121c2a;
  --color-on-surface-variant: #424754;
  --color-surface: #f8f9ff;
  --color-surface-container-low: #eff4ff;
  --color-ai-indigo: #6366f1;
  --color-ai-purple: #8b5cf6;
}

/* Material Symbols configuration */
.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

/* Glass morphism effect */
.glass-effect {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* Hide scrollbar but keep functionality */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Custom animations */
@keyframes pulse-slow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-pulse-slow {
  animation: pulse-slow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.animate-fade-in {
  animation: fade-in 0.3s ease-out;
}

/* Card hover effects */
.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(18, 28, 42, 0.08);
}

/* Input focus styles */
input:focus, select:focus, textarea:focus {
  outline: none;
}

/* Button press effect */
.btn-press:active {
  transform: scale(0.98);
}

/* Gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--color-primary), var(--color-ai-indigo));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Category color utilities */
.bg-financial { background-color: #1a56db; }
.bg-health { background-color: #059669; }
.bg-math { background-color: #7c3aed; }
.bg-engineering { background-color: #d97706; }
.bg-education { background-color: #db2777; }
.bg-general { background-color: #64748b; }

/* Line clamp utilities */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

/* SSE streaming text cursor */
.streaming-cursor::after {
  content: '▋';
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Responsive typography */
@media (max-width: 640px) {
  .text-5xl { font-size: 2.25rem; }
  .text-6xl { font-size: 2.5rem; }
  .text-7xl { font-size: 3rem; }
}

/* Print styles */
@media print {
  /* Hide non-essential elements */
  .no-print,
  .ad-container,
  nav,
  footer,
  header,
  .share-btn,
  button[onclick*="share"],
  button[onclick*="export"],
  button[onclick*="toggle"],
  input[type="range"],
  .loan-preset-btn,
  .mort-term-btn,
  .loan-term-btn,
  .savings-mode-btn,
  .invest-mode-btn,
  #ai-analysis-section,
  .htmx-indicator {
    display: none !important;
  }

  /* Reset backgrounds */
  body {
    background: white !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Make containers full width */
  .container,
  main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Remove shadows and borders for cleaner print */
  .shadow-sm,
  .shadow-md,
  .shadow-lg {
    box-shadow: none !important;
  }

  /* Ensure text is black for readability */
  h1, h2, h3, h4, h5, h6, p, span, div {
    color: #000 !important;
  }

  /* Preserve important colors for charts */
  .bg-blue-500, .bg-blue-600 { background-color: #3b82f6 !important; }
  .bg-emerald-500, .bg-emerald-600 { background-color: #10b981 !important; }
  .bg-amber-500, .bg-amber-600 { background-color: #f59e0b !important; }
  .bg-purple-500, .bg-purple-600 { background-color: #8b5cf6 !important; }

  .text-blue-600 { color: #3b82f6 !important; }
  .text-emerald-600 { color: #10b981 !important; }
  .text-amber-600 { color: #f59e0b !important; }
  .text-purple-600 { color: #8b5cf6 !important; }

  /* Show hidden breakdown tables fully */
  .max-h-32,
  .max-h-96 {
    max-height: none !important;
    overflow: visible !important;
  }

  /* Page breaks */
  .page-break-before { page-break-before: always; }
  .page-break-after { page-break-after: always; }
  .avoid-break { page-break-inside: avoid; }

  /* Tables */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  th, td {
    border: 1px solid #e2e8f0 !important;
    padding: 8px !important;
  }

  thead {
    background-color: #f1f5f9 !important;
  }

  /* Preserve gradients as solid colors */
  .bg-gradient-to-br,
  .bg-gradient-to-r {
    background: #3b82f6 !important;
  }

  /* SVG charts */
  svg {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Input values - show as text */
  input[type="number"],
  input[type="text"] {
    border: none !important;
    background: transparent !important;
    font-weight: bold !important;
  }

  /* Calculator results card */
  .rounded-2xl {
    border: 1px solid #e2e8f0 !important;
    page-break-inside: avoid;
  }

  /* Print header */
  @page {
    margin: 1.5cm;
    size: A4;
  }
}

/* ============================================
   Google AdSense - CLS Protection Styles
   ============================================ */

/* Ad containers */
.ad-container {
  position: relative;
}

.ad-skeleton {
  display: none;
}


/* Sidebar sticky ad (desktop) */
.ad-sidebar {
  position: sticky;
  top: 6rem;
}


/* ============================================
   Mobile UX Improvements
   ============================================ */

/* Improved touch targets - minimum 44px for accessibility */
@media (max-width: 768px) {
  /* Ensure all buttons have adequate touch size */
  button,
  .btn,
  [role="button"],
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Larger tap area for checkboxes and toggles */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
  }

  /* Better slider experience on mobile */
  input[type="range"] {
    height: 44px;
    cursor: grab;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
  }

  /* Improved input fields for mobile */
  input[type="text"],
  input[type="number"],
  select {
    font-size: 16px !important; /* Prevents iOS zoom on focus */
    min-height: 48px;
    padding: 12px 14px;
  }

  /* Better modal sizing on mobile */
  #social-share-modal > div,
  #bookmarks-modal > div,
  #comparison-selector > div,
  #comparison-results > div {
    margin: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Comparison bar - better mobile layout */
  #comparison-bar {
    padding: 12px 16px;
  }

  #comparison-bar > div {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  #comparison-bar button {
    min-height: 44px;
  }

  /* Calculator action buttons - stack on very small screens */
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Better spacing for calculator cards */
  .rounded-2xl {
    padding: 16px;
  }

  /* Improved scrollable areas */
  .max-h-64,
  .max-h-48 {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Hide comparison button text on very small screens */
  @media (max-width: 374px) {
    .grid-cols-4 button span:last-child {
      display: none;
    }
  }
}

/* Touch feedback */
@media (hover: none) and (pointer: coarse) {
  button:active,
  [role="button"]:active {
    transform: scale(0.96);
    transition: transform 0.1s ease;
  }

  /* Disable hover effects on touch devices */
  .card-hover:hover {
    transform: none;
    box-shadow: none;
  }

  /* Add active state instead */
  .card-hover:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* Smooth scrolling for iOS */
.overflow-y-auto,
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
}

/* Safe area padding for notched devices */
@supports (padding: max(0px)) {
  #comparison-bar {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .fixed.bottom-0 {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
}

/* Prevent text selection on interactive elements */
button,
[role="button"],
.loan-preset-btn,
.mort-term-btn,
.loan-term-btn,
.savings-mode-btn,
.invest-mode-btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Better focus states for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
