/*
    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;
}

/* 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;
}

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

/* --- Header --- */
.app_header {
    height: 52px;
    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);
}

/* --- 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;
}

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

.sidebar_header {
    padding: 16px;
    border-bottom: 1px solid var(--line);
}

.sidebar_content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty_state {
    text-align: center;
    color: var(--middle_grey);
    margin-top: 30px;
    font-size: 0.875rem;
}

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

.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;
}

/* --- 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.1), 0 0 9px 2px rgb(255 255 255);
    /* 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: 3px;
    color: var(--middle_grey) !important;
}

.btn_icon:hover { background-color: rgba(128,128,128,0.1); }
.btn_icon svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; }

.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; }