/**
 * Plot Designer Inline Overrides
 * Extracted from plot_designer.html <style> block
 */

/* Timeline slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #e5e7eb, #e5e7eb);
    border-radius: 9999px;
    height: 6px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}

/* Event dot styling */
.event-dot {
    transition: transform 0.1s ease;
    z-index: 5;
}

.event-dot:hover {
    transform: scale(1.5);
    z-index: 10;
}

/* Ghost placement styling */
.placement--ghost {
    opacity: 0.3;
}

/* Contextual toolbar styling */
.contextual-toolbar {
    min-width: 240px;
}
.contextual-toolbar .placement-label {
    pointer-events: none;
}

/* Mobile contextual toolbar: position at bottom, full width */
@media (max-width: 768px) {
    #toolbar-host.contextual-toolbar {
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100vw !important;
        min-width: unset !important;
        max-width: 100vw !important;
        padding: 0 !important;
    }
    /* Direct content divs (placement, backdrop, decor, floating-permanent, zone-label, callout, pot) */
    #toolbar-host.contextual-toolbar > div {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 1rem 1rem 0 0 !important;
    }
    /* Content cards get comfortable mobile padding + safe-area for notched devices */
    #toolbar-host.contextual-toolbar > div.bg-surface-tint,
    #toolbar-host.contextual-toolbar > div > div.bg-surface-tint,
    #toolbar-host.contextual-toolbar > div.pd-card,
    #toolbar-host.contextual-toolbar > div > div.pd-card {
        padding: 0.75rem !important;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
    }
    /* Grandchild content divs — bed toolbar uses a wrapper <div> around view/edit mode divs */
    #toolbar-host.contextual-toolbar > div > div {
        width: 100% !important;
        max-width: 100% !important;
    }
    /* Override potential conflicting styles from external CSS */
    #toolbar-host.contextual-toolbar .pd-card {
        position: static !important;
        margin: 0 !important;
        max-width: none !important;
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        border-radius: 1rem 1rem 0 0 !important;
    }

    /* Public garden: toolbar stays near click target, not fixed at bottom */
    .public-plot-wrap #toolbar-host.contextual-toolbar {
        right: auto !important;
        bottom: auto !important;
        width: auto !important;
        min-width: 240px !important;
        max-width: 90vw !important;
        padding: 0 !important;
    }
    .public-plot-wrap #toolbar-host.contextual-toolbar > div {
        width: auto !important;
        max-width: 90vw !important;
        border-radius: 0.5rem !important;
    }
    .public-plot-wrap #toolbar-host.contextual-toolbar > div.bg-surface-tint,
    .public-plot-wrap #toolbar-host.contextual-toolbar > div > div.bg-surface-tint,
    .public-plot-wrap #toolbar-host.contextual-toolbar > div.pd-card,
    .public-plot-wrap #toolbar-host.contextual-toolbar > div > div.pd-card {
        padding: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    .public-plot-wrap #toolbar-host.contextual-toolbar > div > div {
        width: auto !important;
        max-width: 90vw !important;
    }
    .public-plot-wrap #toolbar-host.contextual-toolbar .pd-card {
        position: static !important;
        margin: 0 !important;
        max-width: 90vw !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
        border: 1px solid rgba(0, 0, 0, 0.08) !important;
        width: auto !important;
        border-radius: 0.5rem !important;
    }
}

/* Toolbar pages — swipeable tab container (mobile only) */
.toolbar-pages {
    overflow: hidden;
}

.toolbar-pages__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.125rem 0.25rem 0.25rem;
    justify-content: space-between;
}

.toolbar-pages__tabs {
    display: flex;
    gap: 2px;
    background: var(--color-surface-alt, #f3f4f6);
    border-radius: 6px;
    padding: 2px;
    flex: 1;
    min-width: 0;
}

.toolbar-pages__tabs button {
    flex: 1;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: center;
    transition: all 0.15s ease;
    color: var(--color-content-muted, #6b7280);
    border: none;
    background: none;
    cursor: pointer;
    white-space: nowrap;
}

.toolbar-pages__tabs button.active {
    background: var(--color-surface-tint, #ffffff);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    color: var(--color-content-primary, #111827);
    font-weight: 500;
}

.toolbar-pages__close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid var(--color-surface-border, #e5e7eb);
    font-size: 0.75rem;
    color: var(--color-content-muted, #6b7280);
    background: none;
    cursor: pointer;
    flex-shrink: 0;
}

.toolbar-pages__close:hover {
    background: var(--color-surface-alt, #f3f4f6);
}

.toolbar-pages__track {
    display: flex;
    transition: transform 0.2s ease;
    will-change: transform;
}

.toolbar-pages__track[data-swiping] {
    transition: none;
}

.toolbar-pages__track > [data-toolbar-page] {
    min-width: 100%;
    flex-shrink: 0;
    padding: 0 0.5rem 0.5rem;
}

/* Desktop: pages system invisible — show all content inline */
@media (min-width: 769px) {
    .toolbar-pages {
        overflow: visible;
    }
    .toolbar-pages__header {
        display: none;
    }
    .toolbar-pages__track {
        display: block;
        transform: none !important;
        height: auto !important;
    }
    .toolbar-pages__track > [data-toolbar-page] {
        min-width: unset;
        padding: 0;
    }
}

/* Single-page toolbar: no tabs needed */
.toolbar-pages--single .toolbar-pages__header {
    display: none;
}

.toolbar-pages--single .toolbar-pages__track {
    transform: none !important;
    height: auto !important;
}

/* ─── Path Placement Toolbar ─── */
.toolbar-section {
    padding: 4px 0;
}
.toolbar-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--color-content-muted, #6B7280);
    margin-bottom: 4px;
}
.toolbar-row {
    padding: 2px 0;
}
.toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.toolbar-btn--primary {
    background: var(--color-brand-600, #4F46E5);
    border-color: var(--color-brand-600, #4F46E5);
    color: #fff;
}
.toolbar-btn--primary:hover {
    background: var(--color-brand-700, #4338CA);
}
.toolbar-btn--secondary {
    background: transparent;
    border-color: var(--color-surface-border, #E5E7EB);
    color: var(--color-content-secondary, #374151);
}
.toolbar-btn--secondary:hover {
    background: var(--color-surface-alt, #F9FAFB);
}
.toolbar-btn--danger {
    background: transparent;
    border-color: #FCA5A5;
    color: #DC2626;
}
.toolbar-btn--danger:hover {
    background: #FEF2F2;
}

.path-entry-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}
.path-entry-row {
    border-left: 3px solid var(--entry-color, #6B7280);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.02);
    transition: background 0.15s;
    min-width: 0;
}
.path-entry-row:hover {
    background: rgba(0, 0, 0, 0.04);
}
.path-entry-row__main {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    cursor: pointer;
    min-height: 32px;
}
.path-entry-row__img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.path-entry-row__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--entry-color, #6B7280);
    flex-shrink: 0;
}
.path-entry-row__name {
    font-size: 12px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.path-entry-row__count {
    font-size: 11px;
    color: var(--color-content-muted, #6B7280);
    flex-shrink: 0;
    padding: 1px 5px;
    margin-left: 4px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.06);
}
.path-entry-row__arrows {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex-shrink: 0;
}
.path-entry-row__arrow {
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    padding: 6px 8px;
    color: var(--color-content-muted, #6B7280);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    min-width: 44px;
    min-height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.path-entry-row__arrow-h {
    display: none;
}
.path-entry-row__arrow-v {
    display: inline;
}
.path-entry-row__arrow:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.08);
    color: var(--color-content-primary, #111);
}
.path-entry-row__arrow:disabled {
    opacity: 0.2;
    cursor: default;
}
.path-entry-row__remove {
    font-size: 11px;
    line-height: 1;
    padding: 2px 4px;
    color: var(--color-content-muted, #9CA3AF);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
}
.path-entry-row__remove:hover {
    color: #EF4444;
    background: rgba(239, 68, 68, 0.08);
}
.path-entry-row__detail {
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    min-width: 0;
}
.path-entry-row__detail input[type="range"] {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: block;
    margin-top: 6px;
    margin-bottom: 4px;
}

@media (min-width: 768px) {
    .path-entry-list {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        max-height: none;
        overflow-y: visible;
        max-width: 600px;
    }
    .path-entry-row {
        border-left: none;
        border-radius: 12px;
        border: 2px solid var(--entry-color, #6B7280);
    }
    .path-entry-row__main {
        padding: 2px 4px;
        min-height: 26px;
        gap: 2px;
    }
    .path-entry-row__img {
        width: 16px;
        height: 16px;
    }
    .path-entry-row__dot {
        width: 8px;
        height: 8px;
    }
    .path-entry-row__name {
        max-width: 140px;
    }
    .path-entry-row__arrows {
        flex-direction: row;
    }
    .path-entry-row__arrow {
        font-size: 14px;
        min-width: 18px;
        min-height: 18px;
        padding: 0 3px;
    }
    .path-entry-row__arrow-h {
        display: inline;
    }
    .path-entry-row__arrow-v {
        display: none;
    }
    .path-entry-row__detail {
        padding: 8px 10px 10px;
        border-top: 1px solid rgba(0, 0, 0, 0.06);
        width: 200px;
    }
}

/* Path placement vertex editing handles — block browser touch gestures */
[data-pp-handles] [data-vertex-idx],
[data-pp-handles] [data-midpoint-after] {
    touch-action: none;
}

