/* ═══════════════════════════════════════════════════════════════
   V1 — Top Bar + Contextual Dropdowns
   Menu-style persistent topbar with horizontal tabs.
   Click a tab → dropdown panel appears below that tab.
   Each dropdown adapts width to its content.
   Click again or press Escape → dropdown closes.
   ═══════════════════════════════════════════════════════════════ */

/* ── Hide the floating settings button ─────────────────────── */
body.layout-v1 .settings-btn {
    display: none !important;
}

/* ── Settings panel → persistent topbar ────────────────────── */
body.layout-v1 .settings-panel {
    position: fixed;
    top: 0;
    left: 0 !important;
    right: 0;
    bottom: auto;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100vh;
    height: auto;
    transform: none !important;
    border-radius: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    flex-direction: column;
    transition: none;
    overflow: visible;
}

/* ── Header → slim topbar ──────────────────────────────────── */
body.layout-v1 .settings-header {
    flex-direction: row;
    align-items: center;
    padding: 0 20px;
    height: 52px;
    gap: 0;
    flex-shrink: 0;
    background: linear-gradient(180deg, #16191e 0%, #12151a 100%);
    border-bottom: 1px solid rgba(255,255,255,.06);
    box-shadow: 0 1px 0 rgba(0,0,0,.5),
                0 4px 16px rgba(0,0,0,.3);
    position: relative;
    z-index: 2;
}

body.layout-v1 .settings-header-row {
    display: contents;
}

body.layout-v1 .settings-title {
    display: none;
}

body.layout-v1 .settings-close-btn {
    display: none;
}

/* ── Brand element ─────────────────────────────────────────── */
body.layout-v1 .topbar-brand {
    display: flex !important;
    align-items: center;
    gap: 10px;
    margin-right: 28px;
    flex-shrink: 0;
    padding-right: 20px;
    border-right: 1px solid rgba(255,255,255,.06);
}
body.layout-v1 .topbar-brand img {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    flex-shrink: 0;
}
body.layout-v1 .topbar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
body.layout-v1 .topbar-brand-name {
    font-family: 'Inter', 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #e3e6ea;
    letter-spacing: .3px;
}
body.layout-v1 .topbar-brand-sub {
    font-family: 'Inter', 'DM Sans', sans-serif;
    font-size: 9px;
    font-weight: 600;
    color: #5a6069;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* ── Tab strip → horizontal menu-style tabs ────────────────── */
body.layout-v1 .sub-tab-buttons {
    flex-direction: row;
    background: transparent;
    border-radius: 0;
    padding: 0;
    gap: 1px;
    flex: 1;
    justify-content: flex-start;
    align-items: center;
    height: 100%;
}

body.layout-v1 .sub-tab-button {
    flex: none;
    flex-direction: row;
    gap: 7px;
    padding: 0 16px;
    border-radius: 0;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    background: transparent;
    height: 100%;
    box-shadow: none;
    position: relative;
    transition: color .2s ease, background .2s ease;
    letter-spacing: .2px;
}

body.layout-v1 .sub-tab-button:hover {
    background: rgba(255,255,255,.03);
    color: #b9bec6;
}

body.layout-v1 .sub-tab-button.active {
    background: rgba(255,255,255,.04);
    color: #e3e6ea;
    box-shadow: none;
}

body.layout-v1 .sub-tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #b9bec6, transparent);
    border-radius: 2px 2px 0 0;
    box-shadow: 0 1px 8px rgba(185,190,198,.25);
}

body.layout-v1 .sub-tab-button .tab-icon {
    font-size: 11px;
    color: inherit;
    opacity: .8;
}

body.layout-v1 .sub-tab-button.active .tab-icon {
    color: #b9bec6;
    opacity: 1;
}

body.layout-v1 .sub-tab-button span:not(.tab-icon) {
    font-size: 12px;
}

/* ── Content area → contextual dropdown card ──────────────── */
body.layout-v1 .settings-content {
    position: absolute;
    top: 52px;
    left: 12px;
    width: 420px;
    max-height: 0;
    overflow: hidden;
    padding: 0;
    background: rgba(16, 18, 23, 0.98);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border: 1px solid rgba(255,255,255,.07);
    border-top: none;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5),
                0 2px 8px rgba(0,0,0,.3),
                inset 0 1px 0 rgba(255,255,255,.03);
    transition: max-height .22s cubic-bezier(.4,0,.2,1),
                padding .22s cubic-bezier(.4,0,.2,1),
                opacity .18s ease;
    opacity: 0;
}

body.layout-v1 .settings-panel.open .settings-content {
    max-height: min(60vh, 560px);
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 20px;
    opacity: 1;
}

body.layout-v1 .sub-tab-content {
    max-width: none;
    margin: 0;
}

body.layout-v1 .setting-group {
    padding: 10px 12px;
    background: rgba(255,255,255,.015);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.04);
    margin-bottom: 8px;
}

body.layout-v1 .setting-group:last-child {
    margin-bottom: 0;
}

/* ── Overlay → transparent click-catcher ───────────────────── */
body.layout-v1 .settings-overlay {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: transparent;
}

/* ── Map container → offset below topbar ───────────────────── */
body.layout-v1 .map-container {
    top: calc(50% + 26px);
}

/* ── Mini session info → below topbar ──────────────────────── */
body.layout-v1 .mini-session-info {
    top: 64px;
}

/* ── Layout switcher → inside topbar visually ──────────────── */
body.layout-v1 #layoutSwitcher {
    top: 10px;
    right: 20px;
}

/* ── Color picker → above dropdown ─────────────────────────── */
body.layout-v1 .cpicker-popover {
    z-index: 1100;
}

/* ── Scrollbar styling inside dropdown ─────────────────────── */
body.layout-v1 .settings-content::-webkit-scrollbar {
    width: 3px;
}
body.layout-v1 .settings-content::-webkit-scrollbar-track {
    background: transparent;
}
body.layout-v1 .settings-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.1);
    border-radius: 3px;
}
body.layout-v1 .settings-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,.18);
}

/* ═══════════════════════════════════════════════════════════
   Pointer Style Improvements
   ═══════════════════════════════════════════════════════════ */

/* SVG preview icons in pointer buttons */
.ptr-preview {
    display: block;
    opacity: .6;
    transition: opacity .15s;
}
.shape-button.active .ptr-preview,
.shape-button:hover .ptr-preview {
    opacity: 1;
}
.ptr-style-buttons .shape-button {
    flex-direction: column !important;
    align-items: center;
    gap: 4px !important;
    padding: 6px 8px !important;
}

/* Compact Length + Outline row */
.ptr-compact-row {
    display: flex !important;
    align-items: stretch;
    gap: 0 !important;
}
.ptr-compact-item {
    padding: 4px 0;
}
.ptr-compact-length {
    flex: 1;
    min-width: 0;
}
.ptr-compact-outline {
    flex-shrink: 0;
    padding-left: 12px;
    display: flex;
    align-items: center;
}
.ptr-compact-divider {
    width: 1px;
    background: rgba(255,255,255,.06);
    margin: 4px 0;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   Icon Layout — Sectioned Cards
   ═══════════════════════════════════════════════════════════ */

/* Base: wrappers invisible in non-V1 layouts */
.icon-sections-grid { display: contents; }
.icon-section { display: contents; }
.icon-section-header { display: none; }
.icon-section-body { display: contents; }
.icon-subtab-panel:not(.active) { display: none !important; }

/* Canvas preview */
body.layout-v1 [data-icon-style="2"] > div[style*="aspect-ratio"] {
    aspect-ratio: 2.5/1 !important;
    margin-bottom: 8px;
}

/* ── Sections grid ─────────────────────────────────────────── */
body.layout-v1 [data-icon-style="2"] .icon-sections-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ── Section card ──────────────────────────────────────────── */
body.layout-v1 [data-icon-style="2"] .icon-section {
    display: block;
    background: rgba(255,255,255,.02);
    border: 1px solid rgba(255,255,255,.05);
    border-radius: 8px;
    overflow: hidden;
}

/* ── Section header ────────────────────────────────────────── */
body.layout-v1 [data-icon-style="2"] .icon-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-family: 'Inter', 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #e3e6ea;
    letter-spacing: .8px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,.04);
    background: rgba(255,255,255,.025);
}

/* ── Tabbed header (Health / Weapon) ───────────────────────── */
body.layout-v1 [data-icon-style="2"] .icon-section-header--tabbed {
    padding: 0;
    gap: 0;
    background: rgba(255,255,255,.02);
}

body.layout-v1 .icon-subtabs {
    display: flex;
    width: 100%;
}

body.layout-v1 .icon-subtab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    font-family: 'Inter', 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all .15s ease;
    letter-spacing: .5px;
    text-transform: uppercase;
    position: relative;
}

body.layout-v1 .icon-subtab:hover {
    color: #b9bec6;
    background: rgba(255,255,255,.02);
}

body.layout-v1 .icon-subtab.active {
    color: #e3e6ea;
    background: rgba(255,255,255,.03);
}

body.layout-v1 .icon-subtab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    border-radius: 2px 2px 0 0;
}

body.layout-v1 .icon-subtab[data-subtab="health"].active::after {
    background: #f87171;
    box-shadow: 0 0 8px rgba(248,113,113,.3);
}

body.layout-v1 .icon-subtab[data-subtab="weapon"].active::after {
    background: #60a5fa;
    box-shadow: 0 0 8px rgba(96,165,250,.3);
}

/* Divider between the two tabs */
body.layout-v1 .icon-subtab + .icon-subtab {
    border-left: 1px solid rgba(255,255,255,.04);
}

/* ── Section body ──────────────────────────────────────────── */
body.layout-v1 [data-icon-style="2"] .icon-section-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px;
}

body.layout-v1 [data-icon-style="2"] .icon-subtab-panel.active {
    display: flex !important;
}

body.layout-v1 [data-icon-style="2"] .icon-section-body .setting-group {
    padding: 5px 8px !important;
    margin: 0 !important;
    border-radius: 5px !important;
    border: none !important;
    background: transparent !important;
}
body.layout-v1 [data-icon-style="2"] .icon-section-body .setting-label {
    font-size: 10px !important;
    margin-bottom: 3px !important;
}
body.layout-v1 [data-icon-style="2"] .icon-section-body .shape-button {
    padding: 3px 7px !important;
    font-size: 9px !important;
}
body.layout-v1 [data-icon-style="2"] .icon-section-body .slider-value {
    font-size: 10px !important;
}
body.layout-v1 [data-icon-style="2"] .icon-section-body .toggle-switch {
    transform: scale(0.85);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    body.layout-v1 .settings-header {
        height: 46px;
        padding: 0 12px;
        gap: 0;
    }

    body.layout-v1 .topbar-brand {
        margin-right: 12px;
        padding-right: 12px;
    }
    body.layout-v1 .topbar-brand-text {
        display: none;
    }

    body.layout-v1 .sub-tab-buttons {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    body.layout-v1 .sub-tab-buttons::-webkit-scrollbar {
        display: none;
    }

    body.layout-v1 .sub-tab-button {
        padding: 0 10px;
        font-size: 11px;
        white-space: nowrap;
    }
    body.layout-v1 .sub-tab-button span:not(.tab-icon) {
        display: none;
    }

    body.layout-v1 .settings-content {
        left: 0 !important;
        width: 100vw !important;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    body.layout-v1 .settings-panel.open .settings-content {
        max-height: 60vh;
        padding: 12px 14px 20px;
    }

    body.layout-v1 .map-container {
        top: calc(50% + 23px);
    }

    body.layout-v1 #layoutSwitcher {
        top: auto;
        bottom: 10px;
        right: 10px;
    }
}

@media (max-width: 380px) {
    body.layout-v1 .topbar-brand img {
        width: 26px;
        height: 26px;
    }
}
