/* =====================================================================
   app.css — Bootstrap JS compatibility layer + custom utilities.
   Bootstrap JS (bundle) is kept for modal/dropdown/offcanvas/tooltip
   behaviour, but Bootstrap CSS is removed. This file provides the
   minimal structural CSS those JS components need to function.
   Visual styling comes from Tailwind classes in the views.
   ===================================================================== */

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1055;
  display: none;
  overflow: hidden auto;
  outline: 0;
}
.modal.show { display: block; }
.modal.fade .modal-dialog {
  transform: translateY(-20px);
  transition: transform 0.2s ease-out;
}
.modal.show .modal-dialog { transform: none; }
.modal-dialog {
  position: relative;
  width: auto;
  margin: 0.5rem;
  pointer-events: none;
  max-width: 100%;
}
.modal-dialog-centered {
  display: flex;
  align-items: center;
  min-height: calc(100% - 1rem);
}
.modal-dialog-scrollable {
  height: calc(100% - 1rem);
}
.modal-dialog-scrollable .modal-content {
  max-height: 100%;
  overflow: hidden;
}
.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1050;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}
.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.show { opacity: 1; }
.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  pointer-events: auto;
}
@media (min-width: 576px) {
  .modal-dialog { max-width: 500px; margin: 1.75rem auto; }
  .modal-dialog-centered { min-height: calc(100% - 3.5rem); }
  .modal-dialog-scrollable { height: calc(100% - 3.5rem); }
}
@media (min-width: 992px) {
  .modal-lg .modal-dialog, .modal-xl .modal-dialog { max-width: 800px; }
}

/* ---- Dropdown ---- */
.dropdown-menu {
  position: absolute;
  z-index: 1000;
  display: none;
  min-width: 12rem;
  padding: 0.25rem;
  margin: 0;
}
.dropdown-menu[data-bs-popper] {
  top: 100%;
  left: 0;
  margin-top: 0.125rem;
}
.dropdown-menu.show { display: block; }
.dropdown-menu-end[data-bs-popper] {
  left: auto;
  right: 0;
}

/* ---- Offcanvas ---- */
.offcanvas {
  position: fixed;
  bottom: 0;
  z-index: 1045;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  visibility: hidden;
  outline: 0;
  transition: transform 0.3s ease-in-out, visibility 0.3s ease-in-out;
}
.offcanvas.show { visibility: visible; }
.offcanvas-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background-color: rgba(0, 0, 0, 0.5);
}
.offcanvas-backdrop.show { opacity: 1; }
.offcanvas-start {
  top: 0;
  left: 0;
  width: 400px;
  max-width: 85vw;
  transform: translateX(-100%);
  border-right: 1px solid rgba(0,0,0,0.1);
}
.offcanvas-start.show { transform: none; }
[dir="rtl"] .offcanvas-start {
  left: auto;
  right: 0;
  transform: translateX(100%);
  border-right: none;
  border-left: 1px solid rgba(0,0,0,0.1);
}
[dir="rtl"] .offcanvas-start.show { transform: none; }

/* ---- Collapse ---- */
.collapse:not(.show) { display: none; }
.collapsing {
  height: 0;
  overflow: hidden;
  transition: height 0.35s ease;
}

/* ---- Bootstrap display utilities (used by JS toggles & shared common partials) ---- */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
@media (min-width: 576px) {
  .d-sm-none { display: none !important; }
  .d-sm-block { display: block !important; }
  .d-sm-inline { display: inline !important; }
  .d-sm-flex { display: flex !important; }
}
@media (min-width: 768px) {
  .d-md-none { display: none !important; }
  .d-md-block { display: block !important; }
  .d-md-inline { display: inline !important; }
  .d-md-inline-block { display: inline-block !important; }
  .d-md-flex { display: flex !important; }
}
@media (min-width: 992px) {
  .d-lg-none { display: none !important; }
  .d-lg-block { display: block !important; }
  .d-lg-inline { display: inline !important; }
  .d-lg-flex { display: flex !important; }
}

/* ---- Tab content (Bootstrap JS tab plugin hides inactive panes) ---- */
.tab-content > .tab-pane { display: none; }
.tab-content > .tab-pane.active { display: block; }

/* ---- Form validation feedback (Bootstrap JS .needs-validation triggers .was-validated) ---- */
.invalid-feedback { display: none; }
.was-validated .invalid-feedback,
.invalid-feedback.d-block { display: block; }
.was-validated .form-control:invalid,
.was-validated input:invalid:not([type="checkbox"]),
.was-validated textarea:invalid {
  border-color: #f43f5e;
}

/* ---- Category block tabs (active state styled via .active class, toggled by Bootstrap JS) ---- */
.nav-category-block .nav-link.active {
  background-color: #f43f5e !important;
  color: #fff !important;
}
.nav-category-block .nav-link.active:hover {
  background-color: #e11d48 !important;
}

/* ---- Tooltip (minimal, styling via Tailwind in data-bs-original-title) ---- */
.tooltip {
  position: absolute;
  z-index: 1080;
  display: block;
  margin: 0;
  font-size: 0.75rem;
  word-wrap: break-word;
  opacity: 0;
}
.tooltip.show { opacity: 0.95; }
.tooltip-inner {
  max-width: 200px;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  background: #1e293b;
  color: #fff;
  text-align: center;
}
.dark .tooltip-inner { background: #f1f5f9; color: #0f172a; }
.tooltip .tooltip-arrow { position: absolute; display: block; width: 0.5rem; height: 0.5rem; }

/* ---- Spinner (Bootstrap JS uses .spinner-border) ---- */
.spinner-border {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  vertical-align: text-bottom;
  border: 0.15em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner-border 0.75s linear infinite;
}
.spinner-border-sm { width: 0.875rem; height: 0.875rem; }
@keyframes spinner-border { to { transform: rotate(360deg); } }

/* ---- Ratio (used by some partials) ---- */
.ratio { position: relative; width: 100%; }
.ratio::before { display: block; content: ""; }
.ratio-16x9::before { padding-top: 56.25%; }
.ratio-4x3::before { padding-top: 75%; }
.ratio-1x1::before { padding-top: 100%; }
.ratio > * { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---- Visually hidden (sr-only) ---- */
.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---- Feed-specific: snap scroll (hard to do purely with Tailwind) ---- */
.vf-snap-feed {
  scroll-snap-type: y proximity;
}
.vf-snap-card {
  scroll-snap-align: start;
}

/* ---- Follow button state toggle (data-following attribute) ---- */
[data-vf-follow][data-following="1"] {
  background: transparent !important;
  border-color: rgba(255,255,255,0.35) !important;
}
[data-vf-follow][data-following="0"] {
  background: rgba(255,255,255,0.15) !important;
  border-color: rgba(255,255,255,0.6) !important;
}
[data-vf-follow][data-following="0"]:hover {
  background: rgba(255,255,255,0.25) !important;
}

/* ---- Utility: truncate to N lines ---- */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.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; }

/* ---- Print ---- */
@media print {
  .no-print { display: none !important; }
}

/* ── Fixed sidebar (desktop only) ────────────────────────────────── */
.vf-main-wrapper {
    display: flex;
    flex-direction: row;
    min-height: calc(100vh - 56px);
}

.vf-main-content {
    flex: 1;
    min-width: 0;
}

[data-bs-theme="dark"] .vf-fixed-sidebar,
.dark .vf-fixed-sidebar {
    background: rgba(15, 23, 42, 0.8);
}
.vf-fixed-sidebar::-webkit-scrollbar { width: 4px; }
.vf-fixed-sidebar::-webkit-scrollbar-thumb { background: rgba(120,120,120,.3); border-radius: 2px; }
.vf-fixed-sidebar::-webkit-scrollbar-track { background: transparent; }

.vf-sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vf-sidebar-block {
    background: transparent;
    border: none;
    padding: 0;
}

.vf-welcome-block {
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.6);
}
[data-bs-theme="dark"] .vf-welcome-block,
.dark .vf-welcome-block {
    background: rgba(30, 41, 59, 0.6);
}

@media (max-width: 991.98px) {
    .vf-main-wrapper { flex-direction: column; }
    .vf-fixed-sidebar { display: none !important; }
    .vf-main-content { width: 100%; }
}

/* ── Page layout: sidebar + main area ─────────────────────────────── */
.vf-page-layout {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}
.vf-page-layout:not(.has-sidebar) {
    flex-direction: column;
}

/* Sidebar: OPPOSITE side from search (rendered first in HTML).
   LTR: sidebar LEFT, search RIGHT.
   RTL: flex auto-reverses → sidebar RIGHT, search LEFT. */
.vf-page-layout .vf-fixed-sidebar {
    
    width: 300px;
    flex-shrink: 0;
    position: fixed;
    top: 15px;
    margin:0 15px;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    /* Same background as flipbook content page */
    background: var(--vf-paper);
    border: none;
    scrollbar-width: thin;
    scrollbar-color: rgba(120,120,120,.3) transparent;
    z-index: 30;
}
[data-bs-theme="dark"] .vf-page-layout .vf-fixed-sidebar,
.dark .vf-page-layout .vf-fixed-sidebar {
    background: var(--vf-paper-dark, #0f172a);
}
.vf-page-layout .vf-fixed-sidebar::-webkit-scrollbar { width: 4px; }
.vf-page-layout .vf-fixed-sidebar::-webkit-scrollbar-thumb { background: rgba(120,120,120,.3); border-radius: 2px; }

/* Main area: topbar + content + footer */
.vf-page-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Mobile: hide sidebar, full width main */
@media (max-width: 991.98px) {
    .vf-page-layout { flex-direction: column !important; }
    .vf-page-layout .vf-fixed-sidebar { display: none !important; }
    .vf-page-main { width: 100%; }
}

/* ── Sidebar block styling (white/dark bg + spacing) ──────────────── */
.vf-sidebar-inner {
    gap: 16px; /* margin between blocks */
}

.vf-sidebar-block {
    background: #ffffff;
    border-radius: 12px;
    padding: 14px;
}
[data-bs-theme="dark"] .vf-sidebar-block,
.dark .vf-sidebar-block {
    background: #1e293b;
}

/* Welcome block already has its own bg — keep it */
.vf-welcome-block {
    padding: 14px;
    border-radius: 12px;
    background: #ffffff;
}
[data-bs-theme="dark"] .vf-welcome-block,
.dark .vf-welcome-block {
    background: #1e293b;
}

/* Block title */
.vf-sidebar-block-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 0 2px 12px; /* padding between title and items */
}

/* Featured posts list */
.vf-featured-list {
    display: flex;
    flex-direction: column;
    gap: 12px; /* spacing between items */
}
.vf-featured-item {
    display: block;
    padding: 10px;
    border-radius: 10px;
    background: rgba(248, 250, 252, 0.8);
    transition: background 0.2s;
    text-decoration: none;
}
.vf-featured-item:hover {
    background: rgba(241, 245, 249, 1);
}
[data-bs-theme="dark"] .vf-featured-item,
.dark .vf-featured-item {
    background: rgba(15, 23, 42, 0.5);
}
[data-bs-theme="dark"] .vf-featured-item:hover,
.dark .vf-featured-item:hover {
    background: rgba(15, 23, 42, 0.8);
}
