/* Loaded only on screens up to 900px wide (see the media attribute on its <link>).
   Layout: the shirt fills the screen, the toolbar sits at the bottom, and a panel
   slides up OVER the shirt when a tool is tapped, then slides back down. */

body.designer-page {
    min-height: 0;                    /* cancels a "min-height: 100vh" from site.css, which is taller than the visible screen */
    max-height: var(--app-h, 100dvh);
    margin: 0;
    position: fixed;
    top: var(--app-top, 0px);
    right: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    height: var(--app-h, 100dvh);   /* the visible height, measured by mobile.js */
    overflow: hidden;
    overscroll-behavior: none;
    display: flex;
    flex-direction: column;
}

body.designer-page .site-nav { flex: 0 0 auto; }

body.designer-page .nav-inner {
    min-height: 48px;
    flex-wrap: nowrap;
    padding-top: 0;
    padding-bottom: 0;
}

body.designer-page .lang-toggle { margin-left: auto; }

body.designer-page .progress-steps,
body.designer-page footer.footer,
body.designer-page .canvas-hint,
body.designer-page .designer-sidebar h3,
body.designer-page .desktop-only { display: none; }

body.designer-page .page-main {
    flex: 1 1 auto;
    min-height: 0;
    max-width: none;
    padding: 0;
    display: flex;
}

.designer-layout {
    position: relative;      /* the panel is positioned inside it */
    overflow: hidden;        /* a closed panel hides below the toolbar */
    flex: 1;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Shirt area: takes all the space that is left ---------- */
.designer-canvas-area {
    order: 1;
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    overflow: hidden;
    justify-content: flex-start;
}

.mobile-side-toggle {
    display: flex;
    justify-content: center;
    padding: 4px 0 2px;
}

.mobile-side-toggle .side-btn {
    flex: 0 0 120px;
    min-height: 34px;
    font-size: 0.85rem;
}

.mobile-side-toggle .side-btn + .side-btn { margin-left: -1px; }

.canvas-stage {
    flex: 1 1 0;
    min-height: 0;
    padding: 0;
    align-items: center;
}

#canvasWrapper {
    border: 0;
    background: transparent;
}

.canvas-container, .canvas-container canvas { touch-action: none; }

.canvas-empty-hint {
    display: none;
    position: absolute;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    width: max-content;
    max-width: 88%;
    padding: 0.5rem 0.9rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    pointer-events: none;
}

.canvas-empty-hint.visible { display: block; }

/* ---------- The panel that slides up over the shirt ---------- */
.designer-sidebar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--toolbar-h, 72px);      /* sits right above the toolbar (set by mobile.js) */
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-height: 52vh;
    max-height: min(52dvh, 480px);
    max-height: min(52dvh, 480px, var(--sheet-max, 999px));
    padding: 0;
    overflow: hidden;
    background: var(--white);
    border: 1px solid var(--border);
    border-width: 1px 0 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.16);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 0.26s ease, visibility 0s linear 0.26s;
}

.designer-layout.sheet-open .designer-sidebar {
    transform: translateY(0);
    visibility: visible;
    transition: transform 0.26s ease, visibility 0s;
}

/* The little grey bar at the top of the panel */
.designer-sidebar::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 44px;
    height: 5px;
    margin-left: -22px;
    border-radius: 3px;
    background: var(--border-strong);
}

.designer-sidebar .panel { display: none; }

.designer-sidebar .panel.active {
    display: block;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 28px 1rem 1.1rem;
}

.sheet-title {
    display: block;
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.9rem;
    padding-right: 5.5rem;
}

.sheet-close {
    display: block;
    position: absolute;
    top: 14px;
    right: 0.75rem;
    z-index: 2;
    min-height: 38px;
    padding: 0 1rem;
    background: var(--black);
    color: var(--white);
    border: 1px solid var(--black);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
}

.m-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: 0.9rem 0 0.4rem;
}

.designer-sidebar select,
.designer-sidebar input[type="text"] {
    font-size: 16px; /* 16px stops iPhones from zooming the page on focus */
    min-height: 46px;
    padding: 0.5rem 0.65rem;
}

.color-btn { min-height: 46px; font-size: 0.95rem; }

.file-upload-btn,
#deleteSelected {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    font-size: 0.95rem;
}

.text-controls-row input[type="color"] { width: 52px; height: 46px; }

.element-controls label { font-size: 0.85rem; margin-top: 0.9rem; }
#deleteSelected { margin-top: 1.1rem; }

/* On the phone the text is placed with Gotovo, so the "Dodaj tekst" button is not needed */
#addTextBtn { display: none; }

/* ---------- Text and Dres panels: the top part stays, the rest scrolls ---------- */
.designer-sidebar .panel.panel-split.active {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 28px 1rem 0;
}

.panel-split .sheet-title { flex: 0 0 auto; margin-bottom: 0.5rem; }

.panel-split .panel-pinned {
    flex: 0 0 auto;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border);
    background: var(--white);
}

.panel-split .panel-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.8rem 0 1.1rem;
}

/* These two panels need more room because of the part that stays at the top */
.designer-sidebar[data-open="text"],
.designer-sidebar[data-open="jersey"] {
    max-height: 66vh;
    max-height: min(66dvh, 540px);
    max-height: min(66dvh, 540px, var(--sheet-max, 999px));
}

#textInput { width: 100%; box-sizing: border-box; border: 1px solid var(--border-strong); }

.style-card.active { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- No sliders on the phone: fingers do it on the shirt ---------- */
.element-controls > label,
#scaleSlider,
#rotationSlider,
#shapeInner label,
#shapeInner input[type="range"],
#shapeInner > p.hint:not(.touch-only),
#jerseyNameCurve,
#jerseyNameCurve + .hint { display: none; }

.touch-only { display: block; }

.touch-hint {
    margin: 0 0 0.9rem;
    padding: 0.6rem 0.75rem;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text);
}

/* Buttons that replace the "curve" slider of jersey names */
.curve-stepper.touch-only { display: flex; gap: 6px; margin-top: 0.4rem; }

.curve-stepper button {
    flex: 1;
    min-height: 46px;
    padding: 0 0.4rem;
    background: var(--white);
    border: 1px solid var(--border-strong);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    cursor: pointer;
}

.curve-stepper button:active { background: var(--accent-soft); border-color: var(--black); }

/* Edit panel: message when nothing is selected, fields when something is */
.edit-empty {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    padding: 0.25rem 0 0.75rem;
}

.edit-fields { display: none; }
#editPanel.has-selection .edit-empty { display: none; }
#editPanel.has-selection .edit-fields { display: block; }

.edit-text-row { display: none; }
#editPanel.is-text .edit-text-row { display: block; }
.edit-text-row input { width: 100%; margin-top: 0.3rem; }
.edit-text-row label { display: block; }

/* ---------- Bottom toolbar (always visible) ---------- */
.mobile-toolbar {
    order: 3;
    position: relative;
    z-index: 30;
    display: flex;
    flex: 0 0 auto;
    align-items: stretch;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    user-select: none;
    -webkit-user-select: none;
}

.tool-btn {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 0;
    min-height: 52px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.68rem;
    cursor: pointer;
}

.tool-btn svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: square;
    stroke-linejoin: miter;
}

.tool-btn.active {
    color: var(--black);
    box-shadow: inset 0 2px 0 var(--accent);
}

.tool-dot {
    display: none;
    position: absolute;
    top: 8px;
    right: calc(50% - 20px);
    width: 8px;
    height: 8px;
    background: var(--accent);
}

.tool-btn.has-selection .tool-dot { display: block; }

.tool-next {
    flex: 1.4;
    flex-direction: row;
    gap: 6px;
    margin-left: 4px;
    background: var(--black);
    color: var(--white);
    font-size: 0.9rem;
    font-weight: 600;
}

.tool-next svg { width: 20px; height: 20px; }
.tool-next:active { background: var(--accent); color: var(--black); }
.tool-next:disabled { background: var(--border-strong); cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
    .designer-sidebar,
    .designer-layout.sheet-open .designer-sidebar { transition: none; }
}
