/* ═══════════════════════════════════════════════════════════════════
   JoyA — «ПроПлюс» (Такси) Layout
   ═══════════════════════════════════════════════════════════════════ */

/* ── ProPlus Button in Header ───────────────────────────────────── */

.btn-proplus {
    display: none; /* hidden until premium */
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(245, 189, 65, 0.12), rgba(245, 189, 65, 0.04));
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.btn-proplus:hover {
    background: linear-gradient(135deg, rgba(245, 189, 65, 0.22), rgba(245, 189, 65, 0.1));
    box-shadow: 0 0 16px rgba(245, 189, 65, 0.15);
    transform: translateY(-1px);
}

.btn-proplus--active {
    background: linear-gradient(135deg, var(--accent), #e6a817);
    color: #1a1a2e;
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(245, 189, 65, 0.25);
}

.btn-proplus--active:hover {
    background: linear-gradient(135deg, #e6a817, var(--accent));
}

.btn-proplus--in-dropdown {
    width: 100%;
    margin: 0.35rem 0;
    justify-content: center;
}

.btn-proplus__icon {
    font-size: 1rem;
    line-height: 1;
}

.btn-proplus__label {
    line-height: 1;
}

/* Show when premium user */
body[data-premium="true"] .btn-proplus {
    display: inline-flex;
}

/* ── Taxi Layout Container ──────────────────────────────────────── */

.taxi-layout {
    display: none;
    position: relative;
    grid-template-columns: 220px 1fr;
    gap: 0;
    margin-top: 0.5rem;
    transition: grid-template-columns 0.3s ease;
}

.taxi-layout--sidebar-collapsed {
    grid-template-columns: 60px 1fr;
}

.taxi-layout--active {
    display: grid;
    margin-bottom: 1rem;
}

/* ── Taxi Sidebar ───────────────────────────────────────────────── */

.taxi-sidebar {
    background: var(--bg-body);
    border-right: 1px solid var(--border);
    border-radius: 12px 0 0 12px;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    position: sticky;
    top: 0;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    z-index: 50;
}

.taxi-sidebar__logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.5rem;
    margin-bottom: 1rem;
    font-family: var(--font-heading), sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.taxi-sidebar__logo-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.taxi-layout--sidebar-collapsed .taxi-sidebar__logo {
    padding: 0;
    justify-content: center;
}

.taxi-sidebar__section {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.taxi-sidebar__section:hover {
    background: rgba(245, 189, 65, 0.06);
    color: var(--text-primary);
}

.taxi-sidebar__section--active {
    background: rgba(245, 189, 65, 0.1);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 700;
}

.taxi-sidebar__icon {
    font-size: 1.15rem;
    width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.taxi-sidebar__label {
    line-height: 1.2;
    transition: opacity 0.2s ease;
}

.taxi-sidebar__divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 1rem;
}

/* ── Builder / Util Buttons ─────────────────────────────────────── */

.taxi-sidebar__builder {
    display: flex;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;
    justify-content: space-between;
}

.taxi-layout--sidebar-collapsed .taxi-sidebar__builder {
    flex-direction: column;
    padding: 0.25rem;
    align-items: center;
}

.taxi-sidebar__util-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.4rem 0.2rem;
    border: none;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 0;
}

.taxi-sidebar__util-btn:hover {
    background: rgba(245, 189, 65, 0.1);
    color: var(--accent);
}

.taxi-sidebar__util-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.taxi-sidebar__util-btn .taxi-sidebar__label {
    font-size: 0.65rem;
    font-weight: 500;
    text-align: center;
}

.taxi-layout--sidebar-collapsed .taxi-sidebar__util-btn .taxi-sidebar__label {
    display: none;
}

/* ── Workspaces ─────────────────────────────────────────────────── */

.taxi-sidebar__workspaces {
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.taxi-layout--sidebar-collapsed .taxi-sidebar__workspaces {
    padding: 0.5rem;
    align-items: center;
}

.taxi-sidebar__ws-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.taxi-sidebar__ws-slots {
    display: flex;
    gap: 0.25rem;
    width: 100%;
}

.taxi-layout--sidebar-collapsed .taxi-sidebar__ws-slots {
    flex-direction: column;
}

.taxi-sidebar__ws-btn {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 0.25rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.taxi-sidebar__ws-btn:hover {
    background: rgba(245, 189, 65, 0.1);
    color: var(--text-primary);
}

.taxi-sidebar__ws-btn--active {
    background: rgba(245, 189, 65, 0.2);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 700;
}

.taxi-sidebar__ws-save {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 0.35rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.taxi-sidebar__ws-save:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(245, 189, 65, 0.05);
}

/* Collapsed Sidebar overrides */
.taxi-layout--sidebar-collapsed .taxi-sidebar__label,
.taxi-layout--sidebar-collapsed .taxi-sidebar__badge,
.taxi-layout--sidebar-collapsed .taxi-sidebar__ws-title,
.taxi-layout--sidebar-collapsed .taxi-sidebar__ws-save span,
.taxi-layout--sidebar-collapsed .taxi-sidebar__logo-text,
.taxi-layout--sidebar-collapsed .taxi-sidebar__back span:last-child {
    opacity: 0;
    width: 0;
    display: none;
}
.taxi-layout--sidebar-collapsed .taxi-sidebar__ws-save::after {
    content: '💾';
}
.taxi-layout--sidebar-collapsed .taxi-sidebar__section {
    padding: 0.75rem 0.5rem;
    justify-content: center;
}
.taxi-layout--sidebar-collapsed .taxi-sidebar__icon {
    width: auto;
}
.taxi-layout--sidebar-collapsed .taxi-sidebar__back {
    padding: 0.6rem 0.5rem;
    justify-content: center;
}

/* Custom Tooltip for collapsed sidebar handled by global tooltip */
.taxi-layout--sidebar-collapsed .taxi-sidebar {
    overflow: visible !important;
}


/* ═══ Section Counter Badge ═══════════════════════════════════════════════ */

.taxi-sidebar__badge {
    margin-left: auto;
    background: rgba(245, 189, 65, 0.15);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    min-width: 1.2rem;
    text-align: center;
}

/* ── Main Content Area ──────────────────────────────────────────── */

.taxi-content {
    background: var(--card-bg, rgba(255, 255, 255, 0.02));
    border-radius: 0 12px 12px 0;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

/* ── Pro+ Global Header ─────────────────────────────────────────── */

.taxi-global-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 1.2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
    flex-shrink: 0;
    background: rgba(22, 22, 34, 0.85); /* Glassmorphism background */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

html[data-theme="classic"] .taxi-global-header,
html[data-theme="premium"] .taxi-global-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.taxi-global-header__welcome {
    font-size: 1rem;
    font-family: var(--font-heading), sans-serif;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}
.taxi-global-header__welcome span {
    color: var(--text-primary);
}

.taxi-global-header__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.taxi-global-header__btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.taxi-global-header__btn > * {
    pointer-events: none;
}
.taxi-global-header__btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

html[data-theme="classic"] .taxi-global-header__btn:hover,
html[data-theme="premium"] .taxi-global-header__btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Make the main auth button look like an avatar inside Taxi */
.taxi-global-header__actions #btn-auth {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.taxi-global-header__actions #btn-auth:hover {
    transform: scale(1.05);
}

.taxi-global-header__actions #user-label {
    display: none; /* Hide 'Login' text */
}

/* Adjust language switcher in Taxi header */
.taxi-global-header__actions .lang-switch {
    margin-right: 0.5rem;
}

.taxi-content__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.taxi-content__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.taxi-content__title-icon {
    font-size: 1.25rem;
}

/* ── Section Panels ─────────────────────────────────────────────── */

.taxi-section {
    display: none;
    animation: taxiFadeIn 0.25s ease;
    padding: 0 1.5rem 1.5rem 1.5rem;
}

.taxi-section--active {
    display: block;
}

@keyframes taxiFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Widgets grid within each section (Muuri: absolute positioning) */
.taxi-section__grid {
    position: relative;
    width: 100%;
    min-height: 100px;
    transition: min-height 0.2s ease;
}

/* ── Density Modes ─────────────────────────────────────────────── */
/* Density: compact — tighter margins on widgets */
.taxi-layout--density-compact .taxi-widget {
    margin: 0.2rem !important;
}
.taxi-layout--density-compact .taxi-widget--half {
    width: calc(50% - 0.4rem) !important;
}
.taxi-layout--density-compact .taxi-widget--full {
    width: calc(100% - 0.4rem) !important;
}
.taxi-layout--density-compact .taxi-widget__header {
    padding: 0.4rem 0.75rem;
}
.taxi-layout--density-compact .taxi-widget {
    border-radius: 6px;
}

/* Density: ultra — minimal margins */
.taxi-layout--density-ultra .taxi-widget {
    margin: 0.1rem !important;
}
.taxi-layout--density-ultra .taxi-widget--half {
    width: calc(50% - 0.2rem) !important;
}
.taxi-layout--density-ultra .taxi-widget--full {
    width: calc(100% - 0.2rem) !important;
}
.taxi-layout--density-ultra .taxi-widget__header {
    padding: 0.25rem 0.5rem;
}
.taxi-layout--density-ultra .taxi-widget__title {
    font-size: 0.8rem;
}
.taxi-layout--density-ultra .taxi-widget {
    border-radius: 4px;
}
.taxi-layout--density-ultra .taxi-widget__controls button {
    width: 22px;
    height: 22px;
}

/* ── Widget Cards inside Taxi ───────────────────────────────────── */

.taxi-widget {
    background: rgba(18, 18, 18, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden; /* Clip content at widget boundary during resize */
    position: absolute;
    z-index: 1;
    margin: 0.35rem;
    width: calc(100% - 0.7rem);
    will-change: transform;
}

.taxi-widget--half { width: calc(50% - 0.7rem); }
.taxi-widget--third { width: calc(33.333% - 0.7rem); }
.taxi-widget--two-thirds { width: calc(66.666% - 0.7rem); }

/* ── Widgets inside Group Tabs (Muuri: relative container) ────── */
.taxi-group-tab-content {
    position: relative;
    min-height: 100px;
}

/* Widgets inside a group default to half-width (margin is 0.35rem each side = 0.7rem total,
   subtract an extra pixel to avoid subpixel rounding causing wrap) */
.taxi-group-tab-content > .taxi-widget {
    width: calc(50% - 0.7rem - 1px);
}

.taxi-widget:hover {
    border-color: rgba(245, 189, 65, 0.25);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.taxi-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.taxi-widget__drag-handle {
    color: var(--text-muted, rgba(255,255,255,0.3));
    cursor: grab;
    margin-right: 0.5rem;
    font-size: 1.1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
    transition: color 0.2s;
}

.taxi-widget__drag-handle:hover {
    color: var(--accent);
}

.taxi-widget__drag-handle:active {
    cursor: grabbing;
}

.taxi-widget__title-group {
    display: flex;
    align-items: center;
    flex: 1;
}

.taxi-widget__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.taxi-widget__controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.taxi-widget__toggle,
.taxi-widget__expand,
.taxi-widget__custom-btn,
.taxi-widget__close,
.taxi-widget__pin,
.taxi-widget__color-btn,
.taxi-widget__size-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.15rem 0.3rem;
    transition: transform 0.2s ease, color 0.2s ease;
}

.taxi-widget__toggle:hover,
.taxi-widget__expand:hover,
.taxi-widget__custom-btn:hover,
.taxi-widget__pin:hover,
.taxi-widget__color-btn:hover,
.taxi-widget__size-btn:hover {
    color: var(--accent);
}

.taxi-widget__close:hover {
    color: var(--error, #ff4a4a);
    transform: scale(1.1);
}

.taxi-widget--collapsed .taxi-widget__toggle {
    transform: rotate(-90deg);
}

.taxi-widget__body {
    padding: 0.5rem 0.75rem;
    min-height: 60px;
    overflow: auto;
    position: relative;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    word-break: break-word;
    overflow-wrap: break-word;
    container-type: inline-size;
}

/* Custom Scrollbar for Widgets */
.taxi-widget__body::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.taxi-widget__body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
.taxi-widget__body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
.taxi-widget__body::-webkit-scrollbar-thumb:hover {
    background: rgba(245, 189, 65, 0.3);
}

.taxi-widget--collapsed .taxi-widget__body {
    display: none;
}

.taxi-widget--collapsed .taxi-widget__resize-handle {
    display: none;
}

/* ── Resize Handle ──────────────────────────────────────────────── */

.taxi-widget__resize-handle {
    height: 16px;
    cursor: nwse-resize;
    background: transparent;
    transition: all 0.15s ease;
    position: relative;
}

.taxi-widget__resize-handle::after {
    content: '';
    position: absolute;
    right: 6px;
    bottom: 3px;
    width: 10px;
    height: 10px;
    border-right: 2px solid rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 0 2px 0;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.taxi-widget:hover .taxi-widget__resize-handle::after {
    opacity: 1;
}

.taxi-widget__resize-handle:hover {
    background: rgba(245, 189, 65, 0.05);
}

.taxi-widget__resize-handle:hover::after {
    border-color: var(--accent);
}

/* Active resize state — disable transitions for instant feedback */
.taxi-widget--resizing {
    transition: none !important;
    border-color: rgba(245, 189, 65, 0.4) !important;
}
.taxi-widget--resizing .taxi-widget__body {
    transition: none !important;
}

/* ── Focus Mode (Fullscreen) ────────────────────────────────────── */

.taxi-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.taxi-overlay--active {
    display: block;
    opacity: 1;
}

.taxi-widget--fullscreen {
    position: fixed !important;
    top: 30px !important;
    left: 30px !important;
    right: 30px !important;
    bottom: 30px !important;
    width: auto !important;
    height: auto !important;
    z-index: 9999 !important;
    margin: 0 !important;
    transform: none !important;
    max-width: none !important;
    max-height: none !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Safe here: Muuri is not positioning fullscreen widgets */
}

.taxi-widget--fullscreen .taxi-widget__toggle,
.taxi-widget--fullscreen .taxi-widget__close,
.taxi-widget--fullscreen .taxi-widget__pin {
    display: none !important;
}

.taxi-widget--fullscreen .taxi-widget__body {
    max-height: none !important;
    flex: 1 1 auto;
}

.taxi-widget--fullscreen .taxi-widget__resize-handle {
    display: none !important;
}

/* ── Drag-and-Drop States (Muuri) ───────────────────────────────── */
/* IMPORTANT: Muuri uses inline transform:translate() for positioning.
   NEVER set transform or transition:transform here — it will break drag. */

.muuri-item-dragging {
    z-index: 9999 !important;
    cursor: grabbing;
    box-shadow: 0 20px 35px rgba(0, 0, 0, 0.35), 0 0 1px rgba(255, 255, 255, 0.2);
    border-color: rgba(245, 189, 65, 0.4) !important;
    opacity: 0.95;
    pointer-events: none; /* FIX 4: prevent hover effects interfering with drop zone detection */
}

.muuri-item-releasing {
    z-index: 9998 !important;
}

.muuri-item-placeholder {
    opacity: 0.15;
    border: 2px dashed var(--accent);
    border-radius: 8px;
    background: rgba(245, 189, 65, 0.04);
}

.muuri-item-hidden {
    z-index: 0;
}

/* ── Anti-Jitter Guard: disable transitions during drag ─────────── */
/* FIX 4: When body has this class, all geometry transitions are killed
   so Muuri reads honest coordinates without animation delays. */

body.taxi-mode-dragging .taxi-widget {
    transition: none !important;
}

body.taxi-mode-dragging .taxi-section__grid {
    transition: none !important;
}

.taxi-no-transition .taxi-widget {
    transition: none !important;
}


/* ── Back to Normal Button ──────────────────────────────────────── */

.taxi-sidebar__back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    margin: 0 0.5rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.taxi-sidebar__back:hover {
    background: rgba(255, 80, 80, 0.08);
    border-color: rgba(255, 80, 80, 0.3);
    color: var(--danger-soft);
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .taxi-widget--half,
    .taxi-widget--third,
    .taxi-widget--two-thirds {
        width: calc(100% - 0.7rem) !important;
    }
}

@media (max-width: 768px) {
    .taxi-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .taxi-layout--sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .taxi-sidebar {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid var(--border);
        border-radius: 12px 12px 0 0;
        padding: 0.5rem;
        max-height: none;
        position: static;
    }

    .taxi-sidebar__section {
        flex-direction: column;
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        border-left: none;
        border-bottom: 2px solid transparent;
        gap: 0.25rem;
    }

    .taxi-sidebar__section--active {
        border-left-color: transparent;
        border-bottom-color: var(--accent);
    }

    .taxi-sidebar__badge {
        display: none;
    }

    .taxi-sidebar__back {
        margin: 0 0.25rem;
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }

    .taxi-content {
        border-radius: 0 0 12px 12px;
        padding: 1rem;
        max-height: none;
    }
}

/* ── Hiding utilities for Taxi mode ─────────────────────────────── */

.page-nav--taxi-hidden {
    display: none !important;
}

.page-content--taxi-hidden {
    display: none !important;
}


/* When inside taxi widget, pages should display as blocks */
.taxi-widget__body > .page-content {
    display: block !important;
}

.taxi-widget__body > .page-content > main {
    padding: 0;
}

/* Analysis panels inside taxi widgets: always visible */
.taxi-widget__body > .analysis-panel {
    display: block !important;
}

/* Remove card wrappers' excess padding in taxi context */
.taxi-widget__body .card {
    border: none;
    box-shadow: none;
    padding: 0;
    background: transparent;
}

.taxi-widget__body .card--form {
    padding: 0;
}

.taxi-widget__body .card__title,
.taxi-widget__body .card__header {
    display: none !important; /* Title and header already in widget header */
}

/* Force card body to be visible even if the underlying card is collapsed */
.taxi-widget__body .card__body {
    display: block !important;
}
/* But allow the input form to collapse in taxi mode */
.taxi-widget__body .card--collapsed .card__body {
    display: none !important;
}

/* ── Pro+ Compact Input Form (tw-input) ── */
.taxi-widget__body #input-section .profiles-bar,
.taxi-widget__body #ayanamsha-row {
    display: none !important;
}
.taxi-widget__body #input-section .form {
    gap: 0.5rem;
}
.taxi-widget__body #input-section .form__group label {
    font-size: 0.75rem;
    margin-bottom: 0.1rem;
}
.taxi-widget__body #input-section input, 
.taxi-widget__body #input-section select {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    height: 28px;
}
.taxi-widget__body #input-section .btn {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

/* ── Pro+ Compact Table Overrides ── */
.taxi-widget__body .table th,
.taxi-widget__body .table td {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-mono); /* Monospaced for data density */
}
.taxi-widget__body .table th {
    font-family: var(--font-body);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.03);
}
.taxi-widget__body .table tbody tr:hover {
    background: rgba(245, 189, 65, 0.08);
}
/* ── Compatibility & Synastry Forms in Pro+ ─────────────────── */
.taxi-widget .compat-form {
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.taxi-widget .compat-partner {
    padding: 0.5rem;
}

.taxi-widget .form__row {
    flex-direction: column;
    gap: 0.5rem;
}

.taxi-widget .form__row > .form__group {
    width: 100%;
}

.taxi-widget .card__subtitle {
    display: none;
}

.taxi-widget .syn-import-btns {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.taxi-widget .syn-import-btns .btn {
    width: 100%;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
}

.taxi-widget .table td,
.taxi-widget .table th {
    padding: 0.25rem 0.4rem;
    font-size: 0.75rem;
}

.taxi-widget .btn--large {
    width: 100%;
    padding: 0.5rem;
    font-size: 0.85rem;
}

/* For fullscreen widgets, we can relax some rules if needed, but keeping it compact is fine */
.taxi-widget--fullscreen .compat-form {
    grid-template-columns: 1fr 1fr;
}
.taxi-widget--fullscreen .form__row {
    flex-direction: row;
}
.taxi-widget--fullscreen .syn-import-btns {
    flex-direction: row;
}
/* (SortableJS classes removed — using Muuri drag states above) */

/* ── Overlay glassmorphism ─────────────────────────────────────────── */
.taxi-overlay {
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease, backdrop-filter 0.3s ease;
}

/* ── Content Responsiveness (adapts to widget width changes) ─────── */

/* Body clips and constrains all content to widget width */
.taxi-widget__body {
    overflow-x: auto;
    overflow-y: auto;
}

/* All direct children must respect the body width */
.taxi-widget__body > * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Images, SVG, Canvas — scale down to fit */
.taxi-widget__body img,
.taxi-widget__body svg,
.taxi-widget__body canvas {
    max-width: 100%;
    height: auto;
}

/* Tables — scroll horizontally instead of overflowing */
.taxi-widget .table-responsive {
    margin-bottom: 0;
    overflow-x: auto;
}

.taxi-widget .table {
    width: 100%;
    table-layout: auto;
}

.taxi-widget .table th, 
.taxi-widget .table td {
    white-space: normal;
    word-break: break-word;
}

/* Force ALL descendants to respect container width */
.taxi-widget__body * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Charts must scale with container */
.taxi-widget .ni-chart,
.taxi-widget .si-chart,
.taxi-widget .chart-wrapper {
    min-height: 0;
    min-width: 0;
}

/* Form inputs should shrink with container */
.taxi-widget input,
.taxi-widget select,
.taxi-widget textarea {
    max-width: 100%;
    min-width: 0;
}

/* Varga detail grid should stack when narrow */
.taxi-widget .varga-detail {
    min-width: 0;
}

/* CRM form inputs */
.taxi-widget .card--form input,
.taxi-widget .card--form select {
    width: 100%;
    min-width: 0;
}

/* Make headers more compact if they are inside analytics widgets */
.taxi-widget .panel-header {
    display: none; /* Hide redundant panel headers since widget has a header */
}
/* ── Mobile Adaptation (Phase 6) ──────────────────────────────────── */
@media (max-width: 768px) {
    /* Override inline styles for layout */
    .taxi-widget,
    .taxi-group-tab-content > .taxi-widget {
        grid-column: span 12 !important;
    }
    
    .taxi-widget__body {
        max-height: none !important;
    }

    /* Convert layout to single column and make room for bottom nav */
    .taxi-layout--active {
        display: flex;
        flex-direction: column;
    }
    
    .taxi-layout__content {
        height: calc(100vh - 70px) !important;
        grid-template-columns: 1fr !important;
        margin-bottom: 70px;
    }
    
    /* Convert sidebar to bottom navigation */
    .taxi-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 70px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 0.5rem;
        z-index: 9999;
        background: var(--bg-card);
        justify-content: flex-start;
        align-items: center;
    }
    
    /* Hide some elements on mobile sidebar */
    .taxi-sidebar__divider,
    .taxi-sidebar__ws-title,
    .taxi-sidebar__label,
    #btn-taxi-sidebar-toggle {
        display: none !important;
    }
    
    .taxi-sidebar__section {
        min-height: auto;
        padding: 0.5rem 0.75rem;
        border-left: none;
        border-bottom: 3px solid transparent;
        flex-shrink: 0;
    }
    
    .taxi-sidebar__section--active {
        border-left: none;
        border-bottom: 3px solid var(--accent);
        background: var(--bg-hover);
    }
    
    .taxi-sidebar__icon {
        margin: 0;
        font-size: 1.5rem;
    }
    
    .taxi-sidebar__workspaces {
        flex-direction: row;
        margin: 0;
        padding: 0 0.5rem;
        border-left: 1px solid var(--border);
        align-items: center;
    }
    
    .taxi-sidebar__ws-slots {
        gap: 0.25rem;
    }
    
    .taxi-sidebar__ws-save {
        margin-left: 0.5rem;
        padding: 0.4rem;
    }
    
    /* Hide specific controls on mobile to save space */
    .taxi-widget__custom-btn {
        display: none;
    }
}
/* ── Mobile Drag Handle (Phase 7) ──────────────────────────────────── */
.taxi-widget__drag-handle {
    display: none; /* Hidden by default on desktop */
    cursor: grab;
    padding: 0 0.5rem 0 0;
    color: var(--text-muted);
    font-size: 1.2rem;
    user-select: none;
}

@media (max-width: 768px) {
    .taxi-widget__drag-handle {
        display: block; /* Show only on tablet/mobile */
    }
    
    /* Allow scrolling when touching the header on mobile (since drag is via handle now) */
    .taxi-widget__header {
        touch-action: pan-y;
        cursor: default;
    }
}
/* ── Fullscreen Focus Mode (Phase 8) ───────────────────────────────── */
.taxi-widget--expanded {
    position: fixed !important;
    top: 5vh !important;
    left: 5vw !important;
    width: 90vw !important;
    height: 90vh !important;
    z-index: 10001 !important;
    margin: 0 !important;
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
    background: var(--bg-card) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9) !important;
    transition: all 0.3s ease;
}

.taxi-widget--expanded .taxi-widget__toggle,
.taxi-widget--expanded .taxi-widget__close,
.taxi-widget--expanded .taxi-widget__pin,
.taxi-widget--expanded .taxi-widget__resize-handle {
    display: none !important;
}

.taxi-widget--expanded .taxi-widget__body {
    flex-grow: 1;
    overflow: auto; /* Changed to auto so tables can scroll if needed */
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Current Sky exceptions when expanded */
.taxi-widget--expanded #current-sky-view-table {
    max-height: none !important;
    height: 100%;
}
.taxi-widget--expanded #current-sky-chart {
    max-width: 60vh !important;
}
.taxi-widget--expanded #current-sky-chart .si-planet {
    font-size: 1.2rem;
}
.taxi-widget--expanded #current-sky-chart .si-cell__sign,
.taxi-widget--expanded #current-sky-chart .si-cell__house {
    font-size: 0.9rem;
}

/* Ensure overlay is above everything but below the expanded widget */
.taxi-overlay {
    z-index: 10000;
}

/* ── Client Switcher Mini-Widget ────────────────────────────────── */

.taxi-client-widget {
    position: relative;
    z-index: 1000;
    display: flex;
    align-items: stretch;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--card-shadow, 0 2px 8px rgba(0, 0, 0, 0.08));
    height: 36px;
}

html[data-theme="classic"] .taxi-client-widget,
html[data-theme="premium"] .taxi-client-widget {
    background: rgba(22, 22, 34, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(245, 189, 65, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.taxi-client-widget__main {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 12px;
    cursor: pointer;
}

.taxi-client-widget__input {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    font-family: var(--font-body);
    width: 110px;
    padding: 0;
    margin: 0;
    outline: none;
    cursor: pointer;
    text-overflow: ellipsis;
}

.taxi-client-widget__input:focus {
    cursor: text;
}

.taxi-client-widget__input::placeholder {
    color: rgba(245, 189, 65, 0.5);
    font-weight: 500;
}

.taxi-client-widget__dob {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1;
    margin-top: 2px;
}

.taxi-client-widget__btn {
    background: transparent;
    border: none;
    border-left: 1px solid rgba(245, 189, 65, 0.15);
    color: var(--text-secondary);
    padding: 0 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.taxi-client-widget__btn:hover {
    background: rgba(245, 189, 65, 0.1);
    color: var(--accent);
}

.taxi-client-widget__dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 250px;
    background: rgba(30, 30, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 4px;
}

.taxi-client-widget__dropdown-item {
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    flex-direction: column;
}

.taxi-client-widget__dropdown-item:hover {
    background: rgba(245, 189, 65, 0.15);
}

.taxi-client-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.taxi-client-item-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.taxi-layout .advanced-disclaimer { display: none !important; }


.taxi-layout .badge--premium, .taxi-layout .badge-premium { display: none !important; }


/* Group Widget Tabs */
.widget-group-tabs {
    display: flex;
    overflow-x: auto;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0 0.5rem;
    gap: 0.25rem;
    scrollbar-width: none;
}
.widget-group-tabs::-webkit-scrollbar { display: none; }

.widget-group-tab {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-group-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

.widget-group-tab.active,
.widget-group-tab--active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.widget-group-tab-input {
    background: transparent;
    border: none;
    color: inherit;
    font-size: inherit;
    font-family: inherit;
    outline: none;
    width: 60px;
    transition: width 0.2s;
}
.widget-group-tab-input:focus {
    width: 100px;
    border-bottom: 1px dashed var(--accent);
}

.widget-group-tab-delete {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0 2px;
    display: none;
}
.widget-group-tab:hover .widget-group-tab-delete {
    display: inline-block;
}
.widget-group-tab-delete:hover {
    color: var(--danger);
}

.widget-group-tab-add {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1rem;
    line-height: 1;
}
.widget-group-tab-add:hover {
    color: var(--accent);
}

.widget-group-content {
    min-height: 150px;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.widget-group-content:empty {
    border: 2px dashed rgba(255,255,255,0.1);
    border-radius: 8px;
    margin: 0.5rem;
    position: relative;
}
.widget-group-content:empty::after {
    content: '���������� ������� ����';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.taxi-layout--active ~ .footer {
    display: none !important;
}

/* ==========================================================
   Chart Placeholder (shown when chart is not calculated)
   ========================================================== */
.taxi-widget__chart-placeholder {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card, rgba(18, 18, 28, 0.97));
    border-radius: inherit;
    pointer-events: none;
}

.taxi-widget__chart-placeholder-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    text-align: center;
    animation: placeholder-fade-in 0.3s ease;
}

@keyframes placeholder-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   Widget Container Queries for Buttons (Scaling on Resize)
   ========================================================== */
@container (max-width: 600px) {
    /* Reduce table font size for narrower widgets */
    table, .table, .table--compact {
        font-size: 0.75rem;
    }
    table th, .table th, .table--compact th {
        padding: 0.2rem 0.35rem;
        font-size: 0.7rem;
    }
    table td, .table td, .table--compact td {
        padding: 0.2rem 0.35rem;
    }
    .badge {
        font-size: 0.6rem;
        padding: 0.1rem 0.25rem;
    }
}

@container (max-width: 450px) {
    .chart-style-toggle {
        height: 28px;
    }
    .chart-style-toggle .chart-style-btn {
        padding: 0 0.5rem;
        font-size: 0.7rem;
    }
    /* Compact tables further */
    table, .table, .table--compact {
        font-size: 0.7rem;
    }
    table th, .table th {
        padding: 0.15rem 0.25rem;
        font-size: 0.65rem;
        white-space: nowrap;
    }
    table td, .table td {
        padding: 0.15rem 0.25rem;
    }
    /* Hide less important columns */
    .taxi-widget__body table td:nth-child(n+5),
    .taxi-widget__body table th:nth-child(n+5) {
        display: none;
    }
    /* Compact header controls */
    .taxi-widget__controls {
        gap: 0.2rem;
    }
    .taxi-widget__title {
        font-size: 0.7rem;
    }
}

@container (max-width: 320px) {
    .chart-style-toggle {
        height: 24px;
        padding: 2px;
    }
    .chart-style-toggle .chart-style-btn {
        padding: 0 0.35rem;
        font-size: 0.65rem;
    }
    .chart-style-toggle .btn__text {
        display: none;
    }
    .chart-style-toggle svg {
        margin-right: 0 !important;
    }
    /* Ultra-compact tables */
    table, .table, .table--compact {
        font-size: 0.6rem;
    }
    table th, .table th {
        padding: 0.1rem 0.15rem;
        font-size: 0.58rem;
    }
    table td, .table td {
        padding: 0.1rem 0.15rem;
    }
    /* Hide even more columns */
    .taxi-widget__body table td:nth-child(n+4),
    .taxi-widget__body table th:nth-child(n+4) {
        display: none;
    }
    .taxi-widget__title {
        font-size: 0.65rem;
    }
    /* Stack header */
    .taxi-widget__header {
        flex-wrap: wrap;
        gap: 0.2rem;
    }
}
