/* SVG Editor Modal */
#svgEditorModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 120vh;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

#svgEditorModal .modal-content {
    max-width: 100vw !important;
    max-height: 100vh !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overscroll-behavior: contain;
}

/* Header */
.svg-editor-header {
    flex-shrink: 0;
    background: var(--header-dark-bg, #2d3748);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.svg-editor-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.svg-editor-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.svg-editor-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    margin: 0;
}

/* Buttons */
.svg-editor-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.svg-editor-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.svg-editor-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(0);
}

.svg-editor-btn img {
    width: 18px;
    height: 18px;
    filter: brightness(0) invert(1);
}

.svg-editor-close {
    color: white;
    opacity: 0.9;
    font-size: 2rem;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
}

.svg-editor-close:hover {
    opacity: 1;
}

/* Main Container */
.svg-editor-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
}

/* Sidebar */
.svg-editor-sidebar {
    width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.svg-editor-sidebar-list {
    padding: 15px;
}

.svg-editor-item {
    padding: 12px;
    margin-bottom: 8px;
    background: var(--surface2);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.svg-editor-item:hover {
    background: var(--surface-border);
}

.svg-editor-item.active {
    border: 2px solid var(--accent);
    background: var(--hover-bg);
}

.svg-editor-item.unsaved {
    background: var(--hover-bg);
    border: 2px solid var(--accent);
}

.svg-editor-item.unsaved:hover {
    background: var(--hover-bg);
}

.svg-editor-item-name {
    font-weight: 600;
    color: var(--text-ui);
    font-size: 0.9rem;
}

/* Main Content */
.svg-editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--background);
    min-width: 0;
    box-sizing: border-box;
}

/* Toolbar */
.svg-editor-toolbar {
    background: var(--surface);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-sizing: border-box;
}

.svg-editor-current-case {
    display: none;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.svg-editor-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.svg-editor-toolbar-right {
    display: flex;
    gap: 8px;
}

.svg-editor-zoom-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.svg-editor-zoom-slider {
    width: 120px;
    cursor: pointer;
}

.svg-editor-zoom-value {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 45px;
}

.svg-editor-toolbar .svg-editor-btn {
    background: var(--surface2);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.svg-editor-toolbar .svg-editor-btn:hover {
    background: var(--surface-border);
    border-color: var(--border-color);
}

.svg-editor-toolbar .svg-editor-btn img {
    width: 18px;
    height: 18px;
    filter: none;
}

/* Canvas */
.svg-editor-canvas {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.svg-editor-canvas-content {
    position: relative;
    background: var(--surface);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transform-origin: center;
    transition: transform 0.2s;
}

.svg-editor-empty {
    text-align: center;
    color: var(--text-secondary);
}

.svg-editor-empty h2 {
    margin-bottom: 10px;
}

.svg-editor-empty p {
    margin-bottom: 15px;
}

/* Mobile Sidebar Toggle */
.svg-editor-sidebar-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Mobile Overlay */
.svg-editor-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 120vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Tablet Styles (571px - 999px) */
@media (min-width: 571px) and (max-width: 999px) {
    .svg-editor-sidebar {
        width: 30vw;
        min-width: 200px;
        max-width: 280px;
    }
}

/* Hide zoom below 720px */
@media (max-width: 720px) {
    .svg-editor-toolbar-left {
        display: none !important;
    }
}

/* Mobile Styles (below 570px) */
@media (max-width: 570px) {
    .svg-editor-sidebar-toggle {
        display: block;
    }

    .svg-editor-sidebar {
        position: fixed;
        top: 13vw;
        left: 0;
        height: calc(100% - 13vw);
        width: 70vw;
        max-width: 280px;
        z-index: 2;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
    }

    .svg-editor-sidebar.open {
        transform: translateX(0);
    }

    .svg-editor-sidebar.open ~ .svg-editor-overlay {
        display: block;
    }

    .svg-editor-header {
        padding: 2.5vw 3vw;
    }

    .svg-editor-header-left {
        gap: 2vw;
        min-width: 0;
        flex: 1;
    }

    .svg-editor-header-right {
        gap: 1.5vw;
        flex-shrink: 0;
    }

    .svg-editor-title {
        font-size: 3.8vw;
        white-space: nowrap;
    }

    .svg-editor-title::after {
        content: "Edit Image";
    }

    .svg-editor-title-text {
        display: none;
    }

    .svg-editor-btn {
        width: 7vw;
        height: 7vw;
        min-width: 26px;
        min-height: 26px;
        max-width: 32px;
        max-height: 32px;
        padding: 0;
    }

    .svg-editor-header .svg-editor-btn {
        background: rgba(255, 255, 255, 0.2);
    }

    .svg-editor-header .svg-editor-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }

    .svg-editor-header .svg-editor-btn img {
        width: 3.5vw;
        height: 3.5vw;
        min-width: 14px;
        min-height: 14px;
        max-width: 16px;
        max-height: 16px;
        filter: brightness(0) invert(1);
    }

    .svg-editor-close {
        font-size: 5.5vw;
        width: 7vw;
        height: 7vw;
        min-width: 26px;
        min-height: 26px;
        max-width: 32px;
        max-height: 32px;
    }

    .svg-editor-sidebar-toggle {
        padding: 1vw 2.5vw;
        font-size: 3.5vw;
        border-radius: 3px;
    }

    .svg-editor-toolbar {
        padding: 2vw 3vw;
        gap: 2vw;
        flex-wrap: nowrap;
    }

    .svg-editor-toolbar-left {
        display: none;
    }

    .svg-editor-toolbar-right {
        gap: 1.5vw;
        flex-shrink: 0;
    }

    .svg-editor-toolbar .svg-editor-btn img {
        width: 3.5vw;
        height: 3.5vw;
        min-width: 14px;
        min-height: 14px;
        max-width: 16px;
        max-height: 16px;
    }

    .svg-editor-canvas-content {
        padding: 4vw;
    }

    .svg-editor-item {
        padding: 3vw;
        margin-bottom: 2vw;
    }

    .svg-editor-item-name {
        font-size: 3.5vw;
    }

    .svg-editor-sidebar-list {
        padding: 3vw;
    }

    .svg-editor-empty h2 {
        font-size: 5vw;
    }

    .svg-editor-empty p {
        font-size: 3.5vw;
    }

    .svg-editor-current-case {
        display: block !important;
        font-size: 3.2vw;
        color: var(--text-secondary);
        font-weight: 600;
        flex: 1;
        min-width: 0;
    }
}

/* ── Dark-mode: SVG editor toolbar icons ───────────────────── */
/* The header buttons already use brightness(0) invert(1) always  */
/* (they sit on the permanently dark header). Toolbar buttons use  */
/* filter:none and need inversion only in dark mode.               */
/* html[data-theme="dark"] gives specificity (0,3,1) which beats   */
/* the toolbar's .svg-editor-toolbar .svg-editor-btn img (0,2,1).  */
html[data-theme="dark"] .svg-editor-toolbar .svg-editor-btn img {
    filter: invert(1);
}
