/* Custom styles for clock worksheet generator */

body {
  min-height: 100vh;
}

/* Clock SVG styling */
.clock-svg {
  display: block;
  margin: 0 auto;
  width: 160px;
  height: 160px;
}

/* Worksheet grid */
.worksheet-grid {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  max-width: 100%;
}

.clock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 2px dashed #e5e7eb;
  border-radius: 0.5rem;
  background: white;
}

.time-label {
  font-size: 1.25rem;
  font-weight: 600;
  color: #374151;
  min-height: 2rem;
  border-bottom: 2px solid #d1d5db;
  padding: 0.5rem 2rem;
  text-align: center;
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .worksheet-grid {
    gap: 1.5rem;
    padding: 1rem;
  }
  
  .clock-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  @page {
    margin: 1cm;
  }
}

/* Configuration page styling */
.config-container {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.input-group {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.input-group label {
  min-width: 100px;
  font-weight: 600;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .worksheet-grid {
    gap: 1rem;
    padding: 1rem;
  }
  
  .clock-svg {
    width: 150px;
    height: 150px;
  }
}

/* AdSense and timer button styles */
.btn-timer {
  position: relative;
  overflow: hidden;
}

.btn-timer:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-timer .timer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.1) 100%);
  transition: width 0.1s linear;
}

.ad-container {
  background: #f8f9fa;
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
  border: 1px solid #e5e7eb;
}

/* Back to Top Button */
.back-to-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: hsl(var(--p));
  color: hsl(var(--pc));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  z-index: 40;
}

.back-to-top-btn:hover {
  background: hsl(var(--pf));
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:active {
  transform: translateY(0);
}

/* Responsive adjustments for back-to-top button */
@media (max-width: 640px) {
  .back-to-top-btn {
    bottom: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* SVG Flag Icons */
.flag-icon {
  width: 20px;
  height: 15px;
  border-radius: 2px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}

.flag-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Language switcher flag styling */
.lang-flag {
  width: 24px;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
}

.lang-flag svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Language dropdown grid - two columns */
.lang-dropdown-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.25rem;
  width: 28rem;
  max-height: 70vh;
  overflow-y: auto;
}

.lang-dropdown-grid li {
  margin: 0;
}

.lang-dropdown-grid li a {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

/* Responsive - single column on mobile */
@media (max-width: 640px) {
  .lang-dropdown-grid {
    grid-template-columns: 1fr;
    width: 16rem;
    max-height: 60vh;
  }
}

/* Fix for dropdown - disable pointer events when closed */
.dropdown:not(:focus-within) .dropdown-content {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

/* Prevent CLS - fixed dimensions for language button */
#langBtn {
  min-width: 85px;
  min-height: 48px;
}

#langBtn #currentFlag {
  width: 24px;
  height: 24px;
  display: inline-block;
}

#langBtn #currentCode {
  width: 24px;
  display: inline-block;
}



/* Prevent CLS - reserve space for cards */
.card {
  min-height: 60px;
}


/* CSS Containment for better performance */
.card {
  contain: layout style;
}

/* Fix SVG sizes in buttons */
.btn svg {
  width: 1.5rem !important;
  height: 1.5rem !important;
  flex-shrink: 0;
}

.btn-lg svg {
  width: 1.5rem !important;
  height: 1.5rem !important;
}

.btn-sm svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
}

.btn-circle svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
}

/* Back to top button SVG fix */
.back-to-top-btn svg {
  width: 1.25rem !important;
  height: 1.25rem !important;
  flex-shrink: 0;
}

/* ==================== RTL Support ==================== */
/* RTL direction for Arabic, Hebrew, Persian/Farsi */

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

/* Language switcher position for RTL */
[dir="rtl"] .fixed.top-4.right-4 {
  right: auto;
  left: 1rem;
}

/* Back to top button position for RTL */
[dir="rtl"] .back-to-top-btn {
  right: auto;
  left: 2rem;
}

/* Dropdown alignment for RTL */
[dir="rtl"] .dropdown-end .dropdown-content {
  left: 0;
  right: auto;
}

/* Flex direction adjustments for RTL */
[dir="rtl"] .flex.items-center.gap-2 {
  flex-direction: row-reverse;
}

[dir="rtl"] .flex.gap-3 {
  flex-direction: row-reverse;
}

/* Input group for RTL */
[dir="rtl"] .input-group {
  flex-direction: row-reverse;
}

/* Card actions for RTL */
[dir="rtl"] .card-actions.justify-end {
  justify-content: flex-start;
}

/* List styling for RTL */
[dir="rtl"] .list-disc {
  list-style-position: inside;
  padding-right: 0;
  padding-left: 1rem;
}

[dir="rtl"] ul, [dir="rtl"] ol {
  padding-right: 1.5rem;
  padding-left: 0;
}

/* Share buttons for RTL */
[dir="rtl"] .flex.flex-wrap.items-center.justify-center.gap-2 {
  flex-direction: row-reverse;
}

/* Form labels for RTL */
[dir="rtl"] .label {
  text-align: right;
}

[dir="rtl"] .label-text,
[dir="rtl"] .label-text-alt {
  text-align: right;
}

/* Select and input alignment for RTL */
[dir="rtl"] .select,
[dir="rtl"] .input {
  text-align: right;
}

/* Footer for RTL */
[dir="rtl"] footer {
  text-align: center;
}

/* Language dropdown grid for RTL */
[dir="rtl"] .lang-dropdown-grid a {
  flex-direction: row-reverse;
  text-align: right;
}

/* Card title for RTL */
[dir="rtl"] .card-title {
  justify-content: flex-end;
}

/* Prose content for RTL */
[dir="rtl"] .prose {
  text-align: right;
}

[dir="rtl"] .prose h2,
[dir="rtl"] .prose h3 {
  text-align: right;
}

/* Button content for RTL */
[dir="rtl"] .btn {
  flex-direction: row-reverse;
}

/* Fix spacing for RTL buttons */
[dir="rtl"] .btn svg + span,
[dir="rtl"] .btn span + svg {
  margin-right: 0.5rem;
  margin-left: 0;
}
