/**
 * 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, var(--color-canvas-grid-major), var(--color-canvas-grid-major));
    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: var(--color-success);
    border: 2px solid var(--color-content-inverse);
    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: var(--color-success);
    border: 2px solid var(--color-content-inverse);
    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: var(--radius-sm);
    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-primary);
    border-color: var(--color-primary);
    color: var(--color-content-inverse);
}
.toolbar-btn--primary:hover {
    background: var(--color-primary-hover);
}
.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: var(--color-danger);
}
.toolbar-btn--danger:hover {
    background: #FEF2F2;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) .toolbar-btn--danger:hover {
    background: #450a0a;
  }
}
.dark .toolbar-btn--danger:hover {
  background: #450a0a;
}

.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: var(--radius-md);
    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: var(--radius-sm);
    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: var(--radius-sm);
    flex-shrink: 0;
}
.path-entry-row__remove:hover {
    color: var(--color-canvas-error);
    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: var(--radius-lg);
        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;
}

/* === Impeccable sweep: polish + animate === */

/* Zoom/toolbar button press feedback (animate-3, delight-1) */
.zoom-controls button,
.canvas-navigation-controls button,
.canvas-navigation-controls a {
    transition: transform 100ms cubic-bezier(0.25, 1, 0.5, 1),
                background-color 150ms;
}
.zoom-controls button:active,
.canvas-navigation-controls button:active,
.canvas-navigation-controls a:active {
    transform: scale(0.9);
}

/* Zoom percentage hover affordance (critique-2) */
.zoom-controls .zoom-level-display {
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 2px 6px;
    transition: background-color 0.15s ease;
}
.zoom-controls .zoom-level-display:hover {
    background-color: var(--color-surface-alt, #f5f3ed);
}

/* Sidebar toolbar items hover lift (delight-6, polish-9) */
.tools-toolbar__item,
.tools-toolbar--desktop .tools-toolbar__btn {
    transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.15s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: var(--radius-md);
}
.tools-toolbar__item:hover,
.tools-toolbar--desktop .tools-toolbar__btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    background-color: var(--color-surface-alt, #f5f3ed);
}
.tools-toolbar__item:active,
.tools-toolbar--desktop .tools-toolbar__btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Dimension label contrast backdrop (polish-8) */
.canvas-dimension-label {
    background: rgba(252, 251, 248, 0.85);
    backdrop-filter: blur(2px);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) .canvas-dimension-label {
    background: rgba(30, 30, 30, 0.85);
  }
}
.dark .canvas-dimension-label {
  background: rgba(30, 30, 30, 0.85);
}

/* Mobile safe-area padding (polish-10) */
.tools-fab {
    bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
}
@supports (padding: env(safe-area-inset-top)) {
    .canvas-navigation-controls {
        top: calc(1rem + env(safe-area-inset-top, 0px));
    }
}

/* View-mode glow color tokens (critique-5) */
:root {
    --transition-glow-warm: rgba(255, 235, 170, 0.55);
    --transition-glow-mid: rgba(255, 220, 140, 0.25);
    --transition-glow-center: rgba(255, 255, 240, 0.6);
    --transition-glow-fade: rgba(255, 240, 180, 0.15);
}

/* Reduced-motion gating for zoom/nav controls (polish-4) */
@media (prefers-reduced-motion: reduce) {
    .zoom-controls,
    .zoom-controls *,
    .canvas-navigation-controls *,
    .tools-toolbar__item,
    .tools-toolbar--desktop .tools-toolbar__btn,
    .mode-pill-toggle__slider,
    .mode-pill-toggle__btn,
    .coaching-overlay__card--sway,
    .plant-tray__placement-bar,
    .save-checkmark {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
    .zoom-controls button:active,
    .canvas-navigation-controls button:active,
    .canvas-navigation-controls a:active,
    .tools-toolbar__item:hover,
    .tools-toolbar__item:active,
    .tools-toolbar--desktop .tools-toolbar__btn:hover,
    .tools-toolbar--desktop .tools-toolbar__btn:active {
        transform: none;
        box-shadow: none;
    }
}

/* === Mode pill sliding highlight (delight-2) === */
.mode-pill-toggle {
    position: relative;
}
.mode-pill-toggle__btn {
    position: relative;
    z-index: 1;
    transition: color 0.2s ease-out;
}
.mode-pill-toggle__slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(100% - 4px);
    height: calc(50% - 2px);
    border-radius: 0.5rem;
    background: var(--color-success);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease-out;
    z-index: 0;
}
.mode-pill-toggle__slider--view {
    transform: translateY(100%);
}
@media (min-width: 640px) {
    .mode-pill-toggle__slider {
        width: calc(50% - 2px);
        height: calc(100% - 4px);
    }
    .mode-pill-toggle__slider--view {
        transform: translateX(100%);
    }
}

/* === Save checkmark flash (delight-5) === */
.save-checkmark {
    animation: checkmarkFlash 600ms ease-out forwards;
}
@keyframes checkmarkFlash {
    0% { opacity: 0; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1.05); }
    70% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}

/* === Coaching overlay sway entrance (delight-8) === */
.coaching-overlay__card--sway {
    animation: coachingSway 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes coachingSway {
    0% { transform: rotate(1.5deg) scale(0.95); opacity: 0; }
    60% { transform: rotate(-0.5deg) scale(1.01); opacity: 1; }
    100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

/* === Mobile FAB empty canvas hint (critique-6) === */
.tools-toolbar__fab-hint {
    margin-top: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-content-muted, #6b7280);
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
}

/* === Placement bar bounce easing (delight-4 + animate-2) === */
.plant-tray__placement-bar {
    animation: none; /* Override the old keyframe; Alpine x-transition handles entrance */
}

/* === Mode pill focus ring (polish-5) === */
.mode-pill-toggle__btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--color-surface-alt), 0 0 0 4px var(--color-success);
    border-radius: 0.5rem;
}

/* === Desktop sidebar group separator (critique-1) === */
.tools-toolbar__separator--group {
    margin: 10px 10px;
}
:is(.dark, [data-theme="dark"]) .tools-toolbar__separator--group {
    opacity: 0.2;
}

