/* صمّم هديتك — gift designer page styles.
   Extends the site sheet (style.css): same tokens, logical properties for
   RTL/LTR, spacious canvas, minimal chrome around it. */

.gd { --gd-panel-w: 300px; }
/* display:flex/grid on overlays must never defeat the hidden attribute. */
.gd [hidden] { display: none !important; }

/* --- Page head + toolbar ---------------------------------------------- */
.gd__head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; padding-block: 1.1rem .4rem;
}
.gd__sub { color: var(--ink-soft); margin-top: .15rem; }
.gd__toolbar { display: flex; gap: .45rem; flex-wrap: wrap; }
.gd__toolbar .btn { padding: .45rem .85rem; font-size: .88rem; }
.gd__toolbar .btn[disabled] { opacity: .45; cursor: default; transform: none; }
.gd-danger:hover { border-color: #c25b5b; color: #a33; }

/* --- Three-column layout ----------------------------------------------- */
.gd__layout {
    display: grid; gap: .9rem; align-items: stretch;
    grid-template-columns: var(--gd-panel-w) minmax(0, 1fr) var(--gd-panel-w);
    height: clamp(520px, calc(100vh - 240px), 860px);
    padding-bottom: .4rem;
}
.gd-panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}

/* --- Library ------------------------------------------------------------ */
.gd-lib__search {
    display: flex; align-items: center; gap: .5rem;
    padding: .7rem .8rem .4rem; color: var(--ink-soft);
}
.gd-lib__search svg { width: 1.1rem; height: 1.1rem; flex: none; }
.gd-lib__search input {
    flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 999px;
    padding: .4rem .9rem; font: inherit; font-size: .9rem; background: var(--bg);
    color: var(--ink);
}
.gd-lib__search input:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }
.gd-lib__filters {
    display: flex; flex-wrap: wrap; gap: .35rem; padding: .35rem .8rem .5rem;
}
.gd-lib__filters select {
    font: inherit; font-size: .78rem; color: var(--ink-soft);
    border: 1px solid var(--line); border-radius: 999px; padding: .18rem .5rem;
    background: var(--surface); max-width: 8.5rem;
}
.gd-chipbtn {
    font: inherit; font-size: .78rem; cursor: pointer; color: var(--ink-soft);
    border: 1px solid var(--line); border-radius: 999px; padding: .18rem .6rem;
    background: var(--surface);
}
.gd-chipbtn[aria-pressed="true"] { background: var(--rose-soft); color: var(--rose-deep); border-color: var(--rose); }
.gd-lib__tabs {
    display: flex; gap: .3rem; overflow-x: auto; padding: .25rem .8rem .55rem;
    scrollbar-width: thin; flex: none;
}
.gd-lib__tabs button {
    font: inherit; font-size: .82rem; font-weight: 500; white-space: nowrap;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft);
    border-radius: 999px; padding: .22rem .8rem; cursor: pointer;
}
.gd-lib__tabs button[aria-selected="true"] {
    background: var(--green); border-color: var(--green); color: #fff;
}
.gd-lib__grid {
    overflow-y: auto; padding: .2rem .8rem .9rem; flex: 1;
    display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; align-content: start;
}
.gd-lib__empty { padding: 1rem; color: var(--ink-soft); font-size: .9rem; text-align: center; }

.gd-card {
    position: relative; border: 1px solid var(--line); border-radius: 12px;
    padding: .5rem .5rem .55rem; background: var(--bg); cursor: pointer;
    display: flex; flex-direction: column; gap: .3rem; text-align: start;
    font: inherit; transition: border-color .12s, transform .12s, box-shadow .12s;
}
.gd-card:hover { border-color: var(--rose); transform: translateY(-1px); box-shadow: var(--shadow); }
.gd-card__thumb {
    height: 62px; border-radius: 9px; background: var(--surface);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.gd-card__thumb canvas { width: 100%; height: 100%; display: block; }
.gd-card__name { font-size: .8rem; font-weight: 700; line-height: 1.35; color: var(--ink); }
.gd-card__meta { display: flex; align-items: center; justify-content: space-between; gap: .3rem; }
.gd-card__price { font-size: .8rem; color: var(--rose-deep); font-weight: 700; }
.gd-card__stock { font-size: .68rem; color: var(--green); }
.gd-card--out { opacity: .55; cursor: not-allowed; }
.gd-card--out .gd-card__stock { color: #a33; }
.gd-card__swatches { display: flex; gap: .18rem; }
.gd-card__swatches i {
    width: .68rem; height: .68rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.12);
}
.gd-card__fav {
    position: absolute; inset-inline-end: .4rem; top: .4rem; z-index: 2;
    background: var(--surface); border: 1px solid var(--line); border-radius: 50%;
    width: 1.55rem; height: 1.55rem; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--ink-soft); font-size: .8rem; line-height: 1;
}
.gd-card__fav[aria-pressed="true"] { color: var(--rose); border-color: var(--rose); }

/* --- Stage -------------------------------------------------------------- */
.gd-stage { min-width: 0; display: flex; }
.gd-stage__host {
    position: relative; flex: 1; border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--line); background:
        radial-gradient(120% 90% at 50% 8%, #fffdf9 0%, var(--bg-tint) 74%, #eadfcd 100%);
    box-shadow: var(--shadow); touch-action: none;
}
.gd-stage__host.gd-full { position: fixed; inset: 0; z-index: 90; border-radius: 0; }
.gd-stage__host canvas.gd-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.gd-stage__host.gd-grabbing { cursor: grabbing; }

.gd-loading, .gd-fallback, .gd-empty {
    position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: .6rem; text-align: center;
    padding: 1.5rem; color: var(--ink-soft);
}
.gd-loading { background: var(--bg-tint); }
.gd-loading__spinner {
    width: 2.4rem; height: 2.4rem; border-radius: 50%;
    border: 3px solid var(--rose-soft); border-top-color: var(--rose);
    animation: gdspin .9s linear infinite;
}
@keyframes gdspin { to { transform: rotate(360deg); } }
.gd-loading__bar {
    width: min(220px, 60%); height: 5px; background: var(--rose-soft);
    border-radius: 999px; overflow: hidden;
}
.gd-loading__bar span { display: block; height: 100%; width: 0; background: var(--rose); transition: width .2s; }
.gd-fallback__icon svg, .gd-empty__icon svg { width: 3rem; height: 3rem; color: var(--rose); }
.gd-empty { pointer-events: none; z-index: 4; }
.gd-empty strong { font-family: var(--font-display); font-size: 1.15rem; color: var(--ink); }

/* Base picker overlay */
.gd-basepick {
    position: absolute; inset: 0; z-index: 6; overflow-y: auto;
    background: rgba(251, 247, 241, .78); backdrop-filter: blur(5px);
    display: flex; align-items: flex-start; justify-content: center; padding: 1rem;
}
.gd-basepick__card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.1rem 1.2rem 1.2rem; max-width: 560px; width: 100%;
    margin-block: auto;
}
.gd-basepick__card h2 { font-size: 1.25rem; }
.gd-basepick__card > p { color: var(--ink-soft); font-size: .9rem; margin: .2rem 0 .8rem; }
.gd-basepick__grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(114px, 1fr)); gap: .5rem;
}
.gd-basepick__grid .gd-card__thumb { height: 56px; }
.gd-basepick__grid .gd-card[aria-pressed="true"] { border-color: var(--rose); background: var(--rose-soft); }
.gd-basepick__opts { display: flex; flex-direction: column; gap: .55rem; margin-block: .8rem; }
.gd-optrow { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.gd-optrow > span { font-size: .82rem; font-weight: 700; color: var(--ink-soft); min-width: 3.6rem; }
.gd-opt {
    font: inherit; font-size: .8rem; cursor: pointer; border: 1px solid var(--line);
    background: var(--surface); color: var(--ink); border-radius: 999px; padding: .2rem .7rem;
}
.gd-opt[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.gd-swatch {
    width: 1.5rem; height: 1.5rem; border-radius: 50%; cursor: pointer;
    border: 2px solid var(--surface); outline: 1px solid var(--line); padding: 0;
}
.gd-swatch[aria-pressed="true"] { outline: 2px solid var(--rose-deep); }

/* Camera cluster + stage buttons + hint */
.gd-cam {
    position: absolute; z-index: 7; inset-inline-start: .7rem; bottom: .7rem;
    display: flex; flex-direction: column; gap: .25rem;
}
.gd-cam button {
    width: 2rem; height: 2rem; border-radius: 9px; border: 1px solid var(--line);
    background: rgba(255, 255, 255, .92); color: var(--ink-soft); cursor: pointer;
    font-size: .95rem; line-height: 1;
}
.gd-cam button:hover { color: var(--rose-deep); border-color: var(--rose); }
.gd-stagebtns {
    position: absolute; z-index: 7; inset-inline-end: .7rem; top: .7rem;
    display: flex; gap: .4rem;
}
.gd-stagebtns .btn { padding: .35rem .75rem; font-size: .8rem; background: rgba(255,255,255,.92); }
.gd-hint {
    position: absolute; z-index: 6; bottom: .55rem; inset-inline-end: .8rem;
    font-size: .72rem; color: var(--ink-soft); background: rgba(255,255,255,.8);
    border-radius: 999px; padding: .15rem .7rem; pointer-events: none; max-width: 70%;
    text-align: center;
}
.gd-toast {
    position: absolute; z-index: 8; top: .8rem; inset-inline-start: 50%; transform: translateX(-50%);
    background: var(--ink); color: #fff; font-size: .85rem; border-radius: 999px;
    padding: .4rem 1.1rem; box-shadow: var(--shadow); max-width: 90%; text-align: center;
}
[dir="rtl"] .gd-toast { transform: translateX(50%); }
.gd-toast--warn { background: #8a5a18; }
.gd-toast--error { background: #8c2c2c; }
.gd-toast--ok { background: var(--green); }

.gd-exporting {
    position: absolute; inset: 0; z-index: 9; display: flex; align-items: center;
    justify-content: center; background: rgba(251, 247, 241, .6); backdrop-filter: blur(3px);
}
.gd-exporting__card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.2rem 1.6rem; display: flex; flex-direction: column;
    align-items: center; gap: .55rem; text-align: center; max-width: 320px;
}
.gd-exporting__card strong { font-family: var(--font-display); }
.gd-exporting__card span { font-size: .8rem; color: var(--ink-soft); }
.gd-exporting__card .btn { margin-top: .3rem; padding: .35rem 1rem; font-size: .82rem; }

/* --- Inspector ---------------------------------------------------------- */
.gd-inspector { overflow-y: auto; }
.gd-sec { padding: .8rem .9rem; border-bottom: 1px solid var(--line); }
.gd-sec:last-child { border-bottom: 0; }
.gd-sec__title {
    font-family: var(--font-body); font-size: .82rem; font-weight: 700;
    color: var(--ink-soft); letter-spacing: .02em; margin-bottom: .5rem;
    display: flex; align-items: center; gap: .4rem;
}
.gd-count {
    background: var(--rose-soft); color: var(--rose-deep); border-radius: 999px;
    font-size: .7rem; padding: 0 .5rem;
}
.gd-sec__empty { font-size: .82rem; color: var(--ink-soft); }

.gd-sel__name { font-weight: 700; font-size: .95rem; margin-bottom: .1rem; }
.gd-sel__price { font-size: .82rem; color: var(--rose-deep); font-weight: 700; margin-bottom: .5rem; }
.gd-field { margin-bottom: .6rem; }
.gd-field > label, .gd-field > span.gd-field__lbl {
    display: block; font-size: .74rem; font-weight: 700; color: var(--ink-soft); margin-bottom: .25rem;
}
.gd-field .gd-optrow > span { min-width: 0; }
.gd-field input[type="range"] { width: 100%; accent-color: var(--rose); }
.gd-field input[type="text"], .gd-field textarea, .gd-field select {
    width: 100%; font: inherit; font-size: .88rem; border: 1px solid var(--line);
    border-radius: 9px; padding: .4rem .6rem; background: var(--bg); color: var(--ink);
}
.gd-field textarea { min-height: 3.6rem; resize: vertical; }
.gd-field input:focus, .gd-field textarea:focus { outline: 2px solid var(--rose-soft); border-color: var(--rose); }

.gd-nudge { display: grid; grid-template-columns: repeat(3, 2rem); gap: .2rem; justify-content: start; }
.gd-nudge button {
    width: 2rem; height: 2rem; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); cursor: pointer; color: var(--ink-soft); font-size: .85rem;
}
.gd-nudge button:hover { border-color: var(--rose); color: var(--rose-deep); }
.gd-qty { display: inline-flex; align-items: center; gap: .55rem; }
.gd-qty button {
    width: 1.7rem; height: 1.7rem; border-radius: 8px; border: 1px solid var(--line);
    background: var(--surface); cursor: pointer; font-size: 1rem; line-height: 1; color: var(--ink);
}
.gd-qty b { min-width: 1.4rem; text-align: center; }

.gd-sel__actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.gd-sel__actions button {
    font: inherit; font-size: .76rem; cursor: pointer; border: 1px solid var(--line);
    border-radius: 999px; padding: .22rem .65rem; background: var(--surface); color: var(--ink);
}
.gd-sel__actions button:hover { border-color: var(--rose); color: var(--rose-deep); }
.gd-sel__actions button[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.gd-sel__actions .gd-del:hover { border-color: #c25b5b; color: #a33; }

.gd-photo__preview {
    width: 100%; height: 90px; border-radius: 9px; border: 1px dashed var(--line);
    background: var(--bg) center/cover no-repeat; margin-bottom: .4rem;
    display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: .75rem;
}
.gd-warn-inline { font-size: .74rem; color: #8a5a18; background: #f7ecd9; border-radius: 8px; padding: .3rem .55rem; margin-top: .3rem; }

/* Layers */
.gd-layers { list-style: none; padding: 0; display: flex; flex-direction: column; gap: .25rem; }
.gd-layers li {
    display: flex; align-items: center; gap: .35rem; border: 1px solid transparent;
    border-radius: 9px; padding: .25rem .4rem; cursor: pointer; font-size: .8rem;
}
.gd-layers li:hover { background: var(--bg); }
.gd-layers li.gd-active { background: var(--rose-soft); border-color: var(--rose); }
.gd-layers li .gd-layer__dot { width: .7rem; height: .7rem; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); flex: none; }
.gd-layers li .gd-layer__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-layers li input.gd-layer__rename { flex: 1; min-width: 0; font: inherit; font-size: .8rem; border: 1px solid var(--rose); border-radius: 6px; padding: 0 .3rem; }
.gd-layers li .gd-layer__btns { display: flex; gap: .1rem; }
.gd-layers li .gd-layer__btns button {
    border: 0; background: none; cursor: pointer; font-size: .78rem; color: var(--ink-soft);
    width: 1.4rem; height: 1.4rem; border-radius: 6px; line-height: 1;
}
.gd-layers li .gd-layer__btns button:hover { background: var(--surface); color: var(--rose-deep); }
.gd-layers li .gd-layer__btns button[aria-pressed="true"] { color: var(--green); }
.gd-layers li.gd-hidden-item { opacity: .5; }

/* Summary */
.gd-summary { font-size: .84rem; }
.gd-summary__line { display: flex; justify-content: space-between; gap: .6rem; padding-block: .18rem; }
.gd-summary__line span:first-child { color: var(--ink-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gd-summary__line.gd-sum-total { border-top: 1px solid var(--line); margin-top: .35rem; padding-top: .45rem; font-weight: 700; font-size: .95rem; }
.gd-summary__empty { color: var(--ink-soft); font-size: .82rem; }

/* --- Sticky bar ---------------------------------------------------------- */
.gd-bar {
    position: sticky; bottom: 0; z-index: 40;
    background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
    border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(140, 44, 72, .07);
}
.gd-bar__inner { display: flex; align-items: center; gap: 1rem; padding-block: .55rem; }
.gd-bar__mobtabs { display: none; gap: .4rem; }
.gd-bar__count { margin-inline-start: auto; color: var(--ink-soft); font-size: .85rem; }
.gd-bar__actions { display: flex; gap: .5rem; align-items: center; }

/* --- Modals & drawer ----------------------------------------------------- */
.gd-modal {
    position: fixed; inset: 0; z-index: 95; display: flex; align-items: center;
    justify-content: center; padding: 1rem; background: rgba(51, 34, 42, .45);
}
.gd-modal__card {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.2rem 1.3rem; max-width: 430px; width: 100%; max-height: 92vh; overflow-y: auto;
}
.gd-modal__card h3 { font-size: 1.15rem; margin-bottom: .35rem; }
.gd-modal__card p { color: var(--ink-soft); font-size: .9rem; }
.gd-modal__actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

.gd-crop__card { max-width: 470px; }
.gd-crop__stage { display: flex; justify-content: center; margin-block: .6rem; }
#gdCropCanvas {
    border-radius: 10px; border: 1px solid var(--line); cursor: grab;
    max-width: 100%; height: auto; touch-action: none; background: #eee;
}
.gd-crop__controls { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.gd-crop__controls label { display: flex; align-items: center; gap: .45rem; font-size: .82rem; color: var(--ink-soft); flex: 1; }
.gd-crop__controls input[type="range"] { flex: 1; accent-color: var(--rose); }
.gd-crop__hint { font-size: .8rem !important; }
.gd-crop__warn { margin-top: .5rem; font-size: .8rem !important; color: #8a5a18 !important; background: #f7ecd9; border-radius: 8px; padding: .35rem .6rem; }

.gd-tut__card { max-width: 480px; }
.gd-tut__steps { margin: .6rem 0 0; padding-inline-start: 1.3rem; display: flex; flex-direction: column; gap: .45rem; color: var(--ink); font-size: .92rem; }
.gd-tut__steps li::marker { color: var(--rose); font-weight: 700; }
.gd-tut__kb { margin-top: .8rem; font-size: .75rem !important; background: var(--bg-tint); border-radius: 8px; padding: .4rem .6rem; }

/* --- SEO content below the designer ------------------------------------- */
.gd-seo { max-width: 820px; padding-block: 2.2rem 2.8rem; }
.gd-seo h2 { margin-top: 1.4rem; }
.gd-seo h3 { margin-top: 1rem; font-size: 1.1rem; }
.gd-seo p { color: var(--ink-soft); margin-top: .5rem; }
.gd-seo a { font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.gd-seo__faqs { display: flex; flex-direction: column; gap: .5rem; margin-top: .8rem; }
.gd-seo__faq {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: .7rem 1rem;
}
.gd-seo__faq summary { font-weight: 700; cursor: pointer; }
.gd-seo__faq p { margin-top: .5rem; }

/* --- Mobile -------------------------------------------------------------- */
@media (max-width: 980px) {
    .gd__layout { grid-template-columns: 1fr; height: auto; }
    .gd-stage { order: 1; }
    .gd-stage__host { height: min(66vh, 560px); }
    .gd__head { padding-block: .8rem .3rem; }
    .gd__toolbar .btn span:not(.gd-btn-lbl):not([aria-hidden]) { display: none; }
    .gd__toolbar .btn { padding: .4rem .6rem; }

    /* Library + inspector become bottom sheets over the canvas. */
    .gd-library, .gd-inspector {
        position: fixed; z-index: 60; inset-inline: 0; bottom: 0; top: auto;
        max-height: 72vh; height: 72vh; border-radius: var(--radius) var(--radius) 0 0;
        transform: translateY(105%); transition: transform .25s ease;
        box-shadow: 0 -14px 40px rgba(51, 34, 42, .25);
    }
    .gd-library.gd-open, .gd-inspector.gd-open { transform: translateY(0); }
    .gd-library::before, .gd-inspector::before {
        content: ''; display: block; width: 44px; height: 4px; border-radius: 4px;
        background: var(--line); margin: .5rem auto .1rem; flex: none;
    }
    .gd-lib__grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .gd-bar__mobtabs { display: flex; }
    .gd-bar__inner { flex-wrap: wrap; gap: .5rem; }
    .gd-bar__actions { flex: 1; justify-content: flex-end; }
    .gd-bar__actions .btn { font-size: .85rem; padding: .5rem .9rem; }
    .gd-bar__count { display: none; }
    .gd-hint { display: none; }
}
