/* The Glorious Quran - Frontend styles */

#top .quran-view { font-size: 16px !important; }

.qv-toolbar { display: block; }
.qv-toolbar .qv-toolbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: #f8faf9; border: 1px solid #e7efe9; }
.qv-toolbar .qv-row1 { border-radius: 8px 8px 0 0; border-bottom: 0; }
.qv-toolbar .qv-row2 { border-radius: 0 0 8px 8px; }
.qv-toolbar .qv-group { display: inline-flex; align-items: center; gap: 8px; padding-right: 10px; border-right: 1px dashed #d6e6db; }
.qv-toolbar .qv-group:last-child { border-right: 0; }
.qv-group label { white-space: nowrap; }
.qv-group .qv-label { font-weight: 600; font-size: 0.82em; }
#top .quran-view .qv-label { font-size: 0.82em !important; font-weight: 600 !important; }
#top .quran-view .qv-toolbar label { font-size: 0.82em !important; font-weight: 600 !important; }

/* Coppie: mantieni label e select sempre insieme */
.qv-pair { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; white-space: nowrap; }
.qv-pair label { margin: 0; }
.qv-pair select { margin: 0; }

.qv-toolbar .qv-font-ctrl { display: inline-flex; flex-direction: column; gap: 2px; margin: 0 2px; }

/* Mobile tweaks */
@media (max-width: 480px) {
  /* Riduci label a 0.70em su mobile */
  #top .quran-view .qv-label { font-size: 0.70em !important; }
  #top .quran-view .qv-toolbar label { font-size: 0.80em !important; }
  /* Abbrevia layout per righe compatte: coppie per riga */
  #qv-row2 { display: flex; flex-wrap: wrap; gap: 6px 10px; }
  #qv-row2 > .qv-pair { display: inline-flex; align-items: center; gap: 4px; }
  /* Icone A+/A- più piccole su mobile */
  .qv-toolbar .qv-font-ctrl button { width: 16px; height: 16px; }
  /* Mantieni select affiancati alle label principali */
  .qv-toolbar .qv-row1 .qv-group { flex-direction: row; align-items: center; }
  /* Allinea le coppie nelle traduzioni */
  #qv-row2 label + .qv-font-ctrl {margin-left: -6px;margin-right: -6px;}
  /* Sura in due righe centrata; gear a destra */
  #qv-group-sura { flex: 1 1 100%; flex-direction: column; align-items: center; gap: 6px; }
  #qv-group-sura select { width: 100%; }
  #qv-group-gear { margin-left: auto; align-self: flex-start; }
}

.qv-toolbar .qv-group label, .qv-toolbar .qv-group .qv-select { align-self: center; }
.qv-toolbar .qv-group .qv-select { height: auto; line-height: normal; vertical-align: middle; }
#top .quran-view .qv-toolbar-row, #top .quran-view .qv-toolbar .qv-group { align-items: center !important; }
#top .quran-view select.qv-select { align-self: center !important; }

.qv-toolbar .qv-font-ctrl button { position: relative; border: 1px solid #cfd9d3; background: #fff; padding: 0; width: 16px; height: 16px; border-radius: 4px; cursor: pointer; overflow: hidden; }
.qv-toolbar .qv-font-ctrl button:hover { background: #f2f7f4; }
/* Nasconde il testo ma mantiene l'accessibilità */
.qv-toolbar .qv-font-ctrl button span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
/* Icone sovrapposte: A grande e A piccola */
.qv-toolbar .qv-font-ctrl .qv-btn-a-big::before,
.qv-toolbar .qv-font-ctrl .btn-a-big::before { content: 'A'; position: absolute; left: 6px; bottom: 3px; font-size: 11px; line-height: 1; color: #6b7d74; font-weight: 700; opacity: .8; }
.qv-toolbar .qv-font-ctrl .qv-btn-a-big::after,
.qv-toolbar .qv-font-ctrl .btn-a-big::after  { content: 'A'; position: absolute; right: 6px; top: 2px; font-size: 16px; line-height: 1; color: #2f4f3f; font-weight: 800; }
.qv-toolbar .qv-font-ctrl .qv-btn-a-small::before,
.qv-toolbar .qv-font-ctrl .btn-a-small::before { content: 'A'; position: absolute; right: 6px; top: 2px; font-size: 11px; line-height: 1; color: #6b7d74; font-weight: 700; opacity: .8; }
.qv-toolbar .qv-font-ctrl .qv-btn-a-small::after,
.qv-toolbar .qv-font-ctrl .btn-a-small::after  { content: 'A'; position: absolute; left: 6px; bottom: 3px; font-size: 16px; line-height: 1; color: #2f4f3f; font-weight: 800; opacity: .6; }

.qv-toolbar .qv-select { margin-left: 6px; }
select.qv-select { font-size: 16px !important; height: fit-content !important; }
select.qv-select { border: 1px solid #cfd9d3; background-color: #fff; padding: 4px 28px 4px 8px; border-radius: 8px; box-shadow: inset 0 1px 2px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03); }
select#qv-layout-select { max-width: max-content; }
.qv-toolbar .qv-row2 #qv-layout-select { align-self: center; }
select#qv-reciter-select { width: max-content; }
select#qv-font-ar { max-width: fit-content; }

/* Font Arabo spacing + select size */
#qv-row2 .qv-label + #qv-font-ar { font-size: 14px !important; }
#qv-row2 .qv-label:has(+ #qv-font-ar) { margin-left: 0 !important; }

/* Font size for all labels  */
#qv-row2 { font-size: 16px; }

/* Stronger selectors to win over theme */
#top .quran-view #qv-toolbar .qv-select,
#top .quran-view #qv-row1 .qv-select,
#top .quran-view #qv-row2 .qv-select {
  font-size: 16px !important;
  padding: 2px 6px !important;
  height: auto !important;
  line-height: 1.2 !important;
  vertical-align: middle !important;
  margin-bottom: 0 !important;
}

/* Forza freccia singola personalizzata a destra e rimuove doppie frecce native */
#top .quran-view select.qv-select,
#top .quran-view #qv-toolbar select.qv-select,
#top .quran-view .qv-player select.qv-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23666' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 6px center !important;
  background-size: 12px 12px !important;
  padding-right: 26px !important;
}

#top .quran-view #qv-row1 .qv-group, #top .quran-view #qv-row2 { align-items: center !important; }
/* Allinea gear in alto a destra nella prima riga */
#qv-group-gear { margin-left: auto; }
#qv-label-sura, #qv-label-ayah, #qv-label-reciter, #qv-label-italiano, #qv-label-layout, #qv-label-lingue { font-size: 0.82em !important; }

/* Mobile: label sopra, select sotto per risparmiare spazio */
@media (max-width: 480px) {
  .qv-toolbar .qv-row1 .qv-group { flex-direction: row; align-items: center; gap: 6px; }
  .qv-toolbar .qv-row1 .qv-group .qv-select { height: auto; line-height: 1.3; }
  /* Nascondi layout su mobile */
  #qv-label-layout, #qv-layout-select { display: none !important; }
  /* Force modal centering on mobile; override theme rules that push it down */
  #top .quran-view .qv-modal { position: fixed !important; top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important; inset: 0 !important; align-items: center !important; justify-content: center !important; }
  #top .quran-view .qv-modal[style*="display: flex"] { display: flex !important; }
  #top .quran-view .qv-modal-dialog { align-self: center !important; margin: 0 12px !important; }
  /* Reduce mini-player selects by 2px on mobile */
  #top .qv-player #qv-reciter-inline,
  #top .qv-player #qv-start { font-size: 12px !important; padding: 1px 5px !important; height: 26px !important; line-height: 1.1 !important; }
  #top .qv-player #qv-reciter-inline { font-size: 12px !important; padding: 1px 5px !important; height: 26px !important; line-height: 1.1 !important; }
  /* Due righe centrate in mobile */
  #top .qv-player { justify-content: center !important; }
  #top .qv-player .qv-surah, #top .qv-player .qv-pos { flex-basis: 100%; text-align: center; }
}

/* Row2 styling improvement */
#qv-row2 { background: #f9fbfa; border-top: 1px solid #e7efe9; box-shadow: inset 0 1px 0 rgba(0,0,0,0.02); }

/* Desktop layout: prima riga con traduzioni, seconda riga con Layout+Font+Reciter */
@media (min-width: 481px) {
  #qv-row2 { 
    display: flex; 
    flex-wrap: wrap; 
    align-items: center; 
    gap: 8px 12px; 
  }
  
  /* Prima riga: traduzioni (Arabo + Traslitt. + due traduttori) */
  #qv-row2 .qv-pair--ar { order: 10; }
  #qv-row2 .qv-pair--tr { order: 11; }
  #qv-row2 .qv-pair--it-hamza_piccardo { order: 12; }
  #qv-row2 .qv-pair--it-abdur_rahman { order: 13; }
  
  /* Forza a-capo sulla riga impostazioni (Layout + Font + Reciter) */
  #qv-row2 .qv-settings-line {
    order: 20;
    flex-basis: 100%;
    width: 100%;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
  }
  /* Dentro la riga impostazioni: niente a-capo dopo Layout */
  #qv-row2 .qv-block-layout { order: 1; margin-top: 0; }
  
  /* Seconda riga: Layout + Font Arabo + Reciter insieme */
  #qv-row2 .qv-block-font { order: 2; }
  /* Reciter sulla stessa riga di Layout e Font Arabo */
  #qv-row2 .qv-block-reciter { order: 3; }
  
  /* Mantieni le coppie sempre insieme */
  .qv-pair { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
  .qv-block-layout { display: inline-flex; align-items: center; gap: 6px; }
  .qv-block-font { display: inline-flex; align-items: center; gap: 6px; }
  .qv-block-reciter { display: inline-flex; align-items: center; gap: 6px; }
}

/* Mobile layout: due righe di traduzioni, poi Font, poi Reciter */
@media (max-width: 480px) {
  #qv-row2 { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 6px 10px; 
  }
  
  /* Nascondi layout su mobile */
  #qv-row2 .qv-block-layout { display: none !important; }
  
  /* Riga 1: Arabo + Traslitt. */
  #qv-row2 .qv-pair--ar { order: 10; }
  #qv-row2 .qv-pair--tr { order: 11; flex-basis: 100%; }
  
  /* Riga 2: due traduttori */
  #qv-row2 .qv-pair--it-hamza_piccardo { order: 20; }
  #qv-row2 .qv-pair--it-abdur_rahman { order: 21; flex-basis: 100%; }
  
  /* Riga 3: Font Arabo */
  #qv-row2 .qv-block-font { order: 30; flex-basis: 100%; }
  
  /* Riga 4: Reciter */
  #qv-row2 .qv-block-reciter { order: 31; flex-basis: 100%; }
  
  /* Mantieni le coppie sempre insieme su mobile */
  .qv-pair { display: inline-flex; align-items: center; gap: 4px; }
  .qv-block-font { display: inline-flex; align-items: center; gap: 4px; }
  .qv-block-reciter { display: inline-flex; align-items: center; gap: 4px; }
}

/* Header re-style (two rows) */
.qv-header { margin: 8px 0 4px; }
.qv-header .qv-header-block { text-align: center; margin: 8px 0; }
.qv-header .qv-header-chapter { margin: 0; color:#555; font-size: 0.95em; }
.qv-header .qv-header-title-ar { margin: 6px 0 0; font-weight: 600; }
.qv-header .qv-header-title-it { margin: 4px 0 0; font-weight: 600; }

.qv-meta span { margin-right: 12px; color: #555; font-size: 14px; }

.qv-verses-grid { margin-top: 10px; }
.qv-grid { display: grid; align-items: start; column-gap: 12px; row-gap: 8px; margin: 8px 0; }
.qv-head { font-weight: 600; color: #333; }
.qv-head .qv-cell { padding-bottom: 6px; border-bottom: 1px solid #e8e8e8; }
.qv-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e6f4ea; color: #1e7e34; font-size: 12px; font-weight: 600; }
.qv-row { padding: 6px 8px; border-radius: 4px; }
#top .quran-view .qv-row { scroll-margin-top: var(--qv-scroll-offset, 180px); }
#top .quran-view .qv-row:nth-child(odd)  { background: transparent !important; }
#top .quran-view .qv-row:nth-child(even) { background: transparent !important; }
#top .quran-view .qv-row.qv-row-active { background: #eaf9f1 !important; box-shadow: inset 0 0 0 2px rgba(86,197,119,0.35) !important; }
/* Ensure Arabic font family wins over theme selectors (driven by CSS var) */
#top .quran-view .qv-cell.lang-ar, #top .quran-view .lang-ar, #top .quran-view .qv-header-title-ar { font-family: var(--qv-font-ar, 'Amiri'), Arial, sans-serif !important; }
.qv-num { width: 48px; color: #555; font-weight: bold; align-self: start; }
.qv-play { border: 1px solid #cfd9d3; background:#fff; border-radius: 4px; padding: 0 6px; cursor: pointer; font-size: 12px; line-height: 20px; height: 22px; }
.qv-play:hover { background:#f2f7f4; }

/* Mini player */
.qv-player { position: fixed; bottom: calc(12px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #ffffff; border: 1px solid #dfe7e2; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,0.08); display: flex; align-items: center; gap: 8px; padding: 6px 12px; z-index: 2147483647; font-size: 14px; max-width: 95vw; flex-wrap: nowrap; overflow-x: auto; opacity: 1; visibility: visible; }
#top .qv-player { position: fixed !important; display: flex !important; z-index: 2147483647 !important; }
@media (max-width: 480px) {
  .qv-player { left: 8px; right: 8px; transform: none; border-radius: 12px; max-width: none; }
}
.qv-player .qv-btn { border: 1px solid #cfd9d3; background:#fff; border-radius: 999px; width: 28px; height: 28px; line-height: 26px; text-align: center; cursor: pointer; }
.qv-player .qv-btn:hover { background:#f2f7f4; }
.qv-player .qv-track { display:none; }
.qv-player .qv-reciter { display:none; }
#top .quran-view #qv-reciter-inline { font-size: 14px !important; padding: 2px 6px !important; height: auto !important; line-height: 1.2 !important; margin-bottom: 0 !important; }
#top .quran-view .qv-player #qv-start { font-size: 14px !important; }
#top .quran-view .qv-player .qv-select { vertical-align: middle !important; margin-bottom: 0 !important; line-height: 1.2 !important; }
.qv-player label { display: inline-flex !important; align-items: center !important; gap: 4px !important; white-space: nowrap !important; width: auto !important; margin: 0 !important; }
.qv-player .qv-select { vertical-align: middle !important; margin-bottom: 0 !important; line-height: 1.2 !important; }
#top .quran-view .qv-player #qv-start { max-width: none; font-size: 14px !important; }
/* Rounded selects style for mini-player */
#top .quran-view .qv-player select.qv-select { border-radius: 8px !important; border: 1px solid #cfd9d3 !important; background-color: #fff !important; box-shadow: inset 0 1px 2px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.03) !important; }

.qv-gear-btn { background: transparent !important; border: 0 !important; border-radius: 0 !important; width: auto !important; height: auto !important; padding: 0 !important; display: inline-flex !important; align-items: center !important; justify-content: center !important; cursor: pointer; box-shadow: none !important; position: relative; overflow: visible; color:#2f4f3f; }
.qv-gear-btn:hover { background: transparent; }
.qv-gear-btn .qv-icon { display:inline-block; vertical-align:middle; }
.qv-gear-btn .qv-tooltip { position:absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background:#2f4f3f; color:#fff; padding:4px 8px; border-radius:4px; white-space:nowrap; font-size:12px; opacity:0; visibility:hidden; transition:opacity .15s ease, visibility .15s ease; pointer-events:none; }
.qv-gear-btn:hover .qv-tooltip, .qv-gear-btn:focus .qv-tooltip { opacity:1; visibility:visible; }
.qv-player .qv-surah { color: #333; font-size: 13px; }
.qv-player .qv-pos { color: #666; font-size: 12px; margin-left: 6px; }

.qv-cell { line-height: 1.7; align-self: start; background: transparent; font-family: 'Raleway', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; }
/* Arabic text: use CSS var for primary font */
#top .quran-view .lang-ar { font-family: var(--qv-font-ar, 'Amiri'), Arial, sans-serif !important; font-size: clamp(12px, var(--fs-ar, 40px), 64px) !important; line-height: 1.9; }
.lang-tr { color: #333; font-size: clamp(12px, var(--fs-tr, 23px), 64px); }
.lang-it { color: #222; font-size: clamp(12px, var(--fs-it, 16px), 64px); }
.lang-it-hamza_piccardo { font-size: clamp(12px, var(--fs-it-hamza_piccardo, var(--fs-it, 22px)), 64px) !important; }
.lang-it-abdur_rahman { font-size: clamp(12px, var(--fs-it-abdur_rahman, var(--fs-it, 21px)), 64px) !important; }
.lang-it-zilio_grandi { font-size: clamp(12px, var(--fs-it-zilio_grandi, var(--fs-it, 21px)), 64px) !important; }

/* Layout toggle: when stacked, force single column per row on desktop */
.qv-stack .qv-grid { grid-template-columns: 1fr !important; }
.qv-stack .qv-num { width: auto; font-weight: 700; }
.qv-stack .lang-ar { order: 1; }
.qv-stack .lang-tr { order: 2; }
.qv-stack .lang-it { order: 3; }
/* In stack ("orizzontale"), mostra prima Piccardo poi Pasquini */
.qv-stack .lang-it-hamza_piccardo { order: 3; }
.qv-stack .lang-it-abdur_rahman { order: 4; }

.qv-note-ref { color: #225d2a; cursor: pointer; margin-left: 4px; }
.qv-note-ref:hover { text-decoration: underline; }
.qv-notes-panel { margin-top: 24px; border-top: 1px solid #eee; padding-top: 10px; }
.qv-translator { color: #777; font-size: 0.82em; font-weight: 600; }

.qv-modal { position: fixed; inset: 0; display: none; align-items: center !important; justify-content: center !important; z-index: 99999; }
.qv-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); z-index: 1; }
.qv-modal-dialog { position: relative; background: #fff; padding: 18px; border-radius: 6px; width: min(900px, 92vw); max-height: 80vh; overflow: auto; z-index: 2; margin: 20px 12px 0 12px; }
.qv-modal-body { max-height: 70vh; overflow: auto; }
.qv-modal-close { position: absolute; top: 8px; right: 12px; background: transparent; border: 0; font-size: 22px; cursor: pointer; }
.qv-ayah-anchor { color: inherit; text-decoration: none; }
.qv-ayah-anchor:hover { text-decoration: underline; }
.qv-row-highlight { outline: 2px solid #8fd19e; outline-offset: 2px; border-radius: 4px; transition: outline-color .4s ease; }

/* Collapsed toolbar: only hide the second row */
#qv-row2.qv-collapsed { display: none !important; }

/* Explicit rule as requested for mini-player select */
select#qv-reciter-inline { margin-bottom: 0; font-size: 14px !important; }

/* Note panel: reduce strong size to 16px as requested */
#top .quran-view .qv-notes-panel strong { font-size: 16px !important; }

#top .quran-view sup.qv-note-ref { scroll-margin-top: var(--qv-scroll-offset, 180px); }
#top .quran-view [id^="ref-"] { scroll-margin-top: var(--qv-scroll-offset, 180px); }
#top .quran-view [id^="note-"] { scroll-margin-top: var(--qv-scroll-offset, 180px); }
#top .quran-view .qv-modal { z-index: 2147483647 !important; }
#top .quran-view .qv-modal-backdrop { z-index: 2147483646 !important; }
#top .quran-view .qv-modal-dialog { z-index: 2147483647 !important; }

.qv-title-notes { margin-top: 6px; text-align: center; font-size: 0.9em; }
.qv-title-notes .qv-note-ref { color: #225d2a; cursor: pointer; margin-left: 6px; }
.qv-title-notes .qv-note-ref:first-child { margin-left: 0; }

#top .qv-player { flex-wrap: nowrap !important; overflow-x: auto !important; }
#top .qv-player label { display: inline-flex !important; align-items: center !important; white-space: nowrap !important; gap: 4px !important; margin: 0 0 0 6px !important; }
#top .qv-player label > select { display: inline-block !important; }
