/* Source: tpl/core/client/css/canvas.css */
/*
    MerchStudio version 0.01 - Core File
    Gang Sheet Builder Styles
    @author      Hezekiah Dayson
    @version     tpl/core/client/css/canvas.css - 0.01 - 02-17-2026
*/

/* --- Local Theme Variables (Scoped to this App) --- */
/* Default (Light) Mappings */
.gang_sheet_app {
    /* Map local ruler vars to global theme vars from theme.tpl */
    --ruler_bg: #ffffff;            /* Distinct from --bg for contrast */
    --ruler_text: var(--text);      /* Use global text color */
    --ruler_line: var(--line);      /* Use global line color */

    /* Checkerboard colors */
    --check_1: #f0f0f0;
    --check_2: transparent;

    /* Canvas bounding shadow (Dark drop-shadow for Light Mode) */
    --canvas_glow: rgba(0, 0, 0, 0.25);
}

/* Dark Theme Overrides */
/* We target the app container when the HTML tag has data-theme="dark" */
html[data-theme="dark"] .gang_sheet_app {
    --ruler_bg: var(--header_bg);   /* Use header background (#161a1a) */
    --ruler_text: var(--middle_grey);
    --ruler_line: var(--line);

    /* Dark Checkerboard */
    --check_1: #1a1b26;
    --check_2: transparent;

    /* Canvas bounding shadow (White backlight for Dark Mode) */
    --canvas_glow: rgba(255, 255, 255, 0.8);
}

/* --- App Container --- */
.gang_sheet_app {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header_height, 0px));
    background-color: var(--base);
    color: var(--text);
    overflow: hidden;
}

/* --- Header --- */
.app_header {
    height: 64px;
    background-color: var(--bg);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.app_title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.header_right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.price_display {
    font-size: 1.1rem;
    font-weight: 700;
    margin-right: 10px;
    color: var(--accent);
}

.header_left {
    display: flex;
}

/* Builder Logo Link */
.builder_logo_link {
    display: flex;
    align-items: center;
    margin-right: 1.5rem;
    padding-right: 1.5rem;
    border-right: 1px solid var(--line);
    height: 100%;
    text-decoration: none;
    transition: opacity 0.2s ease;
}
.builder_logo_link:hover {
    opacity: 0.7;
}
.builder_logo_link svg,
.builder_logo_link img {
    height: 35px;
    width: auto;
    display: block;
}
.header_user_wrap {
    border-left: 1px solid var(--line);
    padding-left: 12px;
    margin-left: 4px;
    display: flex;
    align-items: center;
}

.app_title {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.price_display {
    font-size: 1.1rem;
    font-weight: 700;
    margin-right: 10px;
    color: var(--accent);
}

/* --- Toolbar --- */
.app_toolbar {
    height: 56px;
    background-color: var(--bg);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    flex-shrink: 0;
}

.tool_group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool_group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--middle_grey);
}

.tool_group input {
    width: 100px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 0.9rem;
}

.select_wrapper.small select {
    padding: 6px 30px 6px 10px;
    width: 80px;
}

/* --- Workspace Layout --- */
.app_workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    display: flex;
    height: 100%;
}

/* --- Sidebar --- */
.app_sidebar {
    width: 280px;
    background-color: var(--bg);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-sizing: border-box;
}

.sidebar_header {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
}

.sidebar_content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
    height: 100%;
}

.empty_state {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--middle_grey);
    font-size: 0.875rem;
    border: 2px dashed var(--line);
    border-radius: 8px;
    padding: 16px;
    box-sizing: border-box;
    width: 100%;
    height: 130px;
    margin: 0;
}


/* Thumbnail Card */
.upload_thumb {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px;
    background: var(--bg);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.canvas-count-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background-color: var(--accent_red);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 5;
    pointer-events: none;
}

.upload_thumb:hover {
    box-shadow: 0 4px 6px var(--shadow);
}

.upload_thumb img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    background-color: var(--base);
    border-radius: 4px;
}

.upload_thumb .thumb_name {
    font-size: 0.75rem;
    color: var(--text);
    margin-top: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Container adjustment to align items better */
.thumb_controls {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Spreads label, input, and buttons out */
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.qty_label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* The Enhanced Input Box */
.qty_input_enhanced {
    width: 110px;      /* Extra width so the numbers + arrows aren't squashed */
    height: 36px;                /* Taller hit area */
    padding: 0 4px 0 8px;        /* Room for the number on the left */
    font-size: 1rem;  /* Larger text for better legibility */
    font-weight: 700;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg-input, #0d0e12);
    color: var(--text);
    outline: none;
}

/* Make the increase/decrease arrows (spinners) much larger */
.qty_input_enhanced::-webkit-inner-spin-button,
.qty_input_enhanced::-webkit-outer-spin-button {
    height: 30px;      /* Increases vertical height of the arrows */
    width: 22px;       /* Widens the clickable area of the arrows */
    opacity: 1;         /* Ensures they are always visible */
    cursor: pointer;
    margin-left: 2px;
}

/* Firefox support for larger arrows */
.qty_input_enhanced {
    appearance: auto;
    -moz-appearance: number-input;
}

/* --- Stage / Canvas with Rulers (Grid Layout) --- */
.app_stage {
    flex: 1;
    background-color: var(--base);
    position: relative;
    /* Define Grid: 30px rulers, remaining space for stage */
    display: grid;
    grid-template-columns: 30px 1fr;
    grid-template-rows: 30px 1fr;
    overflow: hidden; /* Container fixed, inner divs scroll */
}

/* The top-left empty corner */
.ruler_corner {
    grid-column: 1;
    grid-row: 1;
    background-color: var(--ruler_bg);
    border-right: 1px solid var(--ruler_line);
    border-bottom: 1px solid var(--ruler_line);
    z-index: 10;
}

/* Top Ruler (X-Axis) Container */
.ruler_x_wrapper {
    grid-column: 2;
    grid-row: 1;
    overflow: hidden; /* Hides scrollbar, synced via JS */
    background-color: var(--ruler_bg);
    border-bottom: 1px solid var(--ruler_line);
    position: relative;
}

/* Left Ruler (Y-Axis) Container */
.ruler_y_wrapper {
    grid-column: 1;
    grid-row: 2;
    overflow: hidden; /* Hides scrollbar, synced via JS */
    background-color: var(--ruler_bg);
    border-right: 1px solid var(--ruler_line);
    position: relative;
}

/* The actual scrolling area for the canvas */
.stage_scroll_area {
    grid-column: 2;
    grid-row: 2;
    overflow: auto;
    padding: 40px;
    background-color: var(--base);
    position: relative;
}

/* The Visual Canvas */
.canvas_visual {
    background-color: var(--bg); /* Adapts to theme base */
    box-shadow:  0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 0 9px 2px var(--canvas_glow);
    /* Flat borders look better with rulers */
    border-radius: 0;
    position: relative;
    transform-origin: 0 0;

    /* Dynamic Checkerboard */
    background-image:
        linear-gradient(45deg, var(--check_1) 25%, var(--check_2) 25%),
        linear-gradient(-45deg, var(--check_1) 25%, var(--check_2) 25%),
        linear-gradient(45deg, var(--check_2) 75%, var(--check_1) 75%),
        linear-gradient(-45deg, var(--check_2) 75%, var(--check_1) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* Canvas elements inside the ruler wrappers */
canvas.ruler_canvas {
    display: block;
}

/* Zoom Controls in Toolbar */
.zoom_controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--base);
    border-radius: 4px;
    padding: 2px;
    border: 1px solid var(--line);
}

.zoom_controls .value_display { min-width: 45px; text-align: center; font-size: 0.8rem; font-weight: 600; }
/*
#btn_zoom_out, #btn_zoom_in {

} */

.btn_icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.btn_icon:hover {
    background-color: var(--hover);
    color: var(--accent);
}

.btn_icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: transparent;
}

.tool_separator {
    width: 1px;
    height: 24px;
    background-color: var(--line);
    margin: 0 8px;
}

.canvas_empty_msg {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--middle_grey);
    pointer-events: none;
}

.canvas_empty_msg .msg_title { font-size: 1.125rem; margin-bottom: 8px; color: var(--text); }
.canvas_empty_msg .msg_sub { font-size: 0.875rem; }

/* Actual Ruler Canvases */
canvas.ruler_canvas { display: block; }


/* Object Properties (canvas_object_properties.tpl) */
.properties-panel {
    background: var(--bg);
    border-left: 1px solid var(--line);
    width: 280px;
    height: 100%;
    display: flex;
    flex-direction: column;
    color: var(--text);
    font-family: inherit;
}
.properties-header {
    padding: 15px;
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    font-size: 1rem;
}
.properties-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    overflow-y: auto;
}
.prop-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.prop-row {
    display: flex;
    gap: 10px;
}
.prop-row .prop-group {
    flex: 1;
}
.properties-panel label {
    font-size: 0.75rem;
    color: var(--middle_grey);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.properties-panel input {
    background: var(--base);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    width: 100%;
    outline: none;
}
.properties-panel input:focus {
    border-color: var(--accent);
}
.properties-panel input[readonly] {
    background: transparent;
    border: none;
    padding: 0;
    font-weight: 500;
    color: var(--middle_grey);
}
.prop-separator {
    border: 0;
    height: 1px;
    background: var(--line);
    margin: 5px 0;
}
.dpi-badge-large {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.85rem;
    text-align: center;
}

/* --- Bounding Box & Resize Handles --- */
.bounding-box {
    position: absolute;
    cursor: move;
    z-index: 20;
    pointer-events: auto; /* Required to catch direct drag events */
}

/* Draws a perfectly centered 2px border straddling the bounding box edge */
.bounding-box::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border: 2px solid var(--accent);
    pointer-events: none; /* Let clicks pass through to the image/box */
    box-sizing: border-box;
}

.resize-handle {
    position: absolute;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.01); /* Invisible solid paint prevents hit-test pass-through */
    pointer-events: auto;

    /* CRITICAL FIX: Use transform instead of margins to beat global CSS resets */
    transform: translate(-50%, -50%);

    z-index: 21;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The visual dot */
.resize-handle::after {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: 50%;
    box-sizing: border-box;
}

/* Handle cursor mapping */
.resize-handle.nw { cursor: nwse-resize; }
.resize-handle.n  { cursor: ns-resize; }
.resize-handle.ne { cursor: nesw-resize; }
.resize-handle.e  { cursor: ew-resize; }
.resize-handle.se { cursor: nwse-resize; }
.resize-handle.s  { cursor: ns-resize; }
.resize-handle.sw { cursor: nesw-resize; }
.resize-handle.w  { cursor: ew-resize; }

/* Rotation handle updated to match */
.rot_handle {
    position: absolute;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.01);
    pointer-events: auto;
    left: 50%;
    top: -36px;

    /* Center horizontally via transform */
    transform: translate(-50%, 0);

    cursor: grab;
    z-index: 22;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rot_handle:active {
    cursor: grabbing;
}

/* We keep the "stick" connecting the box to the handle */
.rot_handle::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 18px;
    background: var(--accent);
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

/* Hide the old CSS circle */
.rot_handle::after {
    display: none;
}

/* Style the new SVG Icon */
.rot_handle .rot_icon_svg {
    width: 20px;
    height: 20px;
    fill: var(--accent);
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4)); /* Gives the icon a nice premium pop */
    transition: transform 0.1s ease;
}

/* Optional: Slight scaling effect when grabbed */
.rot_handle:active .rot_icon_svg {
    transform: scale(1.1);
}

/* Expand the clickable hit-area of all handles invisibly */
.resize-handle::before {
    content: '';
    position: absolute;
    top: -16px;
    left: -16px;
    right: -16px;
    bottom: -16px;
    background: rgba(0, 0, 0, 0.01);
    border-radius: 50%;
    z-index: 1;
}

/* --- Properties Panel Action Buttons --- */
.prop-actions-row {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.properties-panel button.btn-prop-action {
    flex: 1;
    height: 36px;
    border: 1px solid var(--border-color, #2d3039);
    border-radius: 4px;
    background: transparent; /* Overrides the global white background */
    color: var(--text-primary, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Clears global button padding */
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

/* Force the SVG to center and scale correctly */
.properties-panel button.btn-prop-action svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.properties-panel button.btn-prop-action:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.properties-panel button.btn-prop-action.delete-action {
    border-color: rgba(231, 76, 60, 0.3);
    background-color: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.properties-panel button.btn-prop-action.delete-action:hover {
    background-color: rgba(231, 76, 60, 0.2);
    border-color: rgba(231, 76, 60, 0.5);
}

/* --- Canvas Context Menu --- */
.canvas-context-menu {
    position: fixed;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    min-width: 180px;
    padding: 6px 0;
    z-index: 99999;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
}

.ctx-menu-item {
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.15s;
}

.ctx-menu-item:hover {
    background-color: var(--accent);
    color: #fff;
}

.ctx-menu-item.danger:hover {
    background-color: #e74c3c;
}

.ctx-shortcut {
    color: var(--middle_grey);
    font-size: 0.75rem;
}

.ctx-menu-item:hover .ctx-shortcut {
    color: rgba(255, 255, 255, 0.8);
}

.ctx-divider {
    height: 1px;
    background-color: var(--line);
    margin: 4px 0;
}

/* --- Multi-Sheet Panel --- */
.sheets-panel {
    background: var(--bg);
    border-left: 1px solid var(--line);
    width: 280px;
    height: 100%;
    display: flex;
    flex-direction: column;
    color: var(--text);
    font-family: inherit;
}

.sheets-header {
    padding: 15px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sheets-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar for Sheets Body */
.sheets-body::-webkit-scrollbar { width: 6px; }
.sheets-body::-webkit-scrollbar-track { background: transparent; }
.sheets-body::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

/* Sheet Thumbnail Card */
.sheet-thumb-card {
    background: var(--base);
    border: 2px solid var(--line);
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sheet-thumb-card:hover {
    border-color: var(--middle_grey);
}

.sheet-thumb-card.active {
    border-color: var(--accent);
    background: var(--info_bg);
}

.sheet-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.sheet-meta {
    font-size: 0.75rem;
    color: var(--middle_grey);
}

.sheet-price {
    font-size: 0.85rem;
    color: #34CB79;
    font-weight: bold;
    margin-top: 4px;
}

/* User Avatar Initials */
.user_initials_avatar {
    width: 36px;
    height: 36px;
    background-color: var(--accent);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.drop_trigger:hover .user_initials_avatar {
    transform: scale(1.05);
}

.gang_sheet_app .drop_panel_cont .drop_trigger {
    border: 0;
    background-color: transparent;
}

/* --- Unified Header Actions Alignment --- */
.builder_mode #btn_gs_add_cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 52px;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    background-color: transparent;
    box-shadow: none;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 12px;
    transition: opacity 0.2s ease;
}

.builder_mode #btn_gs_add_cart:hover,
.builder_mode #btn_gs_add_cart:active {
    background: transparent;
    background-color: transparent;
    border: none;
    box-shadow: none;
    opacity: 0.7;
}

/* Vector path optimization inside header action matrices */
.builder_mode #btn_gs_add_cart svg {
    stroke: currentColor;
    fill: none;
    width: 35px;
    height: 35px;
    display: block;
}

/* Figma-style Dashed Upload Button */
.builder_mode #btn_gs_upload {
    background-color: transparent;
    color: var(--middle_grey);
    border: 2px dashed var(--line);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    transition: all 0.2s ease;
    box-shadow: none;
    width: 100%;
    box-sizing: border-box;
    height: 110px;
    margin: 0;
}

.builder_mode #btn_gs_upload:hover {
    background-color: rgba(0,0,0,0.02);
    border-color: var(--middle_grey);
}

html[data-theme="dark"] .builder_mode #btn_gs_upload:hover {
    background-color: rgba(255,255,255,0.02);
}

/* Correctly targets filled icons like #add_icon */
.builder_mode #btn_gs_upload svg {
    fill: currentColor;
    stroke: none;
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.builder_mode #btn_gs_upload span {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
}

/* Canvas Name title input */
.gs_title_input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text, #ffffff);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 4px 8px;
    outline: none;
    width: 250px;
    transition: all 0.2s ease;
}
.gs_title_input:hover, .gs_title_input:focus {
    border-color: var(--line, #333);
    background: rgba(255,255,255,0.05);
}
/* The "little bit grayed out" effect */
.gs_title_input.is_untitled {
    color: var(--text-muted, #888888);
    font-style: italic;
}


/* --- Saved Designs Gallery --- */
.design_row {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 4px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.design_row:hover {
    background-color: rgba(255, 255, 255, 0.03); /* Subtle highlight */
    border-color: var(--middle_grey);
}

html[data-theme="light"] .design_row:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.design_thumbnail {
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.03);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 4px;
    flex-shrink: 0;
}

html[data-theme="dark"] .design_thumbnail {
    background: rgba(255, 255, 255, 0.03);
}

.design_thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.design_thumbnail .empty_thumb {
    font-size: 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.design_thumbnail .empty_thumb .merch_icon {
    width: 40px;
    height: 40px;
    opacity: 0.5;
}

.design_details {
    display: flex;
    flex-direction: column;
    flex: 1; /* Pushes the delete button to the right */
}

.design_name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 1rem;
    color: var(--text);
}

.design_size {
    font-size: 0.85rem;
}

.btn_delete_design {
    margin-left: auto;
    background: transparent;
    border: none;
    padding: 12px;
    cursor: pointer;
    color: var(--accent_red, #dc3545);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.btn_delete_design:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

.btn_delete_design .merch_icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.no_designs_msg {
    padding: 15px;
    text-align: center;
    font-size: 0.9rem;
}


/* --- Smart Alignment Guides - START --- */
.smart-guide {
    position: absolute;
    background-color: #ff00ff; /* High-visibility magenta */
    pointer-events: none; /* Never interfere with the mouse */
    z-index: 9999;
    opacity: 0.7;
    /* Optional: Make it dashed */
    /* background-image: linear-gradient(to bottom, transparent 50%, #ff00ff 50%); background-size: 1px 4px; background-color: transparent; */
}

.smart-guide.vertical {
    width: 1px;
    top: 0;
    bottom: 0;
}

.smart-guide.horizontal {
    height: 1px;
    left: 0;
    right: 0;
}


/* --- Smart Alignment Guides - END --- */

/* Auto-Save Indicator - Start */
.gs_save_status {
    opacity: 0;
    font-size: 0.85rem;
    color: var(--text-muted, #888);
    margin-right: 12px;
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease;
}

.gs_save_status.is_active {
    opacity: 1;
}

.gs_save_status.is_saving {
    animation: pulse_opacity 1.5s infinite;
}

@keyframes pulse_opacity {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Auto-Save Indicator - End */

/* --- Mobile Responsiveness --- */
@media (min-width: 769px) {
    .mobile_menu_toggle {
        display: none;
    }

    /* Dissolve the mobile wrapper on desktop so items become direct flex children */
    .mobile_secondary_tools {
        display: contents;
    }

    /* --- Desktop Toolbar Explicit Reordering --- */
    /* 1. Base Dimensions Configuration */
    .app_toolbar .tool_group:has(#gs_width) { order: 1; }
    .app_toolbar .tool_group:has(#gs_height) { order: 2; }
    .app_toolbar .tool_group:has(#gs_margin) { order: 3; }
    .app_toolbar .tool_group:has(#gs_unit) { order: 4; }

    /* 2. Map First Separator */
    .app_toolbar > .tool_separator { order: 5; }

    /* 3. Target History Group */
    .app_toolbar .tool_group:has(#btn_gs_undo) { order: 6; }

    /* 4. Map Second Separator */
    .app_toolbar > .tool_separator ~ .tool_separator { order: 7; }

    /* 5. Zoom Controls */
    .app_toolbar .tool_group:has(#btn_zoom_in) { order: 8; }

    /* 6. Map Third Separator */
    .app_toolbar > .tool_separator ~ .tool_separator ~ .tool_separator { order: 9; }

    /* 7. Global Canvas Actions */
    .app_toolbar .tool_group:has(#btn_canvas_nest) { order: 10; }
}

@media (max-width: 768px) {
    .gang_sheet_app {
        --drawer_width: 280px;
        position: relative;
    }

    .app_header {
        padding: 0 12px;
    }

    .builder_logo_link {
        margin-right: 0.5rem;
        padding-right: 0.5rem;
    }

    .gs_title_input {
        width: 130px;
        font-size: 1rem;
    }

    /* 1. Header Button Optimization: Compact Add to Cart */
    /* Reduced footprint ensures optimal avatar and login button visibility */
    .builder_mode #btn_gs_add_cart {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0;
        margin: 0;
        width: auto;
        height: auto;
        min-width: 0;
        background: transparent;
        background-color: transparent;
        border: none;
        box-shadow: none;
        cursor: pointer;
        color: var(--text);
        font-family: inherit;
        text-align: center;
    }

    #btn_gs_add_cart span {
        display: block;
        margin-top: 5px;
        padding: 0;
        white-space: nowrap;
        font-size: 11px;
        font-weight: 800;
        line-height: 12px;
        color: var(--text);
    }

    /* Isolate and map style properties onto the raw vector node */
    .builder_mode #btn_gs_add_cart svg {
        fill: none;
        stroke: currentColor;
        width: 30px;
        height: 30px;
        display: block;
        margin: 0 auto;
    }

    /* Provide subtle feedback when tapped on mobile frames */
    #btn_gs_add_cart:active svg {
        transform: scale(0.9);
        transition: transform 0.1s ease;
    }

    .builder_mode #btn_gs_add_cart:hover,
    .builder_mode #btn_gs_add_cart:active {
        background: transparent;
        background-color: transparent;
        border: none;
        box-shadow: none;
    }

    /* Relocate save indicator directly above the active assembly stage */
    .gs_save_status {
        position: absolute;
        top: 12px;
        left: 50%;
        transform: translateX(-50%);
        margin-right: 0;
        z-index: 1010;
        background-color: var(--bg);
        border: 1px solid var(--line);
        padding: 4px 12px;
        border-radius: 20px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    /* Wrap the toolbar tools */
    .app_toolbar {
        height: 56px;
        min-height: 56px;
        flex-wrap: nowrap;
        padding: 0 12px;
        gap: 8px;
        position: relative;
        justify-content: flex-start;
    }

    .tool_separator { display: none; }

    /* 2. The Mobile Menu Icon */
    /* Margin adjusted to pull core tools closer to the toggle button */
    .mobile_menu_toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: transparent;
        border: transparent;
        color: var(--text);
        cursor: pointer;
        margin-right: 8px;
    }

    .mobile_menu_toggle svg {
        width: 30px;
        height: 30px;
        fill: currentColor;
    }

    /* 3. Off-Canvas Secondary Tools (History, Zoom, Nest, Clear) */
    .mobile_secondary_tools {
        box-sizing: border-box;
        position: absolute;
        top: 100%;
        left: 0;
        width: var(--drawer_width);
        background: var(--base);
        z-index: 1002;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 16px;
        gap: 16px;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        border-right: 1px solid var(--line);
        border-bottom: 1px solid var(--line);
    }

    .mobile_secondary_tools .tool_group:has(input),
    .mobile_secondary_tools .tool_group:has(select) {
        width: calc(50% - 8px);
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }

    .mobile_secondary_tools .tool_group input,
    .mobile_secondary_tools .select_wrapper.small select {
        width: 100%;
        flex: 1;
        box-sizing: border-box;
    }

    .tool_group:has(#btn_zoom_in) {
        display: none;
    }

    .mobile_secondary_tools .tool_group:has(#btn_canvas_nest) {
        width: 100%;
        justify-content: flex-start;
    }

    .app_toolbar #gs_price_display {
        margin-left: auto;
        margin-right: 8px;
        font-size: 1.1rem;
        display: flex;
        align-items: center;
    }

    .app_toolbar .tool_group:has(#btn_gs_undo) {
        margin-left: 0;
    }

    .app_toolbar .tool_group:has(#btn_gs_undo) label {
        display: none;
    }

    /* Strip the background and border from the shared controls wrapper */
    .app_toolbar .tool_group:has(#btn_gs_undo) .zoom_controls {
        background: transparent;
        border: none;
        padding: 0;
        gap: 6px;
    }

    /* Force the individual buttons to exactly 36x36px and ensure borders are gone */
    .app_toolbar #btn_gs_undo,
    .app_toolbar #btn_gs_redo {
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        padding: 0;
    }

    /* Scale the SVGs proportionally inside the 36px touch target */
    .app_toolbar #btn_gs_undo svg,
    .app_toolbar #btn_gs_redo svg {
        width: 30px;
        height: 30px;
    }

    /* Trigger sliding drawer via body class */
    body.mobile_drawer_open .mobile_secondary_tools {
        transform: translateX(0);
        box-shadow: 4px 4px 15px rgba(0,0,0,0.3);
    }

    /* 4. Workspace & Sidebar (Bottom Tray Optimization) */
    .app_workspace {
        position: relative;
        flex-direction: column;
    }

    /* Break out of grid flow on mobile viewports to maximize canvas space */
    .app_stage {
        width: 100%;
        order: 1;
        flex: 1;
        display: block;
    }

    /* Purge standard desktop rulers to claim maximum viewport area */
    .ruler_corner,
    .ruler_x_wrapper,
    .ruler_y_wrapper {
        display: none;
    }

    /* Let our canvas scroll area dominate the main interface section */
    .stage_scroll_area {
        width: 100%;
        height: 100%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }

    /* Forces the inner canvas wrapper to center cleanly across device viewports */
    .canvas_wrapper {
        margin: 0;
        display: flex;
        width: auto;
        height: auto;
        max-width: 100%;
        box-sizing: border-box;
    }

    .canvas_visual {
        margin: 0;
        width: 100%;
        height: auto;
        transform-origin: top center;
    }

    /* Clamps parent tray bounds tightly to satisfy row layout constraints */
    .app_sidebar {
        order: 2;
        width: 100%;
        height: 100px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--line);
        position: relative;
        transform: none;
        z-index: 10;
        box-sizing: border-box;
    }

    .sidebar_header {
        box-sizing: border-box;
        width: 100px;
        border-bottom: none;
        border-right: 1px solid var(--line);
        padding: 6px;
        display: flex;
        align-items: stretch;
        justify-content: center;
        flex-shrink: 0;
    }

    .sidebar_header .merch_button {
        height: 45px;
        flex-direction: column;
        gap: 4px;
        padding: 6px 2px;
    }

    .sidebar_header #btn_gs_upload {
        box-sizing: border-box;
        height: 100%;
        width: 100%;
        margin: 0;
        min-width: 0;
        flex-direction: column;
        gap: 2px;
        padding: 6px;
        justify-content: center;
        align-items: center;
    }

    .sidebar_header #btn_gs_upload span {
        font-size: 0.65rem;
        line-height: 1.1;
        white-space: normal;
        text-align: center;
    }

    .sidebar_header #btn_gs_upload svg {
        width: 20px;
        height: 20px;
        margin-bottom: 0;
    }

    .sidebar_header .merch_button span {
        font-size: 0.65rem;
        line-height: 1.1;
        white-space: normal;
        text-align: center;
    }

    /* Fills remainder width completely and provisions native horizontal panning */
    .sidebar_content {
        flex: 1;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px 10px;
        align-items: stretch;
        gap: 10px;
        width: auto;
        box-sizing: border-box;
    }

    .sidebar_content .empty_state {
        height: 100%;
    }

    /* Harmonizes empty state bounds to match the upload button height and alignment */
    html .gang_sheet_app .app_sidebar .sidebar_content > .empty_state {
        box-sizing: border-box;
        height: 100%;
        margin: 0;
        padding: 0 16px;
        flex: 1;
        width: auto;
    }

    /* Scale down item tiles horizontally to prevent horizontal tray clipping */
    .gang_sheet_app .app_sidebar .upload_thumb {
        width: 280px;
        height: auto;
        min-height: 80px;
        flex-shrink: 0;
        display: grid;
        grid-template-columns: 60px 1fr;
        grid-template-rows: auto auto;
        gap: 4px 8px;
        padding: 6px;
        box-sizing: border-box;
    }

    .gang_sheet_app .app_sidebar .upload_thumb img {
        grid-column: 1;
        grid-row: 1 / span 2;
        width: 100%;
        height: auto;
        max-height: 60px;
        object-fit: contain;
        align-self: center;
        margin: 0;
    }

    .gang_sheet_app .app_sidebar .upload_thumb .thumb_dims,
    .gang_sheet_app .app_sidebar .upload_thumb .thumb_controls {
        display: flex;
        grid-column: 2;
        margin: 0;
        padding: 0;
        border: none;
        gap: 6px;
        align-items: center;
        justify-content: flex-start;
    }

    .gang_sheet_app .app_sidebar .upload_thumb .thumb_dims {
        grid-row: 1;
        align-self: end;
    }

    .gang_sheet_app .app_sidebar .upload_thumb .thumb_controls {
        grid-row: 2;
        align-self: start;
    }

    .gang_sheet_app .app_sidebar .upload_thumb .thumb_dims > div {
        flex: 0 0 auto;
    }

    .gang_sheet_app .app_sidebar .upload_thumb input[type="number"] {
        width: 44px;
        padding: 2px 4px;
        font-size: 0.8rem;
        height: 24px;
        box-sizing: border-box;
        margin: 0;
    }

    .gang_sheet_app .app_sidebar .upload_thumb .thumb_controls .btn_icon {
        width: 24px;
        height: 24px;
        padding: 4px;
        margin: 0;
    }

    /* Keep text-only metadata fields suppressed to retain compact tracking height */
    .gang_sheet_app .app_sidebar .upload_thumb .thumb_meta,
    .gang_sheet_app .app_sidebar .upload_thumb .thumb_dpi_badge,
    .gang_sheet_app .app_sidebar .upload_thumb .thumb_name {
        display: none;
    }

    /* Floating Action Sidebar Footer Layout */
    .sidebar_footer {
        position: absolute;
        bottom: 100%;
        right: 12px;
        margin-bottom: 8px;
        z-index: 11;
        width: auto;
    }

    /* Compact button layout overrides desktop constraints */
    .sidebar_footer #btn_gs_add_all {
        min-width: 0;
        width: auto;
        height: 32px;
        padding: 0 12px;
        margin: 0;
        font-size: 0.75rem;
        border-radius: 4px;
        background-color: var(--button_bg);
        color: var(--button_text);
        border: 1px solid var(--button_border);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }

    /* 5. Sheets & Properties Off-Canvas Base */
    .sheets-panel, .properties-panel {
        box-sizing: border-box;
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: var(--drawer_width);
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        border-right: 1px solid var(--line);
    }

    .sheets-header, .properties-header {
        flex-shrink: 0;
    }

    /* Open state for panels */
    body.mobile_drawer_open .sheets-panel.is_open,
    body.mobile_drawer_open .properties-panel.is_open {
        transform: translateX(0);
        box-shadow: 4px 0 15px rgba(0,0,0,0.3);
        padding-top: 190px;
    }
}

