/* ================================
   QUOTE MODAL - FINAL (desktop + mobile)
   Replace the whole quote.css with this file
================================ */

/* Overlay */
.quote-modal{
    position:fixed;
    inset:0;
    z-index:100000;
    display:none;
    align-items:center;
    justify-content:center;
    padding:16px;
    background:rgba(0,0,0,.45);
    backdrop-filter:blur(2px);
    -webkit-backdrop-filter:blur(2px);
}
.quote-modal.open{ display:flex; }

/* Card */
.quote-card{
    width:min(1100px, 96vw);
    height:min(92vh, 900px);
    background:#fff;
    border-radius:18px;
    box-shadow:0 20px 60px rgba(0,0,0,.25);
    overflow:hidden;

    display:flex;
    flex-direction:column;
}

/* Header (fixed) */
.quote-head{
    flex:0 0 auto;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:14px 18px;
    border-bottom:1px solid #e5e7eb;
    font-weight:900;
    background:#fff;
}
.quote-x{
    border:0;
    background:transparent;
    font-size:22px;
    cursor:pointer;
    color:#6b7280;
}
.quote-x:hover{ color:#111; }

/* Body = THE ONLY scroll area (force vertical layout everywhere) */
.quote-body{
    flex:1 1 auto;
    min-height:0;                 /* critical */
    overflow-y:auto;              /* ✅ scroll here */
    overflow-x:hidden;
    -webkit-overflow-scrolling:touch;

    display:flex !important;      /* ✅ force column (kills right-side layout) */
    flex-direction:column !important;
    align-items:stretch !important;

    gap:14px;
    padding:16px;

    /* ✅ leave space for sticky actions so buttons never go outside */
    padding-bottom: calc(16px + 70px);
}

/* Force the three sections to be full width and not floated */
.quote-info,
.quote-editor,
.quote-form{
    width:100% !important;
    max-width:none !important;
    float:none !important;
    clear:both !important;
}

/* Info block */
.quote-info{
    border:1px solid #e5e7eb;
    background:#f9fafb;
    border-radius:14px;
    padding:12px;
}
.quote-info-title{
    font-weight:900;
    margin-bottom:6px;
}
.quote-steps{
    margin:0;
    padding-left:18px;
    color:#111827;
    font-size:13px;
}
.quote-flow{
    margin-top:8px;
    font-size:13px;
    color:#374151;
    line-height:1.35;
}

/* Editor */
.quote-editor{
    display:flex;
    flex-direction:column;
    gap:10px;
}
.tools{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    align-items:center;
}
.tbtn{
    padding:8px 12px;
    border-radius:999px;
    border:1px solid #e5e7eb;
    background:#f9fafb;
    font-weight:900;
    cursor:pointer;
    user-select:none;
}
.tbtn:hover{ background:#eef2f7; }
.tbtn.active{
    background:#111827;
    color:#fff;
    border-color:#111827;
}
.lab{
    display:flex;
    align-items:center;
    gap:6px;
    font-size:13px;
    color:#374151;
}
#brushColor{ width:38px; height:30px; border:0; padding:0; background:transparent; }
#brushSize{ width:160px; }
.hint{
    font-size:12px;
    color:#6b7280;
    margin-left:auto;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:520px;
}

/* Canvas container */
.editor-stage{
    width:100%;
    background:#0b0f14;
    border-radius:16px;
    overflow:hidden;
    border:1px solid #e5e7eb;

    /* desktop shape */
    aspect-ratio: 4 / 3;
}
#quoteDrawCanvas{
    width:100%;
    height:100%;
    display:block;
    touch-action:none;
}

/* Form */
.quote-form{
    display:flex;
    flex-direction:column;
    gap:12px;
}
.dims{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:10px;
}
.f{ display:flex; flex-direction:column; gap:6px; }
.f label{ font-size:13px; color:#374151; }
.f input, .f textarea{
    padding:10px 12px;
    border-radius:12px;
    border:1px solid #d1d5db;
    font-size:15px;
}
.f textarea{ min-height:96px; resize:vertical; }
.req{ color:#ef4444; font-weight:900; }

/* Actions: sticky inside scroll container (never outside) */
.actions{
    position: sticky;
    bottom: 0;
    z-index: 20;
    background:#fff;
    padding:10px 0;
    border-top:1px solid #e5e7eb;

    display:flex;
    gap:10px;
    justify-content:flex-end;
}
.btn-cancel{
    padding:10px 16px;
    border-radius:999px;
    border:1px solid #d1d5db;
    background:#f3f4f6;
    font-weight:900;
    cursor:pointer;
}
.btn-ok{
    padding:10px 18px;
    border-radius:999px;
    border:0;
    background:#111827;
    color:#fff;
    font-weight:950;
    cursor:pointer;
}
.btn-ok:hover{ background:#000; }

/* ================================
   MOBILE
================================ */
@media (max-width: 768px){
    .quote-modal{ padding:10px; }
    .quote-card{
        width:min(96vw, 560px);
        height:calc(100dvh - 20px);
    }
    .quote-body{
        padding:12px;
        gap:12px;
        padding-bottom: calc(12px + 76px);
    }

    /* tools sticky top */
    .tools{
        position:sticky;
        top:0;
        z-index:21;
        background:#fff;
        padding:10px 0 8px;
        border-bottom:1px solid #e5e7eb;
    }

    /* square canvas */
    .editor-stage{ aspect-ratio: 1 / 1; }

    /* form single column */
    .dims{ grid-template-columns:1fr; }

    .hint{ display:none; }
    #brushSize{ width:120px; }

    .actions{
        justify-content:space-between;
    }
    .btn-cancel, .btn-ok{
        width:48%;
    }
}
.quote-body{
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}
.field-error{
    margin-top:6px;
    font-size:13px;
    color:#ef4444;
    line-height:1.25;
    display:none;
}
.field-error.show{ display:block; }

.input-error{
    border-color:#ef4444 !important;
    box-shadow:0 0 0 3px rgba(239,68,68,.12);
}
.quote-success-view{ padding:6px 2px; }
.quote-success-view .qs-badge{
    display:inline-flex;align-items:center;
    background:#ecfdf5;color:#065f46;
    border:1px solid #a7f3d0;border-radius:999px;
    padding:6px 10px;font-weight:900;font-size:13px;
}
.quote-success-view .qs-title{ margin:10px 0 4px; font-weight:950; }
.quote-success-view .qs-sub{ margin:0 0 10px; color:#6b7280; }

.quote-success-view .qs-meta{ display:flex; gap:8px; flex-wrap:wrap; margin:10px 0; }
.quote-success-view .qs-pill{
    font-size:12px;color:#111827;background:#f3f4f6;
    border:1px solid #e5e7eb;border-radius:999px;padding:4px 8px;
}

.quote-success-view .qs-imgs{ display:grid; grid-template-columns:1fr; gap:12px; }
.quote-success-view .qs-imgbox{ background:#fff;border:1px solid #e5e7eb;border-radius:14px;padding:10px; }
.quote-success-view .qs-cap{ font-size:12px;color:#6b7280;margin-bottom:6px; }
.quote-success-view img{ width:100%; border-radius:12px; border:1px solid #e5e7eb; background:#0b0f14; object-fit:contain; }

.quote-success-view .qs-actions{ margin-top:12px; display:flex; justify-content:flex-end; }
/* overlay */
#quoteModal.quote-modal{
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(0,0,0,.55);
}
#quoteModal.quote-modal.open{ display:flex; }

/* card becomes a vertical layout with internal scroll */
#quoteModal .quote-card{
    width: min(980px, 100%);
    max-height: calc(100vh - 28px);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* ✅ 让滚动只发生在内部容器 */
    border-radius: 14px;
    background: #efefef;
}

/* header fixed, body scroll */
#quoteModal .quote-head{
    flex: 0 0 auto;
}

/* ✅ 关键：滚动条在这里 */
#quoteModal .quote-body{
    flex: 1 1 auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
#quoteModal #quoteSuccessView{
    flex: 1 1 auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px;
}
/* ===== FORCE SCROLL WORKS (final patch) ===== */
#quoteModal .quote-card{
    display:flex;
    flex-direction:column;
    max-height: calc(100vh - 32px);
    min-height: 0;
    overflow:hidden;
}

#quoteModal .quote-head{
    flex: 0 0 auto;
}

#quoteModal .quote-body{
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* success view inside body */
#quoteModal #quoteSuccessView{
    padding: 6px 2px;
}
