/* ═══════════════════════════════════════════
   Qibla Finder — Full-screen map + panel
   Theme variables are now in css/theme.css
   ═══════════════════════════════════════════ */

/* ─── Base ─── */
.qibla-page {
    overflow: hidden;
    height: 100dvh;
    background: #080c18;
    transition: background 0.4s;
}

/* Header/sidebar theme overrides are now in css/theme.css */

/* Hide the shared footer on this page — location is handled inline */
.qibla-page #site-footer {
    display: none !important;
}

/* ─── Mapbox map fills the viewport ─── */
#qibla-map {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* Token / load error overlay */
.qibla-map-error {
    position: fixed;
    inset: 0;
    z-index: 2;
    background: #080c18;
    display: flex;
    align-items: center;
    justify-content: center;
}
.qibla-map-error-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    color: rgba(255, 255, 255, 0.45);
    padding: 32px;
    max-width: 320px;
}
.qibla-map-error-inner svg {
    opacity: 0.4;
}
.qibla-map-error-inner p {
    font-size: 14px;
    line-height: 1.6;
}
.qibla-map-error-inner code {
    font-family: monospace;
    font-size: 12px;
    background: rgba(255,255,255,0.07);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Position Mapbox controls so they don't overlap the rail sidebar */
.qibla-page .mapboxgl-ctrl-bottom-right {
    right: 96px;
    bottom: 24px;
}
.qibla-page .mapboxgl-ctrl-bottom-left {
    left: 352px;
    bottom: 24px;
    transition: left 0.3s;
}
.qibla-page .mapboxgl-ctrl-attrib {
    background: rgba(5, 8, 18, 0.6);
    color: rgba(255, 255, 255, 0.35);
    border-radius: 6px;
}
.qibla-page .mapboxgl-ctrl-attrib a {
    color: rgba(255, 255, 255, 0.45);
}

/* ═══════════════════════════════════════════
   CONTROL PANEL
   ═══════════════════════════════════════════ */
.qibla-panel {
    position: fixed;
    top: calc(64px + 14px);       /* below header */
    left: 14px;
    width: 310px;
    z-index: 20;
    background: var(--qb-panel-glass);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--qb-border);
    border-radius: 22px;
    box-shadow: var(--qb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100dvh - 64px - 28px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--qb-scroll) transparent;
    transition: background 0.35s, border-color 0.35s, box-shadow 0.35s;
}
.qibla-panel::-webkit-scrollbar { width: 3px; }
.qibla-panel::-webkit-scrollbar-track { background: transparent; }
.qibla-panel::-webkit-scrollbar-thumb { background: var(--qb-scroll); border-radius: 10px; }

/* ─── Panel Header ─── */
.qp-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--qb-border);
    flex-shrink: 0;
    transition: border-color 0.35s;
}

.qp-icon {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--qb-accent);
    flex-shrink: 0;
    transition: color 0.35s;
}

.qp-title-wrap {
    flex: 1;
    min-width: 0;
}
.qp-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--qb-text);
    letter-spacing: 0.2px;
    margin: 0;
    line-height: 1.2;
    transition: color 0.35s;
}
.qp-location-name {
    font-size: 11px;
    color: var(--qb-text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.2px;
    margin: 3px 0 0;
    line-height: 1;
    transition: color 0.35s;
}

.qp-close-btn {
    width: 30px;
    height: 30px;
    display: none;         /* visible only on mobile */
    align-items: center;
    justify-content: center;
    background: var(--qb-input-bg);
    border: 1px solid var(--qb-border);
    border-radius: 9px;
    color: var(--qb-text-dim);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}
.qp-close-btn:hover {
    background: var(--qb-hover);
    color: var(--qb-text);
}

/* ═══════════════════════════════════════════
   COMPASS
   ═══════════════════════════════════════════ */
.qp-compass-section {
    padding: 22px 18px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.qp-compass {
    position: relative;
    width: 196px;
    height: 196px;
    flex-shrink: 0;
}

/* SVG background dial */
.qp-compass-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    color: var(--qb-text);
}

/* Needle wrapper (full-size overlay, rotates) */
.qp-needle {
    position: absolute;
    inset: 0;
    transition: transform 1.15s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform;
    pointer-events: none;
}

/* Inner: column layout, centered on pivot point */
.qp-needle-inner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 168px;
    width: 30px;
}

/* Head — Kaaba icon, points toward Qibla */
.qp-needle-head {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.14);
    border: 1.5px solid rgba(245, 158, 11, 0.55);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f59e0b;
    flex-shrink: 0;
    z-index: 2;
}

/* Shaft — gradient line from tip to tail */
.qp-needle-shaft {
    flex: 1;
    width: 2px;
    background: linear-gradient(
        to bottom,
        rgba(245, 158, 11, 0.75) 0%,
        rgba(245, 158, 11, 0.25) 65%,
        transparent 100%
    );
    border-radius: 1px;
}

/* Tail dot */
.qp-needle-tail {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    flex-shrink: 0;
}

/* Center pivot dot */
.qp-compass-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    border: 2px solid rgba(255, 255, 255, 0.25);
    z-index: 5;
}

/* Label below compass: "N — X° from North" */
.qp-compass-label {
    font-size: 11px;
    color: var(--qb-text-dimmer);
    letter-spacing: 0.3px;
    text-align: center;
    margin: 0;
    transition: color 0.35s;
}

/* ═══════════════════════════════════════════
   BEARING + DISTANCE ROW
   ═══════════════════════════════════════════ */
.qp-info-row {
    display: flex;
    align-items: stretch;
    padding: 0 18px 18px;
    gap: 0;
    flex-shrink: 0;
}

.qp-info-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    text-align: center;
}

.qp-info-divider {
    width: 1px;
    background: var(--qb-border);
    margin: 0 6px;
    align-self: stretch;
    transition: background 0.35s;
}

.qp-info-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--qb-text-dimmer);
    transition: color 0.35s;
}

.qp-info-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--qb-text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    line-height: 1.1;
    transition: color 0.35s;
}

/* ═══════════════════════════════════════════
   SEARCH + LOCATE
   ═══════════════════════════════════════════ */
.qp-search-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px 14px;
    flex-shrink: 0;
    border-top: 1px solid var(--qb-border);
    padding-top: 14px;
    transition: border-color 0.35s;
}

.qp-search-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.qp-search-input-wrap {
    display: flex;
    align-items: center;
    background: var(--qb-input-bg);
    border: 1px solid var(--qb-border);
    border-radius: 13px;
    padding: 0 8px 0 11px;
    gap: 9px;
    transition: border-color 0.2s, background 0.2s;
}
.qp-search-input-wrap:focus-within {
    border-color: color-mix(in srgb, var(--qb-accent) 55%, transparent);
    background: var(--qb-hover);
}
.qp-search-input-wrap > svg {
    color: var(--qb-text-dimmer);
    flex-shrink: 0;
}

.qp-search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--qb-text);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    padding: 10px 0;
    margin: 3px 0;
    outline: none;
    min-width: 0;
    transition: color 0.35s;
}
.qp-search-input::placeholder {
    color: var(--qb-text-dimmer);
}

/* Search results dropdown — fixed above input */
.qp-search-results {
    position: fixed;
    background: var(--qb-panel);
    border: 1px solid var(--qb-border);
    border-radius: 13px;
    z-index: 200;
    box-shadow: var(--qb-shadow);
    max-height: 320px;
    overflow-y: auto;
}
@keyframes qpResultsIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.qp-result {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 13px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--qb-border);
    color: var(--qb-text-dim);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
}
.qp-result:last-child { border-bottom: none; }
.qp-result:hover {
    background: var(--qb-hover);
    color: var(--qb-text);
}
.qp-result svg {
    color: var(--qb-text-dimmer);
    flex-shrink: 0;
}
.qp-result span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* GPS locate button — inline inside the search field */
.qp-locate-inline-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--qb-text-dimmer);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 6px;
    transition: color 0.2s;
}
.qp-locate-inline-btn:hover {
    color: var(--qb-accent);
}
.qp-locate-inline-btn.loading {
    animation: locateSpin 1.2s linear infinite;
    color: var(--qb-accent);
}

/* Kaaba focus button — replace old locate btn */
.qp-kaaba-btn {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: color-mix(in srgb, var(--qb-accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--qb-accent) 22%, transparent);
    color: var(--qb-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.qp-kaaba-btn:hover {
    background: color-mix(in srgb, var(--qb-accent) 20%, transparent);
    border-color: color-mix(in srgb, var(--qb-accent) 38%, transparent);
}
.qp-kaaba-btn:active {
    transform: scale(0.93);
}
@keyframes locateSpin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   STATUS MESSAGE
   ═══════════════════════════════════════════ */
.qp-status {
    margin: 0 14px 14px;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.55;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
    color: var(--qb-text);
}
.qp-status--loading {
    background: color-mix(in srgb, var(--qb-accent) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--qb-accent) 18%, transparent);
}
.qp-status--error {
    background: rgba(239, 68, 68, 0.07);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: rgba(252, 165, 165, 0.9);
}
.qp-status--info {
    background: var(--qb-input-bg);
    border: 1px solid var(--qb-border);
    color: var(--qb-text-dim);
}

/* ═══════════════════════════════════════════
   MAPBOX — custom layers toggle button (injected into ctrl group)
   ═══════════════════════════════════════════ */
/* ═══════════════════════════════════════════
   LAYER THUMBNAIL — Google Maps style
   ═══════════════════════════════════════════ */
.qibla-layer-thumb {
    position: fixed;
    top: calc(64px + 12px);
    right: 12px;
    width: 65px;
    height: 65px;
    border-radius: 8px;
    overflow: hidden;
    border: 2.5px solid var(--qb-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    z-index: 10;
    transition: border-color 0.35s, transform 0.18s, box-shadow 0.18s;
}
.qibla-layer-thumb:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.48);
}
@media (min-width: 769px) {
    body.sidebar-mini .qibla-layer-thumb {
        right: calc(80px + 12px);
    }
}
#qibla-layer-mini-map {
    width: 100%;
    height: 100%;
    pointer-events: none;
}
/* Disable all Mapbox UI inside thumbnail */
#qibla-layer-mini-map .mapboxgl-ctrl,
#qibla-layer-mini-map .mapboxgl-canvas-container canvas {
    pointer-events: none;
}
.qibla-layer-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.52) 0%, transparent 100%);
    padding: 10px 4px 5px;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   TOPBAR RIGHT — theme switcher position
   ═══════════════════════════════════════════ */
.qibla-topbar-right {
    position: absolute;
    top: 0;
    right: 20px;
    height: 100%;
    display: flex;
    align-items: center;
    transition: right 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
@media (max-width: 768px) {
    .qibla-topbar-right {
        right: 20px;
    }
}
@media (min-width: 769px) {
    .qibla-page.sidebar-mini .qibla-topbar-right {
        right: 20px;
    }
}

/* Panel popup rises UP (qibla-specific override) */
.qp-theme-row .q-theme-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    top: auto;
    left: 50%;
    transform: translateX(-50%);
    animation: qbPanelPopupIn 0.15s ease;
}
@keyframes qbPanelPopupIn {
    from { opacity: 0; transform: translateX(-50%) translateY(6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Sidebar z-index — above map but below theme-switcher popup */
.qibla-page #sidebar { z-index: 182; }

/* ═══════════════════════════════════════════
   PANEL THEME ROW
   ═══════════════════════════════════════════ */
.qp-theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px 16px;
    flex-shrink: 0;
    border-top: 1px solid var(--qb-border);
    padding-top: 12px;
    transition: border-color 0.35s;
}
.qp-theme-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--qb-text-dimmer);
    transition: color 0.35s;
}

/* ═══════════════════════════════════════════
   MOBILE PANEL TOGGLE BUTTON
   ═══════════════════════════════════════════ */
.qp-panel-toggle {
    display: none;
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    padding: 13px 26px;
    background: rgba(16, 185, 129, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: none;
    border-radius: 100px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.4px;
    cursor: pointer;
    gap: 7px;
    align-items: center;
    box-shadow: 0 5px 22px rgba(16, 185, 129, 0.38);
    transition: background 0.2s, transform 0.2s;
}
.qp-panel-toggle:hover {
    background: rgba(16, 185, 129, 1);
    transform: translateX(-50%) scale(1.03);
}

/* ─── Mobile Backdrop ─── */
.qp-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 18;
}
.qp-backdrop.hidden { display: none; }

/* ═══════════════════════════════════════════
   KAABA MAP MARKER
   ═══════════════════════════════════════════ */
.qibla-kaaba-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}
.kaaba-pin-icon {
    width: 55px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
    transition: transform 0.2s;
}
.qibla-kaaba-pin:hover .kaaba-pin-icon {
    transform: scale(1.1);
}
/* Pulse ring behind the icon */
.kaaba-pulse {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(62, 141, 208, 0.2);
    box-shadow: 0 0 0 0 rgba(62, 141, 208, 0.5);
    animation: kaabaPulse 2s ease-out infinite;
    pointer-events: none;
}
@keyframes kaabaPulse {
    0%   { transform: scale(0.9); box-shadow: 0 0 0 0    rgba(62, 141, 208, 0.55); }
    60%  { transform: scale(1.1); box-shadow: 0 0 0 18px rgba(62, 141, 208, 0);    }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0    rgba(62, 141, 208, 0);    }
}

/* ═══════════════════════════════════════════
   DRAGGABLE USER LOCATION MARKER
   ═══════════════════════════════════════════ */

.qibla-user-pin {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    /* Force draggable cursor on the whole element */
    touch-action: none;
}
.qibla-user-pin:active {
    cursor: grabbing;
}

/* Pulsing ring */
.qibla-user-pin-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(56, 189, 248, 0.42);
    animation: userPinPulse 2.2s ease-out infinite;
}
@keyframes userPinPulse {
    0%   { transform: scale(0.7); opacity: 0.9; }
    100% { transform: scale(1.9); opacity: 0; }
}

/* Arrow pointing toward Qibla — rotated wrapper orbits the dot */
.qibla-user-pin-arrow-wrap {
    position: absolute;
    inset: 0;
    pointer-events: none;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.qibla-user-pin-arrow {
    position: absolute;
    left: 50%;
    top: -16px;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left:  7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 11px solid #3e8dd0;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.5));
}

/* Inner dot */
.qibla-user-pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #38bdf8;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    position: relative;
    z-index: 1;
    transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.18s ease;
}

/* Lift effect while dragging */
.qibla-user-pin:active .qibla-user-pin-dot,
.mapboxgl-marker.dragging .qibla-user-pin-dot {
    transform: scale(1.25);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* ─── Utility ─── */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

/* Tablet: slightly narrower panel */
@media (max-width: 900px) {
    .qibla-panel {
        width: 290px;
    }
    .qibla-page .mapboxgl-ctrl-bottom-left {
        left: 320px;
    }
}

/* Mobile: panel becomes a bottom sheet */
@media (max-width: 640px) {
    .qibla-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        border-radius: 22px 22px 0 0;
        max-height: 78dvh;
        transform: translateY(100%);
        transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    }
    .qibla-panel.panel-open {
        transform: translateY(0);
    }

    .qp-close-btn {
        display: flex;
    }
    .qp-panel-toggle {
        display: flex;
    }

    /* Smaller compass on mobile */
    .qp-compass {
        width: 168px;
        height: 168px;
    }
    .qp-needle-inner {
        height: 144px;
    }

    /* Map controls: mobile resets */
    .qibla-page .mapboxgl-ctrl-bottom-right {
        right: 14px;
        bottom: 14px;
    }
    .qibla-page .mapboxgl-ctrl-bottom-left {
        left: 14px;
        bottom: 14px;
    }
}

/* Desktop: lock panel visible, remove mobile sheet behaviour */
@media (min-width: 641px) {
    .qibla-panel {
        transform: none !important;
        transition: none;
    }
    .qp-panel-toggle {
        display: none !important;
    }
    .qp-backdrop {
        display: none !important;
    }
}
