/*
 * Family Quest - Application Styles
 */

/* ===== RTL (Right-to-Left) Support ===== */

/* Base RTL text alignment */
[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .text-left {
  text-align: right;
}

[dir="rtl"] .text-right {
  text-align: left;
}

[dir="rtl"] .text-center {
  text-align: center;
}

/* RTL Flexbox - reverse row direction */
[dir="rtl"] .flex-row {
  flex-direction: row-reverse !important;
}

[dir="rtl"] .flex:not(.flex-col):not(.flex-col-reverse):not(.flex-row-reverse):not(.rtl\:flex-row):not(.rtl-no-reverse) {
  flex-direction: row-reverse !important;
}

/* Responsive flex variants */
@media (min-width: 640px) {
  [dir="rtl"] .sm\:flex:not(.flex-col):not(.flex-col-reverse):not(.flex-row-reverse):not(.rtl-no-reverse) {
    flex-direction: row-reverse !important;
  }
}

@media (min-width: 768px) {
  [dir="rtl"] .md\:flex:not(.flex-col):not(.flex-col-reverse):not(.flex-row-reverse):not(.rtl-no-reverse) {
    flex-direction: row-reverse !important;
  }
}

@media (min-width: 1024px) {
  [dir="rtl"] .lg\:flex:not(.flex-col):not(.flex-col-reverse):not(.flex-row-reverse):not(.rtl-no-reverse) {
    flex-direction: row-reverse !important;
  }
}

/* Prevent RTL reversal - use rtl-no-reverse class to keep LTR direction */
[dir="rtl"] .rtl-no-reverse {
  flex-direction: row !important;
}

/* Explicit RTL row class - keeps normal direction in RTL */
[dir="rtl"] .rtl\:flex-row {
  flex-direction: row !important;
}

/* Don't reverse these specific flex containers */
[dir="rtl"] .flex-row-reverse {
  flex-direction: row !important;
}

/* Fix justify content for RTL */
[dir="rtl"] .justify-between {
  justify-content: space-between;
}

[dir="rtl"] .justify-start {
  justify-content: flex-end;
}

[dir="rtl"] .justify-end {
  justify-content: flex-start;
}

/* RTL margin utilities */
[dir="rtl"] .ml-1 { margin-left: 0; margin-right: 0.25rem; }
[dir="rtl"] .ml-2 { margin-left: 0; margin-right: 0.5rem; }
[dir="rtl"] .ml-3 { margin-left: 0; margin-right: 0.75rem; }
[dir="rtl"] .ml-4 { margin-left: 0; margin-right: 1rem; }
[dir="rtl"] .ml-6 { margin-left: 0; margin-right: 1.5rem; }
[dir="rtl"] .ml-8 { margin-left: 0; margin-right: 2rem; }

[dir="rtl"] .mr-1 { margin-right: 0; margin-left: 0.25rem; }
[dir="rtl"] .mr-2 { margin-right: 0; margin-left: 0.5rem; }
[dir="rtl"] .mr-3 { margin-right: 0; margin-left: 0.75rem; }
[dir="rtl"] .mr-4 { margin-right: 0; margin-left: 1rem; }
[dir="rtl"] .mr-6 { margin-right: 0; margin-left: 1.5rem; }
[dir="rtl"] .mr-8 { margin-right: 0; margin-left: 2rem; }

/* RTL padding utilities */
[dir="rtl"] .pl-1 { padding-left: 0; padding-right: 0.25rem; }
[dir="rtl"] .pl-2 { padding-left: 0; padding-right: 0.5rem; }
[dir="rtl"] .pl-3 { padding-left: 0; padding-right: 0.75rem; }
[dir="rtl"] .pl-4 { padding-left: 0; padding-right: 1rem; }
[dir="rtl"] .pl-6 { padding-left: 0; padding-right: 1.5rem; }
[dir="rtl"] .pl-8 { padding-left: 0; padding-right: 2rem; }

[dir="rtl"] .pr-1 { padding-right: 0; padding-left: 0.25rem; }
[dir="rtl"] .pr-2 { padding-right: 0; padding-left: 0.5rem; }
[dir="rtl"] .pr-3 { padding-right: 0; padding-left: 0.75rem; }
[dir="rtl"] .pr-4 { padding-right: 0; padding-left: 1rem; }
[dir="rtl"] .pr-6 { padding-right: 0; padding-left: 1.5rem; }
[dir="rtl"] .pr-8 { padding-right: 0; padding-left: 2rem; }

/* Ensure full-width fixed elements span entire viewport in RTL */
[dir="rtl"] .fixed.inset-x-0 {
  left: 0 !important;
  right: 0 !important;
}

/* RTL positioning - only swap when NOT using inset-x-0 for full width */
[dir="rtl"] .left-0:not(.right-0):not(.inset-x-0) { left: auto; right: 0; }
[dir="rtl"] .left-1:not(.right-0) { left: auto; right: 0.25rem; }
[dir="rtl"] .left-2:not(.right-0) { left: auto; right: 0.5rem; }
[dir="rtl"] .left-4:not(.right-0) { left: auto; right: 1rem; }

[dir="rtl"] .right-0:not(.left-0):not(.inset-x-0) { right: auto; left: 0; }
[dir="rtl"] .right-1:not(.left-0) { right: auto; left: 0.25rem; }
[dir="rtl"] .right-2:not(.left-0) { right: auto; left: 0.5rem; }
[dir="rtl"] .right-4:not(.left-0) { right: auto; left: 1rem; }

[dir="rtl"] .-right-2 { right: auto; left: -0.5rem; }
[dir="rtl"] .-left-2 { left: auto; right: -0.5rem; }

/* RTL border radius */
[dir="rtl"] .rounded-l { border-radius: 0; border-top-right-radius: 0.25rem; border-bottom-right-radius: 0.25rem; }
[dir="rtl"] .rounded-r { border-radius: 0; border-top-left-radius: 0.25rem; border-bottom-left-radius: 0.25rem; }
[dir="rtl"] .rounded-l-lg { border-radius: 0; border-top-right-radius: 0.5rem; border-bottom-right-radius: 0.5rem; }
[dir="rtl"] .rounded-r-lg { border-radius: 0; border-top-left-radius: 0.5rem; border-bottom-left-radius: 0.5rem; }

/* RTL borders */
[dir="rtl"] .border-l { border-left: 0; border-right-width: 1px; }
[dir="rtl"] .border-r { border-right: 0; border-left-width: 1px; }
[dir="rtl"] .border-l-2 { border-left: 0; border-right-width: 2px; }
[dir="rtl"] .border-r-2 { border-right: 0; border-left-width: 2px; }
[dir="rtl"] .border-l-4 { border-left: 0; border-right-width: 4px; }
[dir="rtl"] .border-r-4 { border-right: 0; border-left-width: 4px; }

/* RTL space utilities */
[dir="rtl"] .space-x-1 > :not([hidden]) ~ :not([hidden]) { margin-left: 0; margin-right: 0.25rem; }
[dir="rtl"] .space-x-2 > :not([hidden]) ~ :not([hidden]) { margin-left: 0; margin-right: 0.5rem; }
[dir="rtl"] .space-x-3 > :not([hidden]) ~ :not([hidden]) { margin-left: 0; margin-right: 0.75rem; }
[dir="rtl"] .space-x-4 > :not([hidden]) ~ :not([hidden]) { margin-left: 0; margin-right: 1rem; }
[dir="rtl"] .space-x-6 > :not([hidden]) ~ :not([hidden]) { margin-left: 0; margin-right: 1.5rem; }
[dir="rtl"] .space-x-8 > :not([hidden]) ~ :not([hidden]) { margin-left: 0; margin-right: 2rem; }

/* Space-x-reverse for explicit RTL spacing */
[dir="rtl"] .space-x-reverse > :not([hidden]) ~ :not([hidden]) {
  --tw-space-x-reverse: 1;
}

/* RTL transforms */
[dir="rtl"] .translate-x-1\/2 { transform: translateX(-50%); }
[dir="rtl"] .-translate-x-1\/2 { transform: translateX(50%); }
[dir="rtl"] .translate-x-full { transform: translateX(-100%); }
[dir="rtl"] .-translate-x-full { transform: translateX(100%); }

/* RTL grid */
[dir="rtl"] .grid {
  direction: rtl;
}

/* Fix form inputs in RTL */
[dir="rtl"] input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
[dir="rtl"] textarea,
[dir="rtl"] select {
  text-align: right;
}

[dir="rtl"] input[type="number"] {
  text-align: left; /* Numbers stay LTR */
}

/* Buttons and submits should center text */
[dir="rtl"] input[type="submit"],
[dir="rtl"] button,
[dir="rtl"] .text-center {
  text-align: center;
}

/* Fix lists in RTL */
[dir="rtl"] .list-disc,
[dir="rtl"] .list-decimal {
  padding-left: 0;
  padding-right: 1.5rem;
}

[dir="rtl"] .list-inside {
  padding-right: 0;
}

/* Hebrew Font */
.font-hebrew {
  font-family: "Heebo", "Assistant", system-ui, sans-serif;
}

/* Ensure Hebrew text doesn't break awkwardly */
[dir="rtl"] {
  word-break: normal;
  overflow-wrap: break-word;
}

/* Animations */
@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

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

@keyframes bounce-in {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.animate-bounce-in {
  animation: bounce-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

.animate-pulse-soft {
  animation: pulse-soft 2s ease-in-out infinite;
}

/* Celebration confetti */
@keyframes confetti-fall {
  0% {
    transform: translateY(-100%) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.confetti {
  position: fixed;
  animation: confetti-fall 3s linear forwards;
  z-index: 9999;
  pointer-events: none;
}

/* Safe area for mobile devices */
.safe-area-inset-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

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

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

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c7c7c7;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

/* Turbo progress bar */
.turbo-progress-bar {
  height: 3px;
  background-color: #6366f1;
}
