/* Segmentation Tool Styles */

/* Canvas Container */
.canvas-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    overflow: visible;
}

.zoom-wrapper {
    transform-origin: center center;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    min-width: 100%;
    position: relative;
}

/* Workspace boundary visualization */
.zoom-wrapper::before {
    content: '';
    position: absolute;
    width: 3000px;
    height: 3000px;
    border: 1px dashed #e5e7eb;
    border-radius: 8px;
    background:
        radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.02) 0%, transparent 70%),
        linear-gradient(90deg, rgba(229, 231, 235, 0.3) 1px, transparent 1px),
        linear-gradient(rgba(229, 231, 235, 0.3) 1px, transparent 1px);
    background-size:
        3000px 3000px,
        100px 100px,
        100px 100px;
    background-position: center;
    pointer-events: none;
    z-index: 0;
}

#annotation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    cursor: crosshair;
    z-index: 15;
    border-radius: 8px;
    overflow: hidden;
}

#base-image {
    display: block;
    max-width: 100%;
    height: auto;
    position: relative;
    z-index: 5;
    border-radius: 8px;
}

#annotation-area {
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fafafa;
}

/* Pan tool cursor styles */
#annotation-area.pan-tool {
    cursor: grab !important;
}

#annotation-area.pan-tool.dragging {
    cursor: grabbing !important;
}

#annotation-area.pan-tool * {
    cursor: inherit;
}

/* Canvas Tools Panel */
.canvas-tools {
    position: absolute;
    left: 10px;
    top: 10px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.canvas-tool-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.canvas-tool-btn:hover {
    border-color: #3b82f6;
    background: #f3f4f6;
}

.canvas-tool-btn.tool-active {
    border-color: #3b82f6;
    background: #3b82f6;
    color: white;
}

/* Canvas Image Info */
.canvas-image-info {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    text-align: center;
    padding: 8px 0;
    margin-top: 4px;
    font-size: 0.7rem;
    color: #6b7280;
    z-index: 15;
}

/* Canvas Color Selector */
.canvas-color-selector {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 230px;
}

.color-dropdown {
    position: relative;
    cursor: pointer;
}

.color-selected {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: white;
    font-size: 12px;
    font-weight: 500;
    min-height: 30px;
}

.color-selected:hover {
    border-color: #3b82f6;
}

.color-selected span:not(.color-dropdown-arrow) {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

.color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    min-width: 14px;
}

.color-dropdown-arrow {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.color-dropdown.open .color-dropdown-arrow {
    transform: rotate(180deg);
}

.color-options {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    margin-bottom: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 25;
    max-height: 180px;
    overflow-y: auto;
}

.color-options.show {
    display: block;
}

.color-option {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
    text-align: left;
    white-space: nowrap;
    min-height: 30px;
}

.color-option:hover {
    background-color: #f3f4f6;
}

.color-option span {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
}

.color-option:first-child {
    border-radius: 4px 4px 0 0;
}

.color-option:last-child {
    border-radius: 0 0 4px 4px;
}

/* Custom scrollbar for color options dropdown */
.color-options::-webkit-scrollbar {
    width: 4px;
}

.color-options::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.color-options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.color-options::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Zoom Controls */
.zoom-controls {
    position: absolute;
    top: 210px;
    left: 10px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    border-color: #3b82f6;
    background: #f3f4f6;
}

/* Drawing Styles */
.drawing-line {
    stroke: #ff0000;
    stroke-width: 2;
    fill: none;
    opacity: 0.8;
}

.segment-fill {
    opacity: 0.4;
}

/* Utility Classes */
.tool-active {
    background-color: #3b82f6 !important;
    color: white !important;
}

/* Fullscreen Styles */
#annotation-area:fullscreen {
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100vw !important;
    height: 100vh !important;
}

#annotation-area:-webkit-full-screen {
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100vw !important;
    height: 100vh !important;
}

#annotation-area:-moz-full-screen {
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100vw !important;
    height: 100vh !important;
}

#annotation-area:-ms-fullscreen {
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100vw !important;
    height: 100vh !important;
}

/* Fullscreen zoom wrapper adjustments */
#annotation-area:fullscreen .zoom-wrapper,
#annotation-area:-webkit-full-screen .zoom-wrapper,
#annotation-area:-moz-full-screen .zoom-wrapper,
#annotation-area:-ms-fullscreen .zoom-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Layers Panel */

.layers-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    background: rgba(255, 255, 255, 0.96);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.1);
    min-width: 180px;
    max-width: 220px;
    max-height: 280px;
    overflow: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.layers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    background: rgba(240, 240, 240, 0.1);
    border-bottom: 1px solid rgba(200, 200, 200, 0.2);
    cursor: pointer;
}

.layers-title {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}

.layers-collapse-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.layers-collapse-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.layers-content {
    overflow-y: auto;
    max-height: 220px;
    transition: max-height 0.3s ease;
}

.layers-content.collapsed {
    max-height: 0;
    overflow: hidden;
}

.layers-list {
    padding: 4px;
}

.no-layers-message {
    text-align: center;
    color: #9ca3af;
    font-size: 11px;
    padding: 12px 8px;
    font-style: italic;
}

.layer-item {
    display: flex;
    align-items: center;
    padding: 4px 6px;
    margin: 1px 0;
    border: 1px solid #e5e7eb;
    border-radius: 3px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.layer-item:hover {
    border-color: #3b82f6;
    background: #f8fafc;
}

.layer-item.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 0 0 1px #3b82f6;
}

.layer-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 11px;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-type {
    font-size: 9px;
    color: #6b7280;
    margin-top: 1px;
}

.layer-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
}

.layer-delete-btn {
    width: 16px;
    height: 16px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 10px;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: all 0.2s ease;
    opacity: 0;
}

.layer-item:hover .layer-delete-btn {
    opacity: 1;
}

.layer-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}





/* Responsive adjustments for layers panel */
@media (max-width: 1024px) {
    .layers-panel {
        top: 8px;
        right: 8px;
        min-width: 160px;
        max-width: 190px;
        max-height: 240px;
    }

    .zoom-controls {
        top: 190px;
        left: 8px;
    }

    .canvas-image-info {
        font-size: 0.7rem;
        padding: 6px 10px;
    }
}

@media (max-width: 768px) {
    .layers-panel {
        top: 5px;
        right: 5px;
        min-width: 140px;
        max-width: 170px;
        max-height: 200px;
    }

    .layers-content {
        max-height: 160px;
    }

    .zoom-controls {
        top: 180px;
        left: 5px;
    }

    .canvas-image-info {
        font-size: 0.65rem;
        padding: 5px 8px;
    }

    .canvas-color-selector {
        min-width: 140px;
        max-width: 170px;
    }

    .color-selected {
        font-size: 11px;
        padding: 4px 6px;
        min-height: 28px;
    }

    .color-option {
        font-size: 11px;
        padding: 4px 6px;
        min-height: 28px;
    }

    .color-options {
        max-height: 120px;
    }
}

@media (max-width: 480px) {
    .layers-panel {
        top: 3px;
        right: 3px;
        min-width: 120px;
        max-width: 150px;
        max-height: 160px;
    }

    .layers-content {
        max-height: 120px;
    }

    .zoom-controls {
        top: 170px;
        left: 3px;
    }

    .canvas-image-info {
        font-size: 0.6rem;
        padding: 4px 6px;
    }

    .canvas-color-selector {
        min-width: 120px;
        max-width: 150px;
    }

    .color-selected {
        font-size: 10px;
        padding: 3px 5px;
        min-height: 26px;
    }

    .color-option {
        font-size: 10px;
        padding: 3px 5px;
        min-height: 26px;
    }

    .color-options {
        max-height: 100px;
    }

    .color-dot {
        width: 10px;
        height: 10px;
        min-width: 10px;
    }
}
