/* ── Layout ─────────────────────────────────────────── */

body {
    margin: 0;
    background: #1a1a2e;
    color: #eee;
    overflow: hidden;
    height: 100vh;
}

.app-layout {
    display: flex;
    height: 100vh;
    align-items: center;
    gap: 10px;
}

.sidebar {
    flex: 0 0 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 8px;
}

.viewer-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

/* ── Image Container ───────────────────────────────── */

.image-container {
    position: relative;
    display: inline-block;
}

.page-image {
    max-height: 80vh;
    max-width: 100%;
    display: block;
}

/* ── Item Boxes (silhouette overlays) ──────────────── */

.image-box {
    position: absolute;
    opacity: 0.8;
    transition: opacity 0.3s;
    filter:
        drop-shadow(3px 2px 0 var(--box-shadow-color))
        drop-shadow(-2px -2px 0 var(--box-shadow-color));
    cursor: pointer;
}

.image-box img {
    display: block;
    max-width: none; /* don't constrain item images */
}

.image-box:hover,
.image-box.active {
    opacity: 1;
    transform: scale(1.01);
    animation: color-pulse 2s infinite linear;
}

/* Flash effect on hover */
.image-box::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid white;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

.image-box.active::after {
    animation: flash-outline 0.5s ease-out forwards;
}

@keyframes color-pulse {
    0%, 100% {
        filter:
            drop-shadow(3px 2px 0 var(--box-shadow-color))
            drop-shadow(-2px -2px 0 var(--box-shadow-color));
    }
    50% {
        filter:
            drop-shadow(3px 2px 2px white)
            drop-shadow(-1px -1px 2px white);
    }
}

@keyframes flash-outline {
    0%   { opacity: 1; transform: scale(1.03); }
    100% { opacity: 0; transform: scale(1); }
}

/* ── SAM Mask Canvas ───────────────────────────────── */

#mask-canvas {
    --box-color: #0072bd;
    animation: mask-border 1s ease-in-out infinite;
    opacity: 0;
}

@keyframes mask-border {
    0%, 100% {
        filter:
            drop-shadow(4px 3px 1px var(--box-color))
            drop-shadow(-1px -1px 1px var(--box-color));
    }
    50% {
        filter:
            drop-shadow(2px 1px 0 var(--box-color))
            drop-shadow(-3px -3px 3px var(--box-color));
    }
}

/* ── Navigation ────────────────────────────────────── */

.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(78, 201, 249, 0.15);
    color: #4ec9f9;
    border: 1px solid rgba(78, 201, 249, 0.3);
    text-decoration: none;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.nav-btn:hover {
    background: rgba(78, 201, 249, 0.3);
    color: #fff;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 12px;
}

.page-indicator {
    font-size: 0.9rem;
    color: #888;
}

/* ── Context Menu ──────────────────────────────────── */

.context-menu {
    position: absolute;
    z-index: 1000;
    display: flex;
    gap: 6px;
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 6px;
}

.context-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #4ec9f9;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.context-btn:hover {
    background: rgba(78, 201, 249, 0.2);
}

/* ── Text Box ──────────────────────────────────────── */

.text-box {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(22, 33, 62, 0.95);
    border: 1px solid #0f3460;
    border-radius: 10px;
    padding: 12px 24px;
    max-width: 500px;
    text-align: center;
    z-index: 999;
}

.text-box p {
    margin: 0;
    font-size: 1rem;
}

/* ── Loading Overlay ───────────────────────────────── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

/* ── Tooltip (hidden, read by JS) ──────────────────── */

.item-tooltip {
    display: none;
}
