﻿/* EditTemplate - toolbar + tabs + 3-panel layout */

/* ========== Wrapper ========== */
.template_editor_wrapper {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 170px);
    min-height: 500px;
    border: 1px solid #ccc;
    border-radius: 4px;
    overflow: hidden;
    background: #f0f0f0;
}

/* ========== Top Toolbar ========== */
.template_editor_toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px 8px;
    background: #323537;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
    min-height: 36px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* overflow-x:auto clips absolute dropdowns — open state must allow the menu to paint. */
.template_editor_toolbar_dropdown_open {
    overflow: visible;
}

.template_editor_wrapper_dropdown_open {
    overflow: visible;
}

.template_editor_toolbar_sep {
    width: 1px;
    height: 22px;
    background: #ccc;
    margin: 0 4px;
    flex-shrink: 0;
}

.template_editor_toolbar_btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background 0.1s, border-color 0.1s;
    flex-shrink: 0;
}

.template_editor_toolbar_btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.template_editor_toolbar_btn:active {
    background: rgba(120,30,73,0.2);
}

.template_editor_toolbar_btn:disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: default;
}

.template_editor_toolbar_btn:disabled:hover {
    background: transparent;
    border-color: transparent;
}

.template_editor_toolbar_btn img {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.template_editor_toolbar_btn:disabled img {
    opacity: 0.3;
}
.template_editor_toolbar_spacer {
    flex: 1;
}

.template_editor_toolbar_btn_active {
    background: rgba(37, 149, 210, 0.25);
    border-color: rgba(37, 149, 210, 0.5);
}

.template_editor_toolbar_brand {
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: 0.02em;
    padding: 0 8px 0 4px;
    white-space: nowrap;
    flex-shrink: 0;
    user-select: none;
    line-height: 1;
}

.template_editor_toolbar_brand_sep {
    width: 1px;
    height: 22px;
    background: #555;
    margin: 0 6px 0 2px;
    flex-shrink: 0;
}

.template_editor_save_group {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    flex-shrink: 0;
    z-index: 20;
}

.template_editor_save_group_open {
    z-index: 1200;
}

.template_editor_save_group .template_editor_toolbar_btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.template_editor_save_caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    padding: 4px 6px;
    font-size: 10px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.85);
    background: transparent;
    border: 1px solid transparent;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0 3px 3px 0;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.template_editor_save_caret:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.template_editor_save_caret:disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: default;
}

.template_editor_save_menu_backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: transparent;
}

.template_editor_save_menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: #2a2d30;
    border: 1px solid #555;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    z-index: 1201;
    padding: 4px 0;
}

.template_editor_save_menu_item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    background: transparent;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}

.template_editor_save_menu_item:hover {
    background: rgba(120, 30, 73, 0.25);
}

.template_editor_save_menu_item:disabled {
    color: rgba(255, 255, 255, 0.35);
    cursor: default;
}

.template_editor_toolbar_live_check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.template_editor_toolbar_live_check input {
    margin: 0;
    accent-color: #781e49;
    cursor: pointer;
}


/* ========== Tab Bar ========== */
.template_editor_tabbar {
    display: flex;
    align-items: flex-end;
    gap: 0;
    padding: 0 8px;
    background: #e0e0e0;
    border-bottom: 1px solid #ccc;
    flex-shrink: 0;
    min-height: 30px;
}

.template_editor_tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 12px;
    color: #666;
    background: #d8d8d8;
    border: 1px solid #c0c0c0;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    user-select: none;
    margin-right: -1px;
    position: relative;
    top: 1px;
    transition: background 0.1s;
    white-space: nowrap;
    max-width: 200px;
}

.template_editor_tab:hover {
    background: #e8e8e8;
}

.template_editor_tab_active {
    background: #f0f0f0;
    color: #333;
    font-weight: 600;
    border-color: #ccc;
    z-index: 1;
}

.template_editor_tab_name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.template_editor_tab_dirty {
    color: #e67e22;
    font-weight: 700;
    margin-left: -2px;
}

.template_editor_tab_close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 14px;
    color: #999;
    background: transparent;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.template_editor_tab:hover .template_editor_tab_close,
.template_editor_tab_active .template_editor_tab_close {
    display: flex;
}

.template_editor_tab_close:hover {
    background: rgba(0,0,0,0.1);
    color: #c0392b;
}

.template_editor_tab_draggable {
    cursor: grab;
}

.template_editor_tab_dragging {
    opacity: 0.45;
    cursor: grabbing;
}

.template_editor_tab_drag_over {
    box-shadow: inset 3px 0 0 #781e49;
}

.template_editor_tab_add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 18px;
    color: #888;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-left: 4px;
    align-self: center;
    flex-shrink: 0;
}

.template_editor_tab_add:hover {
    background: #ccc;
}

/* ========== Main 3-panel layout ========== */
.template_editor_main {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 0;
    overflow: hidden;
    background: #f0f0f0;
}

/* ========== LEFT: Toolbox ========== */
.template_editor_toolbox_wrap {
    flex: 0 0 52px;
    width: 52px;
    min-width: 52px;
    max-width: 52px;
    position: relative;
    z-index: 900;
    overflow: visible;
    display: flex;
    flex-direction: column;
    background: #fff;
}

.template_editor_toolbox_wrap_expanded {
    flex: 0 0 186px;
    width: 186px;
    min-width: 186px;
    max-width: 186px;
    background: #fff;
    border-right: 0 none;
}

.template_editor_toolbox_toggle {
    width: 100%;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0 none;
    border-bottom: 0 none;
    background: #fff;
    color: #555;
    font-size: 11px;
    cursor: pointer;
    padding: 4px 6px;
    flex-shrink: 0;
}

.template_editor_toolbox_toggle:hover {
    background: #f5f5f5;
}

.template_editor_toolbox_toggle_icon {
    font-size: 13px;
    line-height: 1;
}

.template_editor_toolbox_toggle_text {
    display: none;
}

.template_editor_toolbox_wrap_expanded .template_editor_toolbox_toggle {
    justify-content: flex-start;
    padding: 5px 8px;
}

.template_editor_toolbox_wrap_expanded .template_editor_toolbox_toggle_text {
    display: inline;
}

.template_editor_toolbox {
    width: 52px;
    height: calc(100% - 28px);
    background: transparent;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 0;
    gap: 2px;
    box-sizing: border-box;
}

.template_editor_toolbox_btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 46px;
    padding: 6px 2px;
    margin: 0;
    border: 0 none;
    border-radius: 6px;
    background: none;
    color: #666;
    font-size: 9px;
    font-weight: 400;
    cursor: pointer;
    line-height: 1.1;
    text-align: center;
    outline: none;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
}

.template_editor_toolbox_btn span {
    display: block;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template_editor_toolbox_btn:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

.template_editor_toolbox_btn_active {
    color: #781e49;
    background: #f3e6ed;
}

.template_editor_toolbox_btn:focus {
    outline: none;
    box-shadow: none;
}

.template_editor_toolbox_btn img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.template_editor_toolbox_popup_cat_0 {
    top: 32px;
}

.template_editor_toolbox_popup_cat_1 {
    top: 87px;
}

.template_editor_toolbox_popup {
    position: absolute;
    left: 100%;
    width: 190px;
    background: rgba(255, 255, 255, 0.96);
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    z-index: 999999;
    overflow: hidden;
}

.template_editor_toolbox_expanded {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2px 0 6px;
    background: #fff;
}

.template_editor_toolbox_expanded_group {
    margin-bottom: 2px;
}

.template_editor_toolbox_expanded_header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    background: #d7e5ec;
    color: #1c2f3a;
    font-size: 12px;
    font-weight: 600;
    border: 0 none;
    width: 100%;
    cursor: pointer;
    text-align: left;
}

.template_editor_toolbox_expanded_header:hover {
    background: #cfe0e8;
}

.template_editor_toolbox_expanded_header_left {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.template_editor_toolbox_expanded_toggle {
    display: inline-flex;
    width: 14px;
    justify-content: center;
    font-weight: 700;
}

.template_editor_toolbox_expanded_header img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

.template_editor_toolbox_expanded_item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 12px;
    border: 0 none;
    background: transparent;
    text-align: left;
    font-size: 12px;
    color: #222;
    cursor: pointer;
}

.template_editor_toolbox_expanded_item img {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
}

.template_editor_toolbox_expanded_item:hover {
    background: #ececec;
}

.template_editor_toolbox_expanded_item:disabled {
    color: #888;
    cursor: default;
}

.template_editor_toolbox_expanded_item:disabled img {
    opacity: 0.6;
}

.template_editor_toolbox_expanded_item:disabled:hover {
    background: transparent;
}

.template_editor_toolbox_popup_header {
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    color: #1c2f3a;
    background: #d7e5ec;
    border: 0 none;
}

.template_editor_toolbox_popup_list {
    padding: 2px 0;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.template_editor_toolbox_item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    color: #222;
    background: none;
    border: 0 none;
    text-align: left;
    cursor: pointer;
    outline: none;
    box-shadow: none;
    appearance: none;
    -webkit-appearance: none;
    transition: background 0.1s;
}

.template_editor_toolbox_item img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    flex-shrink: 0;
}

.template_editor_toolbox_item:hover {
    background: #ececec;
}

.template_editor_toolbox_item:focus {
    outline: none;
    box-shadow: none;
}

.template_editor_toolbox_item:disabled {
    color: #888;
    cursor: default;
}

.template_editor_toolbox_item:disabled img {
    opacity: 0.6;
}

.template_editor_toolbox_item:disabled:hover {
    background: transparent;
    color: #888;
}

/* ========== CENTER: Canvas area ========== */
.template_editor_center {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    height: 100%;
    position: relative;
}

/* DesignCanvas layout (global — must not rely on Blazor scoped CSS isolation).
   Same structure as q.track: host column → viewport flex:1 relative → container absolute inset → zoombar bottom. */
.design_canvas_host {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.design_canvas_viewport {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.design_canvas_container {
    position: absolute;
    inset: 0;
    overflow: auto;
    background: #e0e0e0;
}

.design_canvas_zoombar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    flex: 0 0 auto;
    min-height: 32px;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

.design_canvas_zoom_fit,
.design_canvas_zoom_step {
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #fff;
    color: #666;
    cursor: pointer;
}

.design_canvas_zoom_fit {
    padding: 2px 8px;
    font-size: 11px;
    white-space: nowrap;
}

.design_canvas_zoom_active {
    border-color: #781e49;
    background: #f3e6ed;
    color: #781e49;
    font-weight: 600;
}

.design_canvas_zoom_step {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.design_canvas_zoom_value,
.design_canvas_zoom_size {
    font-family: Consolas, monospace;
    color: #666;
    font-size: 11px;
}

.design_canvas_zoom_size {
    font-size: 10px;
    color: #999;
    min-width: 72px;
}

/* Photos must live here (global). App.razor does not load Blazor scoped CSS,
   so DesignCanvas.razor.css never applies — images would keep their intrinsic
   size while zoom only shrinks the surface (same as q.track inline styles). */
.design_canvas_background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 0;
}

.design_canvas_media,
.design_canvas_iframe {
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    display: block;
    border: none;
}

.design_canvas_media_host,
.design_canvas_placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    pointer-events: none;
}

.design_canvas_object:hover {
    box-shadow: none;
    outline: 1px solid rgba(120, 30, 73, 0.5);
    outline-offset: 0;
}

.design_canvas_object_selected,
.design_canvas_object_selected:hover {
    box-shadow: none;
    outline: 1px solid #781e49;
    outline-offset: 0;
}

/* Outline overlay — global. Scoped DesignCanvas.razor.css is not loaded, so
   border-style:solid must live here or the ring never paints. */
.design_canvas_object_border {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
    border-style: solid;
    pointer-events: none;
    z-index: 5;
}

/* Resize handles - global so they always paint (same idea as q.track inline styles). */
.design_canvas_handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid #781e49;
    border-radius: 2px;
    z-index: 20;
    pointer-events: auto;
    box-sizing: border-box;
}

.design_canvas_handle_nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.design_canvas_handle_ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.design_canvas_handle_sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.design_canvas_handle_se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

/* ========== RIGHT: Properties panel ========== */
.template_editor_properties {
    flex: 0 0 48px;
    min-width: 48px;
    max-width: 48px;
    overflow: hidden;
    border-left: 1px solid #ccc;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    transition: flex-basis 0.15s ease, min-width 0.15s ease, max-width 0.15s ease;
}

.template_editor_properties_expanded {
    flex: 0 0 320px;
    min-width: 320px;
    max-width: 320px;
}

.template_editor_properties_collapsed {
    flex: 0 0 48px;
    min-width: 48px;
    max-width: 48px;
}

.template_editor_properties_visible {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 12px 12px;
    box-sizing: border-box;
}

.template_editor_prop_header {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 0;
    padding: 6px 12px;
    border-bottom: 2px solid #781e49;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-sizing: border-box;
    min-height: 32px;
}

.template_editor_prop_close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.template_editor_prop_close:hover {
    color: #333;
}

.template_editor_prop_section {
    margin-bottom: 14px;
}

.template_editor_prop_section_title {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: #666;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

.template_editor_layout_name_readonly {
    background: #f1f3f5;
    color: #495057;
    cursor: default;
}

.template_editor_layout_order_row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.template_editor_layout_order_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    background: #e0e0e0;
    color: #333;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.template_editor_layout_order_btn:hover:not(:disabled) {
    background: #ccc;
}

.template_editor_layout_order_btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.template_editor_layout_delete_btn {
    background: #fff;
    border-color: #e74c3c;
    color: #e74c3c;
}

.template_editor_layout_delete_btn:hover:not(:disabled) {
    background: #fdecea;
}

.template_editor_prop_actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.template_editor_action_btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    height: 30px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.18);
    background: #781e49;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    flex-shrink: 0;
    width: auto;
    min-width: fit-content;
    cursor: pointer;
    box-sizing: border-box;
    transition: background 0.2s;
}

.template_editor_action_btn:hover {
    background: #5a1636;
}

.template_editor_no_selection {
    color: #999;
    text-align: center;
    padding: 40px 16px;
    font-size: 13px;
}

/* ========== Color picker controls ========== */
.template_editor_color_row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.template_editor_color_swatch {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid #ccc;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

.template_editor_color_swatch:hover {
    border-color: #781e49;
    box-shadow: 0 0 0 2px rgba(120,30,73,0.2);
}

.template_editor_color_input {
    width: 0;
    height: 0;
    padding: 0;
    border: none;
    opacity: 0;
    position: absolute;
    pointer-events: none;
}

.template_editor_color_hex {
    flex: 1;
    height: 30px;
    font-size: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
    padding: 0 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    color: #333;
    text-transform: uppercase;
    min-width: 0;
    box-sizing: border-box;
    line-height: 28px;
}

.template_editor_color_hex:focus {
    border-color: #781e49;
    outline: none;
    background: #fff;
}

.template_editor_opacity_row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.template_editor_opacity_slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, transparent, var(--slider-color, #781e49));
    border-radius: 3px;
    border: 1px solid #0000001a;
    outline: none;
    cursor: pointer;
}

.template_editor_opacity_slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #781e49;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.template_editor_opacity_slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #781e49;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.template_editor_opacity_value {
    font-size: 11px;
    min-width: 36px;
    text-align: right;
    color: #666;
    font-weight: 600;
}

.template_editor_radius_slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #ddd, #888);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.template_editor_radius_slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #666;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.template_editor_radius_slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #666;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ========== Per-corner radius editor (Illustrator-style) ========== */
.template_editor_corners {
    display: flex;
    justify-content: center;
    padding: 4px 0 6px 0;
}

.template_editor_corner_grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 8px;
    align-items: center;
    width: 100%;
    max-width: 240px;
}

.template_editor_corner_cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

.template_editor_corner_cell_tl,
.template_editor_corner_cell_bl {
    grid-column: 1;
    justify-content: flex-start;
}

.template_editor_corner_cell_tr,
.template_editor_corner_cell_br {
    grid-column: 3;
    justify-content: flex-end;
}

.template_editor_corner_cell_tl { grid-row: 1; }
.template_editor_corner_cell_tr { grid-row: 1; }
.template_editor_corner_cell_bl { grid-row: 2; }
.template_editor_corner_cell_br { grid-row: 2; }

.template_editor_corner_icon {
    color: #888;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.template_editor_corner_icon img,
.template_editor_corner_link img {
    width: 14px;
    height: 14px;
    display: block;
}

.template_editor_corner_input {
    width: 56px;
    height: 26px;
    padding: 0 6px;
    font-size: 12px;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    box-sizing: border-box;
}

.template_editor_corner_input:focus {
    outline: none;
    border-color: #781e49;
    box-shadow: 0 0 0 2px rgba(120,30,73,0.15);
}

.template_editor_corner_link_wrap {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.template_editor_corner_link {
    width: 26px;
    height: 26px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f5f5f5;
    color: #888;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.template_editor_corner_link:hover {
    background: #ececec;
    color: #555;
}

.template_editor_corner_link_on {
    background: #781e49;
    border-color: #781e49;
    color: #fff;
}

.template_editor_corner_link_on:hover {
    background: #5a1636;
    color: #fff;
}

/* ========== FontPicker / ImagePicker: no borders (override Bootstrap) ========== */
.template_editor_properties .font_picker_trigger,
.template_editor_properties .font_picker_search,
.template_editor_properties .font_picker_dropdown,
.template_editor_properties .font_picker_item,
.template_editor_properties .font_picker_search_clear,
.template_editor_properties .img_picker_trigger,
.template_editor_properties .img_picker_search,
.template_editor_properties .img_picker_dropdown,
.template_editor_properties .img_picker_item,
.template_editor_properties .img_picker_preview,
.template_editor_properties .img_picker_item_thumb {
    border: none !important;
}

.template_editor_properties .font_picker_trigger:focus,
.template_editor_properties .font_picker_search:focus,
.template_editor_properties .img_picker_trigger:focus,
.template_editor_properties .img_picker_search:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ========== Ticket template canvas (q.track) ========== */
.ticket_template_editor .template_editor_toolbox_wrap {
    background: transparent;
}

.ticket_template_editor .template_editor_toolbox_wrap_expanded {
    background: #f3f3f3;
}

.ticket_template_editor .template_editor_toolbox_toggle {
    background: #ececec;
}

.ticket_template_editor .template_editor_prop_section {
    margin-bottom: 4px;
}

.ticket_template_editor .template_editor_prop_section + .template_editor_prop_section {
    padding-top: 12px;
    border-top: 1px solid #eee;
}

.ticket_template_editor .template_editor_prop_section_title {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: #555;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #2595D2;
}

.ticket_canvas_area {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 16px;
    background: #e0e0e0;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
    background-size: 20px 20px;
    box-sizing: border-box;
}

.ticket_canvas_receipt {
    width: 340px;
    min-height: 200px;
    flex-shrink: 0;
    align-self: flex-start;
    background: #fff;
    border-radius: 2px;
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.15),
        0 1px 4px rgba(0, 0, 0, 0.08);
    padding: 20px 16px;
    font-family: "Courier New", Courier, monospace;
    font-size: 13px;
    color: #000;
    position: relative;
}

.ticket_canvas_receipt::before,
.ticket_canvas_receipt::after {
    content: "";
    display: block;
    height: 8px;
    margin: 0 -16px;
}

.ticket_canvas_receipt::before {
    margin-top: -20px;
    margin-bottom: 12px;
    background: repeating-linear-gradient(90deg, transparent, transparent 4px, #e0e0e0 4px, #e0e0e0 8px);
}

.ticket_canvas_receipt::after {
    margin-bottom: -20px;
    margin-top: 12px;
    background: repeating-linear-gradient(90deg, transparent, transparent 4px, #e0e0e0 4px, #e0e0e0 8px);
}

.ticket_canvas_receipt_upside {
    transform: rotate(180deg);
}

.ticket_canvas_empty {
    padding: 40px 16px;
    text-align: center;
    color: #aaa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    margin: 8px 0;
}

.ticket_canvas_empty p {
    margin: 4px 0;
}

.ticket_canvas_element {
    position: relative;
    padding: 6px 8px;
    margin: 0 -4px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.ticket_canvas_element:hover {
    border-color: rgba(37, 149, 210, 0.3);
    background: rgba(37, 149, 210, 0.02);
}

.ticket_canvas_element_selected {
    border-color: #2595D2;
    background: rgba(37, 149, 210, 0.05);
    box-shadow: 0 0 0 1px rgba(37, 149, 210, 0.15);
}

.ticket_canvas_element_disabled {
    opacity: 0.35;
}

.ticket_canvas_element_actions {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    opacity: 0;
    transition: opacity 0.15s;
}

.ticket_canvas_element:hover .ticket_canvas_element_actions,
.ticket_canvas_element_selected .ticket_canvas_element_actions {
    opacity: 1;
}

.ticket_canvas_move_btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 18px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #aaa;
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.1s;
}

.ticket_canvas_move_btn:hover:not(:disabled) {
    background: rgba(37, 149, 210, 0.12);
    color: #2595D2;
    transform: scale(1.15);
}

.ticket_canvas_move_btn:active:not(:disabled) {
    background: rgba(37, 149, 210, 0.22);
    color: #1a7db5;
    transform: scale(0.95);
}

.ticket_canvas_move_btn:disabled {
    opacity: 0.15;
    cursor: default;
}

.ticket_canvas_element_badge {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: rgba(37, 149, 210, 0.7);
    padding: 1px 5px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ticket_canvas_element:hover .ticket_canvas_element_badge,
.ticket_canvas_element_selected .ticket_canvas_element_badge {
    opacity: 1;
}

.ticket_canvas_badge_qr {
    background: rgba(46, 125, 50, 0.75);
}

.ticket_canvas_off_badge {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    font-size: 8px;
    font-weight: 700;
    color: #c00;
    background: rgba(255, 255, 255, 0.85);
    padding: 1px 4px;
    border-radius: 2px;
    letter-spacing: 0.5px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    pointer-events: none;
}

.ticket_canvas_content {
    flex: 1;
    word-break: break-word;
    min-height: 16px;
}

.ticket_canvas_align_left {
    text-align: left;
}

.ticket_canvas_align_center {
    text-align: center;
}

.ticket_canvas_align_right {
    text-align: right;
}

.ticket_canvas_align_left .ticket_canvas_media {
    margin-left: 0;
    margin-right: auto;
}

.ticket_canvas_align_center .ticket_canvas_media {
    margin-left: auto;
    margin-right: auto;
}

.ticket_canvas_align_right .ticket_canvas_media {
    margin-left: auto;
    margin-right: 0;
}

.ticket_canvas_text {
    font-size: 13px;
}

.ticket_canvas_text_font_b {
    font-family: monospace;
    font-size: 11px;
}

.ticket_canvas_text_bold {
    font-weight: 700;
}

.ticket_canvas_text_underline {
    text-decoration: underline;
}

.ticket_canvas_text_double {
    font-size: 22px;
    letter-spacing: 2px;
}

.ticket_canvas_inverse {
    display: block;
    background: #000;
    color: #fff;
    padding: 4px 8px;
    margin: 0 -8px;
    width: calc(100% + 16px);
    box-sizing: border-box;
}

.ticket_canvas_image {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px;
    border: 1px dashed #ccc;
    border-radius: 4px;
    background: #fafafa;
    width: 80%;
}

.ticket_canvas_image_fit {
    width: 100%;
}

.ticket_canvas_image_icon {
    font-size: 28px;
    line-height: 1;
}

.ticket_canvas_image_caption {
    font-size: 10px;
    color: #999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ticket_canvas_qr {
    width: 88px;
    height: 88px;
    border: 4px solid #111;
    background:
        repeating-linear-gradient(90deg, #111 0 10px, #fff 10px 20px),
        repeating-linear-gradient(#111 0 10px, #fff 10px 20px);
    background-blend-mode: difference;
}

.ticket_canvas_qr_caption {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    color: #999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ticket_canvas_feed {
    position: relative;
}

.ticket_canvas_feed_h_0 { height: 0; }
.ticket_canvas_feed_h_1 { height: 8px; }
.ticket_canvas_feed_h_2 { height: 16px; }
.ticket_canvas_feed_h_3 { height: 24px; }
.ticket_canvas_feed_h_4 { height: 32px; }
.ticket_canvas_feed_h_5 { height: 40px; }
.ticket_canvas_feed_h_6 { height: 48px; }
.ticket_canvas_feed_h_7 { height: 56px; }
.ticket_canvas_feed_h_8 { height: 64px; }
.ticket_canvas_feed_h_9 { height: 72px; }
.ticket_canvas_feed_h_10 { height: 80px; }
.ticket_canvas_feed_h_11 { height: 88px; }
.ticket_canvas_feed_h_12 { height: 96px; }
.ticket_canvas_feed_h_13 { height: 104px; }
.ticket_canvas_feed_h_14 { height: 112px; }
.ticket_canvas_feed_h_15 { height: 120px; }
.ticket_canvas_feed_h_16 { height: 128px; }
.ticket_canvas_feed_h_17 { height: 136px; }
.ticket_canvas_feed_h_18 { height: 144px; }
.ticket_canvas_feed_h_19 { height: 152px; }
.ticket_canvas_feed_h_20 { height: 160px; }

.ticket_canvas_feed_global {
    border-top: 1px dashed #ccc;
}

.ticket_canvas_feed_label {
    position: absolute;
    right: 0;
    top: 0;
    font-size: 9px;
    color: #bbb;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ticket_canvas_cut_line {
    border-top: 2px dashed #999;
    text-align: center;
    padding-top: 6px;
    margin-top: 6px;
    font-size: 11px;
    color: #999;
}

.ticket_prop_field {
    margin-bottom: 12px;
}

.ticket_prop_field > label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.ticket_prop_textarea {
    resize: vertical;
    min-height: 50px;
    width: 100%;
    font-family: "Courier New", Courier, monospace;
    font-size: 12px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-sizing: border-box;
}

.ticket_prop_field_row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #eee;
}

.ticket_prop_field_row label {
    font-size: 12px;
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    cursor: pointer;
}

.ticket_prop_field_row label input[type="checkbox"] {
    margin: 0;
}

.ticket_prop_check_label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #eee;
    transition: background 0.1s, border-color 0.1s;
}

.ticket_prop_check_label:hover {
    background: #eef5fa;
    border-color: #d0e3ee;
}

.ticket_prop_check_label input[type="checkbox"] {
    margin: 0;
}

.ticket_prop_field_grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.ticket_prop_field_grid .ticket_prop_field {
    margin-bottom: 0;
}

.ticket_prop_variables {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.ticket_prop_var_btn {
    padding: 3px 7px;
    font-size: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f5f5f5;
    cursor: pointer;
    color: #555;
    font-family: "Courier New", Courier, monospace;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.ticket_prop_var_btn:hover:not(:disabled) {
    background: #2595D2;
    color: #fff;
    border-color: #2595D2;
}

.ticket_prop_var_btn:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ========== Responsive (tablet / mobile) ========== */
@media (max-width: 1024px) {
    .template_editor_wrapper {
        height: calc(100dvh - 56px);
        min-height: 0;
        border-radius: 0;
    }

    .template_editor_main {
        flex-direction: column;
    }

    .template_editor_toolbox_wrap,
    .template_editor_toolbox_wrap_expanded {
        flex: 0 0 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        border-right: none !important;
        border-bottom: 1px solid #ddd;
        max-height: 220px;
    }

    .template_editor_toolbox {
        width: 100% !important;
        height: auto !important;
        max-height: 180px;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: flex-start !important;
        align-items: flex-start !important;
        padding: 6px 8px !important;
    }

    .template_editor_toolbox_btn {
        width: auto !important;
        min-width: 52px;
    }

    .template_editor_toolbox_popup {
        left: 8px !important;
        top: auto !important;
        margin-top: 4px;
        max-width: calc(100vw - 24px);
    }

    .template_editor_center {
        flex: 1 1 auto;
        min-height: 280px;
        width: 100%;
    }

    .template_editor_properties_expanded,
    .template_editor_properties_collapsed {
        flex: 0 0 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        border-left: none !important;
        border-top: 1px solid #ccc;
    }

    .template_editor_properties_expanded {
        max-height: min(45vh, 420px);
    }

    .template_editor_properties_collapsed {
        max-height: 40px;
    }
}

@media (max-width: 768px) {
    .template_editor_toolbar {
        flex-wrap: nowrap;
        gap: 4px;
        padding: 6px 8px;
    }

    .template_editor_toolbar_btn {
        padding: 6px;
        font-size: 0;
    }

    .template_editor_toolbar_btn img {
        width: 18px;
        height: 18px;
        opacity: 0.9;
    }

    .template_editor_toolbar > span.template_editor_toolbar_filename {
        display: none;
    }

    .template_editor_tab {
        max-width: 140px;
        padding: 5px 10px;
    }

    .template_editor_toolbox_wrap,
    .template_editor_toolbox_wrap_expanded {
        max-height: 200px;
    }

    .template_editor_center {
        min-height: 240px;
    }
}
