/* =========================================================================
   JOTO SYSTEM — UI CONTROL LAYER (theme agnostic)
   Positioning + interactive behaviour for floating controls that are NOT
   covered by the custom Tailwind build (e.g. `tw-z-50`, `tw-w-52` are not
   generated). Loaded after app css and before dark-mode.css so both light
   and dark themes share the same reliable overlay behaviour.
   ========================================================================= */

/* ------------------------------------------------------------------ */
/* Theme selector (Bootstrap 3 dropdown): renders above page content    */
/* but stays inside the topbar stacking context, below modals.          */
/* ------------------------------------------------------------------ */

/* The custom topbar is a normal-flow flex bar (not AdminLTE's fixed
   .main-header). Give it a stacking context capped at 1000 so its
   floating menus can never rise above Bootstrap modals (backdrop 1040,
   modal 1050, tooltips/popovers 1070) while still overlaying cards. */
.joto-topbar {
    position: relative;
    z-index: 1000;
}

.joto-theme {
    position: relative;
}

.joto-theme-toggle {
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.joto-theme-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    left: auto; /* neutralise the Bootstrap 3 .dropdown-menu `left: 0` */
    z-index: 1005; /* high within the topbar context (capped at 1000) */
    width: 13.75rem; /* ~220px, replaces both `tw-w-52` and collapsed sizing */
    min-width: 13.75rem;
    max-width: calc(100vw - 2rem);
    margin: 0; /* neutralise the Bootstrap 3 .dropdown-menu top margin */
    padding: 0.375rem;
    transform-origin: top right;
    outline: none;
}

/* Polished glass panel (both themes get the layered surface, colors are
   theme-specific in dark-mode.css / tailwind). */
.joto-theme-menu {
    border: 1px solid rgba(127, 140, 170, 0.20);
    border-radius: 12px;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 20px 50px rgba(2, 6, 23, 0.22);
    background: rgba(255, 255, 255, 0.86);
}

/* Smooth appearance when the menu is shown (Bootstrap 3 toggles `.open`,
   which switches the slate from `display: none` to `display: block`) */
.joto-theme.dropdown.open .joto-theme-menu {
    -webkit-animation: joto-menu-in 0.16s cubic-bezier(0.22, 0.61, 0.36, 1);
    animation: joto-menu-in 0.16s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes joto-menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Compact premium rows: 44px targets, icon left, label, check right */
.joto-theme-menu .joto-theme-option {
    display: flex !important;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0.375rem 0.625rem;
    border: 1px solid transparent;
    border-radius: 9px;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    color: #475569;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease,
        color 0.15s ease, box-shadow 0.15s ease;
}
.joto-theme-menu .joto-theme-option:hover {
    background: rgba(99, 102, 241, 0.08);
    color: #1e293b;
}

/* Hard icon constraint — option + check icons are locked to 18px so the
   checkmark can never grow beyond its row (Guards the missing `tw-h-4`). */
.joto-theme-menu .joto-theme-option svg {
    width: 18px !important;
    height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    flex: 0 0 18px;
    flex-shrink: 0;
}
.joto-theme-menu .joto-theme-option .theme-option-icon {
    color: #64748b;
}
.joto-theme-menu .joto-theme-option > span {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right-aligned 18px selection indicator (never exceeds the row height) */
.joto-theme-menu .joto-theme-option .theme-selected-icon {
    margin-left: auto;
    color: #6366f1;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.joto-theme-menu .joto-theme-option-active .theme-selected-icon {
    opacity: 1;
    transform: scale(1);
}

/* Active row: subtle translucent blue/violet, soft border, mild glow.
   No oversized card, no giant icon — just a compact selected pill. */
.joto-theme-menu .joto-theme-option-active,
.joto-theme-menu .joto-theme-option-active:hover {
    background: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.30);
    color: #4f46e5;
    font-weight: 600;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.12);
}

/* ------------------------------------------------------------------ */
/* Shared floating layers: keep dropdowns / datepickers / autocompletes */
/* above common card stacking so nothing is hidden behind content.      */
/* ------------------------------------------------------------------ */

.dropdown-menu:not(.joto-theme-menu),
.ui-autocomplete,
.select2-dropdown,
.daterangepicker,
.bootstrap-datetimepicker-widget.dropdown-menu {
    z-index: 1500;
}

.modal-content {
    z-index: 1080;
}

/* ------------------------------------------------------------------ */
/* Guard: floating scroll nice-touching, tap feedback                   */
/* ------------------------------------------------------------------ */

.joto-theme-toggle,
.dropdown-menu > li > a,
.nav-tabs > li > a,
.btn,
a {
    -webkit-tap-highlight-color: transparent;
}
/* ------------------------------------------------------------------ */
/* Product photo quick-update (Product Details modal)                   */
/* Clickable main photo + action sheet + preview. Light-mode variant.   */
/* ------------------------------------------------------------------ */

.product-photo-card {
    width: 100%;
    max-width: 260px;
    margin: 0 auto;
}

.product-photo-area {
    position: relative;
    width: 100%;
    padding-top: 100%; /* square, aspect-ratio fallback */
    border-radius: 12px;
    border: 1px solid var(--joto-border-strong, #d2dae4);
    background: var(--joto-surface-secondary, #f8fafc)
        repeating-linear-gradient(
            45deg,
            rgba(0, 0, 0, 0.03),
            rgba(0, 0, 0, 0.03) 10px,
            transparent 10px,
            transparent 20px
        );
    overflow: hidden;
}

.product-photo-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.product-photo-clickable {
    cursor: pointer;
}

.product-photo-clickable:focus-visible {
    outline: 2px solid var(--joto-brand, #2563eb);
    outline-offset: 2px;
}

.product-photo-hover {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(10, 15, 28, 0.55);
    color: #ffffff;
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
    text-align: center;
    padding: 10px;
    font-size: 13px;
    font-weight: 600;
}

.product-photo-clickable:hover .product-photo-hover,
.product-photo-clickable:focus-visible .product-photo-hover {
    opacity: 1;
}

.product-photo-hover i {
    font-size: 26px;
}

.product-photo-action-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-photo-action-list + .product-photo-action-list {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--joto-border, #e3e8ef);
}

.product-photo-action {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: var(--joto-hover, #f3f4f6);
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--joto-text-primary, #121926);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.product-photo-action:hover {
    background: rgba(99, 102, 241, 0.12);
    border-color: var(--joto-border, #e3e8ef);
}

.product-photo-action i {
    width: 20px;
    text-align: center;
    font-size: 16px;
    color: var(--joto-brand, #2563eb);
}

.product-photo-action-danger {
    color: #dc2626;
}

.product-photo-action-danger i {
    color: #dc2626;
}

.product-photo-action-danger:hover {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.35);
}

.product-photo-preview-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 240px;
    max-height: 60vh;
    background: var(--joto-surface-secondary, #f8fafc);
    border: 1px dashed var(--joto-border-strong, #d2dae4);
    border-radius: 12px;
    overflow: hidden;
    padding: 10px;
}

.product-photo-preview-img {
    max-width: 100%;
    max-height: 56vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

.product-photo-preview-error {
    display: none;
    margin: 12px 0 0;
    color: #dc2626;
    font-weight: 500;
    text-align: center;
}

@media (max-width: 767px) {
    .product-photo-card {
        max-width: 200px;
    }
}
