/*
 * Ad detail page (resources/views/frontend/ad_detail.blade.php).
 * Scoped under .sga so the site header and footer are untouched.
 * Phones < 768px follow the mobile design; 768px+ uses cards;
 * 992px+ adds the right-hand column.
 */
.sga {
    --text: #12161C; --text-2: #3A424D; --muted: #5B6470; --border: #E3E7EC; --border-2: #C3CBD4;
    --bg: #F4F6F8; --green: #157A2C; --green-bg: #E8F7EC; --blue: #0070C0; --link: #0062A8; --blue-bg: #E6F1FA;
    --danger: #B42318; --photo: #E9EDF1;
    background: var(--bg); color: var(--text);
    font: 400 15px/1.5 Poppins, system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    padding-top: var(--sga-top, 64px);
}
.sga *, .sga *::before, .sga *::after { box-sizing: border-box; }
.sga h1, .sga h2, .sga p, .sga ul, .sga dl, .sga dd { margin: 0; padding: 0; list-style: none; }
.sga h1, .sga h2 { font-family: inherit; color: var(--text); letter-spacing: 0; text-transform: none; }
.sga h2 { font-size: 17px; font-weight: 700; line-height: 1.3; }
.sga a { color: var(--link); text-decoration: none; }
.sga a:hover { text-decoration: underline; }
.sga button { font-family: inherit; cursor: pointer; }
.sga img { display: block; max-width: 100%; }
.sga [hidden] { display: none !important; }
.sga .i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sga .i-sm { width: 18px; height: 18px; }
.sga .i-xl { width: 56px; height: 56px; }
.sga .sga-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.sga a:focus-visible, .sga button:focus-visible, .sga input:focus-visible, .sga select:focus-visible,
.sga textarea:focus-visible, .sga summary:focus-visible, .sga [tabindex]:focus-visible { outline: 3px solid #4DA3E0; outline-offset: 2px; }

.sga-card { background: #fff; border-radius: 16px; padding: 16px; }
.sga-row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sga-note { font-size: 12px; line-height: 1.5; color: var(--muted); }
.sga-link { font-size: 14px; font-weight: 600; flex: none; }
.sga-review { background: #FEF3C7; color: #92400E; border-radius: 12px; padding: 12px 16px; font-size: 14px; }

/* Buttons */
.sga-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 16px;
    border-radius: 12px; border: 1.5px solid transparent; font-size: 15px; font-weight: 600; line-height: 1.2; text-align: center;
    background: #fff; color: var(--text); white-space: nowrap;
}
.sga a.sga-btn:hover { text-decoration: none; }
.sga-btn.is-green { background: var(--green); color: #fff; }
.sga-btn.is-green:hover { background: #11662A; color: #fff; }
.sga-btn.is-blue { background: var(--blue); color: #fff; }
.sga-btn.is-blue:hover { background: #005A9C; color: #fff; }
.sga-btn.is-ghost { border-color: var(--border-2); color: var(--text); }
.sga-btn.is-ghost:hover { background: #F7F9FA; }
.sga-btn.is-outline-green { border-color: var(--green); color: var(--green); }
.sga-btn.is-danger { background: var(--danger); color: #fff; }
.sga-btn:disabled { opacity: .6; cursor: default; }

/* Breadcrumbs */
.sga-crumbs { display: none; }
.sga-mcrumbs { font-size: 12px; color: var(--muted); }

/* Layout: on phones the two columns melt into one list, ordered like the design. */
.sga-layout { display: flex; flex-direction: column; gap: 12px; }
.sga-main, .sga-side { display: contents; }
.sga-gallery { order: 1; } .sga-head { order: 2; } .sga-review { order: 3; } .sga-quick { order: 4; } .sga-contact { order: 5; }
.sga-offer { order: 6; } .sga-details { order: 7; } .sga-owner { order: 8; } .sga-seller { order: 9; } .sga-safety { order: 10; }
.sga-more { order: 11; } .sga-foot { order: 12; }

/* Gallery */
.sga-gallery { padding: 0; border-radius: 0; background: transparent; }
.sga-stage { position: relative; background: var(--photo); }
.sga-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.sga-track::-webkit-scrollbar { display: none; }
.sga-slide { flex: 0 0 100%; scroll-snap-align: center; scroll-snap-stop: always; }
.sga-zoom { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.sga-slide img { width: 100%; height: 300px; object-fit: contain; }
.sga-nophoto { height: 220px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 13px; }
.sga-ov {
    position: absolute; z-index: 2; width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
    background: rgba(255, 255, 255, .95); color: var(--text); display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}
.sga a.sga-ov:hover { text-decoration: none; }
.sga-back { left: 12px; top: 12px; }
.sga-ov-group { position: absolute; right: 12px; top: 12px; z-index: 2; display: flex; gap: 8px; }
.sga-ov-group .sga-ov { position: static; }
.sga-ov-group .i { width: 20px; height: 20px; }
.sga-save[aria-pressed="true"] { color: #D92D20; }
.sga-save[aria-pressed="true"] .i { fill: currentColor; }
.sga-prev, .sga-next { top: 50%; margin-top: -20px; display: none; }
.sga-prev { left: 12px; } .sga-next { right: 12px; }
.sga-count { position: absolute; right: 12px; bottom: 26px; z-index: 2; background: rgba(18, 22, 28, .75); color: #fff; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 12px; }
.sga-hint { display: none; }
.sga-dots { position: absolute; left: 0; right: 0; bottom: 30px; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.sga-dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .6); transition: width .2s; }
.sga-dots span.is-on { width: 18px; background: #fff; }
.sga-thumbs { display: none; }

/* Title card (overlaps the photo on phones) */
.sga-head { margin: -16px 12px 0; position: relative; z-index: 3; border-radius: 20px 20px 16px 16px; }
.sga-head h1 { margin: 6px 0 4px; font-size: 22px; line-height: 1.25; font-weight: 700; overflow-wrap: anywhere; }
.sga-head-actions { display: none; }
.sga-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sga-badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 10px; }
.sga-badge.is-green { color: var(--green); background: var(--green-bg); }
.sga-badge.is-blue { color: var(--link); background: var(--blue-bg); }
.sga-badge.is-amber { color: #92400E; background: #FEF3C7; }
.sga-price { font-size: 22px; font-weight: 700; color: var(--text); }
.sga-price small { margin-left: 6px; font-size: 13px; font-weight: 600; color: var(--green); }
.sga-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.sga-meta span { display: inline-flex; align-items: center; gap: 4px; }
.sga-meta .i { width: 15px; height: 15px; }

/* Quick contact row (phones) */
.sga-quick { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin: 0 12px; }
.sga-quick > * {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 14px;
    background: #fff; border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text);
}
.sga-quick a:hover { text-decoration: none; color: var(--text); }
.sga-quick > * > span { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.sga-quick .is-green { background: var(--green-bg); color: var(--green); }
.sga-quick .is-blue { background: var(--blue-bg); color: var(--blue); }

/* Cards inside the column on phones get side margins */
.sga-offer, .sga-details, .sga-owner, .sga-seller, .sga-safety, .sga-contact, .sga-review, .sga-more, .sga-foot { margin: 0 12px; }
.sga-contact { display: none; }

/* Offer */
.sga-offer label { display: block; font-size: 13px; font-weight: 500; margin: 12px 0 6px; }
.sga-offer-row { display: flex; gap: 8px; }
.sga-offer-row .sga-btn { width: auto; flex: none; min-height: 50px; }
.sga-money { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 50px; border: 1.5px solid var(--border-2); border-radius: 12px; padding: 0 12px; }
.sga-money:focus-within { border-color: var(--blue); }
.sga-money span { font-weight: 600; color: var(--muted); }
.sga-money input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 600 17px Poppins, system-ui, sans-serif; color: var(--text); -moz-appearance: textfield; }
.sga-money input::-webkit-outer-spin-button, .sga-money input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.sga-offer .sga-note { margin-top: 8px; }

/* Details */
.sga-details h2 { margin-bottom: 10px; }
.sga-desc { font-size: 15px; line-height: 1.65; color: var(--text-2); overflow-wrap: anywhere; }
.sga-desc p + p, .sga-desc ul, .sga-desc ol { margin-top: 8px; }
.sga-desc ul, .sga-desc ol { padding-left: 20px; list-style: disc; }
.sga-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.sga-specs div { background: #F7F9FA; border-radius: 12px; padding: 10px 12px; min-width: 0; }
.sga-specs dt { font-size: 12px; font-weight: 500; color: var(--muted); }
.sga-specs dd { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

/* Owner */
.sga-owner { display: flex; flex-direction: column; gap: 8px; }

/* Seller */
.sga-seller { display: flex; align-items: center; gap: 12px; }
.sga-avatar { width: 52px; height: 52px; border-radius: 50%; flex: none; object-fit: cover; background: #0B3F7A; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.sga-seller-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sga-seller-text b { font-size: 15px; font-weight: 600; }
.sga-seller-text span { font-size: 12px; color: var(--muted); }

/* Safety */
.sga-safety { background: #FFF8E6; border: 1px solid #F5E2B0; color: #5C4400; }
.sga-safety summary { display: flex; align-items: center; gap: 8px; min-height: 24px; font-size: 15px; font-weight: 600; cursor: pointer; }
.sga-safety ul { margin-top: 10px; padding-left: 18px; list-style: disc; font-size: 13px; line-height: 1.6; }

/* Extra actions */
.sga-more { display: flex; flex-wrap: wrap; gap: 8px; }
.sga-more > * { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 13px; font-weight: 600; }
.sga-more a:hover { text-decoration: none; color: var(--text); background: #F7F9FA; }

.sga-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); padding-bottom: 8px; }
.sga-report { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; border: 0; background: none; padding: 0; color: var(--danger) !important; font-size: 13px; font-weight: 600; }

/* Similar ads: a swipe row on phones */
.sga-similar { margin: 20px 0 0; padding: 0 12px; }
.sga-similar .sga-row-between { margin: 0 4px 10px; }
.sga-sim-list { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding-bottom: 4px; }
.sga-sim-list::-webkit-scrollbar { display: none; }
.sga-sim { position: relative; flex: 0 0 150px; scroll-snap-align: start; background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.sga-sim-ph { aspect-ratio: 4 / 3; background: var(--photo); }
.sga-sim-ph img { width: 100%; height: 100%; object-fit: cover; }
.sga-sim-body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sga-sim-price { font-size: 14px; font-weight: 700; }
.sga-sim a { font-size: 13px; font-weight: 500; line-height: 1.3; height: 34px; overflow: hidden; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sga-sim a::after { content: ""; position: absolute; inset: 0; }
.sga-sim-meta { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sga-popular { margin: 20px 12px 0; }
.sga-popular h2 { font-size: 15px; margin-bottom: 8px; }
.sga-popular ul { display: flex; flex-wrap: wrap; gap: 8px; }
.sga-popular a { display: inline-block; padding: 6px 12px; border-radius: 16px; background: #fff; border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }

/* Contact bar (phones). The bottom menu is hidden on this page. */
.sga-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; display: flex; gap: 8px;
    background: #fff; border-top: 1px solid var(--border); padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.sga-bar .sga-btn { flex: 1 1 0; min-width: 0; padding: 0 8px; font-size: 14px; }
.sga-bar .sga-bar-main { flex-grow: 1.4; }
.sga:not(.has-bar) { padding-bottom: 24px; }
@media (max-width: 767px) {
    body:has(.sga.has-bar) #sg-bnav, body:has(.sga.has-bar) .sg-install { display: none !important; }
    body:has(.sga.has-bar) { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* Dialogs */
.sga-dialog { width: min(480px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: 16px; color: var(--text); font: 400 15px/1.5 Poppins, system-ui, sans-serif; }
.sga-dialog::backdrop { background: rgba(18, 22, 28, .55); }
.sga-dialog form { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.sga-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sga-dialog label { font-size: 13px; font-weight: 500; margin: 0; }
.sga-dialog textarea, .sga-dialog select { width: 100%; border: 1.5px solid var(--border-2); border-radius: 12px; padding: 10px 12px; font: 400 16px/1.5 Poppins, system-ui, sans-serif; color: var(--text); background: #fff; }
.sga-dialog select { height: 48px; }
.sga-dialog textarea { height: auto; min-height: 112px; resize: vertical; }
.sga-dialog .sga-note { text-align: center; }
.sga-x { width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: #F1F3F5; color: var(--text); display: flex; align-items: center; justify-content: center; padding: 0; }
.sga-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.sga-chips button { flex: none; min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--green); background: #fff; color: var(--green); font-size: 13px; font-weight: 500; }
@media (max-width: 767px) {
    /* Bottom sheet on phones */
    .sga-dialog { width: 100%; max-width: none; margin: auto 0 0; border-radius: 20px 20px 0 0; }
    .sga-dialog form { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

/* Photo viewer */
.sga-lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #0B0D10; }
.sga-lightbox::backdrop { background: #0B0D10; }
.sga-lb-track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.sga-lb-track::-webkit-scrollbar { display: none; }
.sga-lb-track li { flex: 0 0 100%; height: 100%; scroll-snap-align: center; display: flex; align-items: center; justify-content: center; padding: 56px 8px; }
.sga-lb-track img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sga-lightbox .sga-x { position: fixed; top: 12px; right: 12px; z-index: 2; background: rgba(255, 255, 255, .9); }

.sga-toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 1100; background: #12161C; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }

/* ---------- Tablet and desktop ---------- */
@media (min-width: 768px) {
    .sga { padding: calc(var(--sga-top, 70px) + 18px) 24px 48px; }
    .sga > * { max-width: 1240px; margin-left: auto; margin-right: auto; }
    .sga-crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
    .sga-mcrumbs, .sga-quick, .sga-bar, .sga-back, .sga-ov-group, .sga-dots { display: none !important; }
    .sga-layout { gap: 16px; }
    .sga-card { border: 1px solid var(--border); padding: 20px; }
    .sga-offer, .sga-details, .sga-owner, .sga-seller, .sga-safety, .sga-contact, .sga-review, .sga-more, .sga-foot, .sga-head, .sga-similar, .sga-popular { margin-left: 0; margin-right: 0; }
    .sga-similar, .sga-popular { padding: 0; }

    .sga-gallery { padding: 12px; background: #fff; border-radius: 16px; }
    .sga-stage { border-radius: 12px; overflow: hidden; }
    .sga-slide img { height: auto; aspect-ratio: 16 / 10; }
    .sga-prev, .sga-next { display: flex; width: 44px; height: 44px; margin-top: -22px; }
    .sga-count { bottom: 14px; right: 14px; font-size: 13px; padding: 4px 12px; }
    .sga-hint { display: inline; }
    .sga-thumbs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
    .sga-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--photo); aspect-ratio: 4 / 3; }
    .sga-thumbs button[aria-current="true"] { border-color: var(--green); }
    .sga-thumbs img { width: 100%; height: 100%; object-fit: cover; }

    .sga-head { border-radius: 16px; }
    .sga-head-row { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
    .sga-head-text { min-width: 0; }
    .sga-badges { margin: 0 0 8px; }
    .sga-head h1 { font-size: 28px; line-height: 1.2; margin: 0 0 6px; }
    .sga-price { font-size: 26px; }
    .sga-meta { font-size: 14px; }
    .sga-head-actions { display: flex; gap: 8px; flex: none; }
    .sga-head-actions .sga-btn { width: auto; min-height: 44px; padding: 0 14px; font-size: 14px; border-color: #D5DBE2; border-radius: 10px; }

    .sga-contact { display: flex; flex-direction: column; gap: 10px; }
    .sga-contact h2 { margin-bottom: 4px; }
    .sga-contact .sga-note { text-align: center; }
    .sga-details h2 { font-size: 18px; margin-bottom: 12px; }
    .sga-desc { font-size: 16px; max-width: 70ch; }
    .sga-specs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sga-similar { margin-top: 32px; }
    .sga-similar h2 { font-size: 22px; }
    .sga-similar .sga-row-between { margin: 0 0 12px; }
    .sga-sim-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; overflow: visible; }
    .sga-sim { border-radius: 14px; }
    .sga-sim-body { padding: 12px 14px 14px; }
    .sga-sim a { font-size: 15px; height: 40px; }
    .sga-sim-price { font-size: 16px; }
    .sga-popular { margin-top: 24px; }
    .sga-toast { bottom: 32px; }
}
@media (min-width: 992px) {
    .sga-layout { flex-direction: row; align-items: flex-start; gap: 24px; }
    .sga-main, .sga-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
    .sga-main { flex: 1 1 auto; }
    .sga-side { flex: 0 0 340px; }
}
@media (min-width: 1200px) {
    .sga-side { flex-basis: 360px; }
}
@media (prefers-reduced-motion: reduce) {
    .sga-track, .sga-lb-track { scroll-behavior: auto; }
    .sga-dots span { transition: none; }
}
