/* OmniTools - main styles */

:root {
  --accent: #4f46e5;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
}

body { -webkit-font-smoothing: antialiased; }

/* Ad slots - unified styling */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    #f8fafc,
    #f8fafc 10px,
    #f1f5f9 10px,
    #f1f5f9 20px
  );
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  margin: 16px 0;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.ad-slot-leaderboard {
  min-height: 90px;
  max-height: 120px;
}

.ad-slot-rectangle {
  min-height: 250px;
  max-height: 280px;
}

.ad-slot-tall {
  min-height: 600px;
  max-height: 640px;
}

.ad-slot-native {
  min-height: 140px;
  max-height: 200px;
}

.ad-slot > span {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  user-select: none;
}

.ad-slot[data-ad-state="pending"] {
  opacity: 0.5;
}

.ad-slot[data-ad-state="loaded"] {
  opacity: 1;
}

.ad-slot[data-ad-state="empty"] {
  display: none;
}

#adblock-message {
  display: none;
  padding: 20px;
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 12px;
  text-align: center;
  margin: 16px 0;
}

#adblock-message.show {
  display: block;
}

#adblock-message p {
  font-size: 13px;
  color: #78350f;
  margin: 0;
}

#adblock-message strong {
  color: #92400e;
}

@media (max-width: 640px) {
  .ad-slot-tall {
    min-height: 250px;
    max-height: 280px;
  }
}

@media print {
  .no-print,
  .ad-slot,
  aside,
  header button,
  #adblock-message {
    display: none !important;
  }
  body {
    background: white !important;
    padding-bottom: 0 !important;
  }
}

/* ------------------------------------------------------------- */
/* Mobile sidebar (drawer)                                       */
/* ------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Sidebar is a fixed drawer on mobile */
  /* Override Tailwind 'hidden md:block' which hides aside on mobile */
  aside#sidebar {
    display: block !important;
    position: fixed;
    top: 57px; /* header height */
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-card, #ffffff);
    border-right: 1px solid var(--border-default, #e2e8f0);
    color: var(--text-primary, #1e293b);
    padding: 16px;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 30;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.05);
  }

  /* When body has .sidebar-open, slide sidebar into view */
  body.sidebar-open aside#sidebar {
    transform: translateX(0);
  }

  /* Overlay that dims the rest of the page */
  body.sidebar-open::after {
    content: '';
    position: fixed;
    top: 57px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 25;
    animation: fadeIn 0.2s ease;
  }

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

/* ------------------------------------------------------------- */
/* Mobile overrides for sidebar scroll and ad heights            */
/* ------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Make ad slots shorter on mobile */
  .ad-slot-tall {
    min-height: 250px !important;
    max-height: 280px !important;
  }

  .ad-slot-leaderboard {
    min-height: 60px !important;
    max-height: 80px !important;
  }

  /* Add padding at bottom of sidebar so ad isn't clipped */
  aside#sidebar {
    padding-bottom: 24px;
  }

  /* Smooth behavior when toggling */
  aside#sidebar {
    -webkit-overflow-scrolling: touch;
  }
}

/* Prevent sticky header from breaking page breaks in PDF */
@media print {
  header {
    display: none !important;
  }

  .ad-slot {
    display: none !important;
  }
}

/* Prevent sidebar transition flash when resizing from desktop to mobile */
@media (max-width: 768px) {
  body.sidebar-no-transition aside#sidebar {
    transition: none !important;
  }
}

/* ------------------------------------------------------------- */
/* Mobile fixes: footer visibility + hide Popular Tools in drawer */
/* ------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Remove min-h-screen so footer can scroll normally */
  body {
    min-height: 0 !important;
  }

  /* Ensure footer is visible with padding */
  footer {
    padding-bottom: 24px !important;
  }

  /* Hide Popular Tools block inside mobile sidebar drawer */
  aside#sidebar .sidebar-popular {
    display: none !important;
  }
}

/* ============================================================= */
/* Universal mobile fix - TARGETED, does not touch header         */
/* ============================================================= */

@media (max-width: 768px) {
  /* 1. Remove min-h-screen from body so footer scrolls naturally */
  body.min-h-screen {
    min-height: 0 !important;
    height: auto !important;
    padding-bottom: 0 !important;
  }

  /* 2. TARGET ONLY the main layout container (the flex wrapper)
        This is the div that directly contains <aside id="sidebar">
        and <main>. Do NOT touch the header's flex container. */
  body > div > .max-w-7xl.flex {
    display: block !important;
    padding-bottom: 24px !important;
  }

  /* 3. Main content: no flex stretch */
  main.flex-1 {
    flex: none !important;
    width: 100% !important;
  }

  /* 4. Footer always visible at the end of page */
  footer {
    padding-bottom: 24px !important;
    margin-bottom: 0 !important;
  }

  /* 5. Sidebar: hide popular, reduce spacing */
  aside#sidebar .sidebar-popular {
    display: none !important;
  }

  aside#sidebar a {
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }

  aside#sidebar .ad-slot-tall {
    min-height: 150px !important;
    max-height: 180px !important;
  }

  aside#sidebar {
    padding-top: 12px !important;
    padding-bottom: 24px !important;
  }
}

/* ------------------------------------------------------------- */
/* Fix empty space in mobile sidebar when Popular is hidden      */
/* ------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Remove spacing from the sidebar-popular block completely */
  aside#sidebar .sidebar-popular {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    height: 0 !important;
    overflow: hidden !important;
  }

  /* First section after sidebar start should have no top padding */
  aside#sidebar > div > div:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  /* Reduce the sticky top wrapper padding-top */
  aside#sidebar .sticky {
    padding-top: 0 !important;
  }
}

/* ------------------------------------------------------------- */
/* Fix: disable sticky on mobile so sidebar drawer has no gap    */
/* ------------------------------------------------------------- */

@media (max-width: 768px) {
  aside#sidebar .sticky {
    position: static !important;
    top: auto !important;
  }
}

/* ------------------------------------------------------------- */
/* Mobile: compact buttons inside calculator forms              */
/* ------------------------------------------------------------- */

@media (max-width: 768px) {
  /* Buttons inside tool forms: reduce padding and font size */
  #calculator-root button {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
    font-size: 13px !important;
  }

  /* Make the primary CTA slightly tighter */
  #calculator-root button[data-next],
  #calculator-root button[data-calculate],
  #calculator-root button[data-action] {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  /* Input fields inside tools: slightly less padding */
  #calculator-root input[type="number"],
  #calculator-root input[type="text"],
  #calculator-root select {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }

  /* Textarea: keep min-height, slightly less padding */
  #calculator-root textarea {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
  }
}

/* ============================================================= */
/* Tool cards - left stripe + gradient (variant E refined)        */
/* ============================================================= */

.tool-card {
  position: relative;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-default, #e2e8f0);
  border-left: 4px solid var(--cat-color, #6366f1);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

@supports (background: color-mix(in srgb, red 50%, white)) {
  .tool-card {
    background:
      linear-gradient(90deg,
        color-mix(in srgb, var(--cat-color, #6366f1) 10%, transparent) 0%,
        color-mix(in srgb, var(--cat-color, #6366f1) 4%, transparent) 30%,
        transparent 70%),
      var(--bg-card, #ffffff);
  }
}

.tool-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.06);
}

@supports (background: color-mix(in srgb, red 50%, white)) {
  .tool-card:hover {
    box-shadow:
      0 4px 12px color-mix(in srgb, var(--cat-color, #6366f1) 18%, transparent),
      0 12px 32px color-mix(in srgb, var(--cat-color, #6366f1) 12%, transparent);
  }
}

/* Icon in gradient circle */
.tool-card .tool-icon {
  background: linear-gradient(135deg,
    var(--cat-color, #6366f1) 0%,
    color-mix(in srgb, var(--cat-color, #6366f1) 70%, #000) 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--cat-color, #6366f1) 30%, transparent);
}

/* Dark theme */
[data-theme="dark"] .tool-card {
  background: var(--bg-card, #1e293b);
  border-color: var(--border-default, #334155);
  border-left-color: var(--cat-color, #6366f1);
}

@supports (background: color-mix(in srgb, red 50%, white)) {
  [data-theme="dark"] .tool-card {
    background:
      linear-gradient(90deg,
        color-mix(in srgb, var(--cat-color, #6366f1) 22%, transparent) 0%,
        color-mix(in srgb, var(--cat-color, #6366f1) 8%, transparent) 30%,
        transparent 70%),
      var(--bg-card, #1e293b);
  }

  [data-theme="dark"] .tool-card:hover {
    box-shadow:
      0 4px 12px color-mix(in srgb, var(--cat-color, #6366f1) 30%, transparent),
      0 12px 32px color-mix(in srgb, var(--cat-color, #6366f1) 20%, transparent);
  }
}

/* ============================================================= */
/* Sidebar scroll - independent from main content                */
/* ============================================================= */

.sidebar-scroll {
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong, #cbd5e1) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background-color: var(--border-strong, #cbd5e1);
  border-radius: 3px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-muted, #94a3b8);
}

/* Dark theme scrollbar */
[data-theme="dark"] .sidebar-scroll {
  scrollbar-color: #475569 transparent;
}

[data-theme="dark"] .sidebar-scroll::-webkit-scrollbar-thumb {
  background-color: #475569;
}

/* On mobile: sidebar drawer already has scroll, no need for max-height */
@media (max-width: 768px) {
  .sidebar-scroll {
    max-height: none;
    overflow-y: visible;
  }
}

/* ============================================================= */
/* Sidebar Home button - active state with theme support         */
/* ============================================================= */

.sidebar-home-active {
  background-color: #ecfdf5;
  color: #047857;
  border-color: #10b981 !important;
}

.sidebar-home-active:hover {
  background-color: #ecfdf5;
  filter: brightness(0.97);
}

[data-theme="dark"] .sidebar-home-active {
  background-color: #064e3b !important;
  color: #6ee7b7 !important;
  border-color: #10b981 !important;
}

[data-theme="dark"] .sidebar-home-active:hover {
  background-color: #065f46 !important;
  filter: none;
}

[data-theme="dark"] .sidebar-home-active i {
  color: #6ee7b7;
}

/* ============================================================= */
/* Mobile category cards - fixed height + tools list on right     */
/* ============================================================= */

@media (max-width: 768px) {
  #mobile-categories > div.grid {
    gap: 8px !important;
  }

  #mobile-categories .tool-card {
    min-height: 76px !important;
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    gap: 12px !important;
    align-items: center !important;
    padding: 12px !important;
  }

  #mobile-categories .tool-card .tool-icon {
    margin-left: 4px;
  }

  #mobile-categories .tool-card .flex-1 {
    min-width: 0 !important;
  }

  /* Tools preview list on mobile - on the right, compact */
  #mobile-categories .tool-card ul {
    text-align: right !important;
    margin-top: 4px !important;
    margin-left: 0 !important;
    padding-right: 0 !important;
  }

  #mobile-categories .tool-card ul li {
    justify-content: flex-end !important;
    font-size: 10px !important;
  }
}

/* ============================================================= */
/* Sidebar scroll fix - capture scroll inside sidebar area       */
/* ============================================================= */

/* Desktop: sidebar area scrolls independently */
@media (min-width: 769px) {
  aside#sidebar {
    position: sticky;
    top: 80px;
    align-self: start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong, #cbd5e1) transparent;
  }

  aside#sidebar::-webkit-scrollbar {
    width: 6px;
  }

  aside#sidebar::-webkit-scrollbar-track {
    background: transparent;
  }

  aside#sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-strong, #cbd5e1);
    border-radius: 3px;
  }

  /* Disable inner .sidebar-scroll max-height ---- outer controls it now */
  .sidebar-scroll {
    max-height: none !important;
    overflow-y: visible !important;
  }
}

/* Mobile: contain overscroll so it doesn't bubble to main */
@media (max-width: 768px) {
  aside#sidebar {
    overscroll-behavior: contain;
  }

  .sidebar-scroll {
    overscroll-behavior: contain;
  }
}


/* ============================================================= */
/* JPG to PDF - drag to reorder drop indicators                     */
/* ============================================================= */

.drop-before {
  box-shadow: inset 0 3px 0 0 #6366f1;
}

.drop-after {
  box-shadow: inset 0 -3px 0 0 #6366f1;
}

[data-theme="dark"] .drop-before {
  box-shadow: inset 0 3px 0 0 #818cf8;
}

[data-theme="dark"] .drop-after {
  box-shadow: inset 0 -3px 0 0 #818cf8;
}
