/* ==========================================================================
   CBHC Pre-Made Patches — toggle, modal, cards
   ========================================================================== */

/* --------------------------------------------------------------------------
   Customization Type Toggle
   -------------------------------------------------------------------------- */

.cbhc-cust-toggle {
    display: flex;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid #e8e8e8;
}

.cbhc-cust-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: #fafafa;
    cursor: pointer;
    transition: border-color .2s, background .2s, box-shadow .2s;
    text-align: center;
    user-select: none;
}

.cbhc-cust-btn:hover {
    border-color: #aaa;
    background: #f4f4f4;
}

.cbhc-cust-btn.active {
    border-color: #d11620;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(209,22,32,.12);
}

.cbhc-cust-btn .cust-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.cbhc-cust-btn .cust-label {
    font-weight: 700;
    font-size: .95rem;
    color: #222;
}

.cbhc-cust-btn .cust-desc {
    font-size: .78rem;
    color: #777;
    line-height: 1.3;
}

.cbhc-cust-btn.active .cust-label { color: #d11620; }

/* --------------------------------------------------------------------------
   Pre-Made Patch Form Panel
   -------------------------------------------------------------------------- */

#cbhc-premade-form {
    display: none;
}

#cbhc-premade-form.visible {
    display: block;
}

/* Selected patch confirmation bar */
.cbhc-selected-patch {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: #f0faf0;
    border: 1px solid #b6ddb6;
    border-radius: 8px;
    margin-bottom: 18px;
    cursor: pointer;
    transition: background .2s;
}

.cbhc-selected-patch:hover {
    background: #e4f5e4;
}

.cbhc-selected-patch img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
    flex-shrink: 0;
}

.cbhc-selected-patch .sp-info { flex: 1; min-width: 0; }

.cbhc-selected-patch .sp-name {
    font-weight: 700;
    font-size: .95rem;
    color: #1a1a1a;
    display: block;
}

.cbhc-selected-patch .sp-variation {
    font-size: .82rem;
    color: #555;
    display: block;
    margin-top: 2px;
}

.cbhc-selected-patch .sp-change {
    font-size: .78rem;
    font-weight: 600;
    color: #d11620;
    white-space: nowrap;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Choose patch button */
.cbhc-choose-patch-btn {
    width: 100%;
    padding: 14px;
    border: 2px dashed #d11620;
    border-radius: 10px;
    background: #fff;
    color: #d11620;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background .2s, color .2s;
    margin-bottom: 18px;
    text-align: center;
}

.cbhc-choose-patch-btn:hover {
    background: #d11620;
    color: #fff;
}

/* --------------------------------------------------------------------------
   Modal Overlay
   -------------------------------------------------------------------------- */

.cbhc-pm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99990;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

.cbhc-pm-overlay.open {
    opacity: 1;
    pointer-events: all;
}

/* Modal box */
.cbhc-pm-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 780px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    transform: translateY(16px);
    transition: transform .25s ease;
    overflow: hidden;
}

.cbhc-pm-overlay.open .cbhc-pm-modal {
    transform: translateY(0);
}

/* Modal header */
.cbhc-pm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 18px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.cbhc-pm-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}

.cbhc-pm-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    line-height: 1;
    padding: 0;
}

.cbhc-pm-close:hover { background: #e0e0e0; }

/* Modal body */
.cbhc-pm-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

/* Loading state */
.cbhc-pm-loading {
    text-align: center;
    padding: 48px 0;
    color: #888;
    font-size: .95rem;
}

/* Patch grid */
.cbhc-pm-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Patch card */
.cbhc-pm-card {
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, transform .2s;
    background: #fff;
}

.cbhc-pm-card:hover {
    border-color: #aaa;
    box-shadow: 0 4px 14px rgba(0,0,0,.1);
    transform: translateY(-2px);
}

.cbhc-pm-card.selected {
    border-color: #d11620;
    box-shadow: 0 0 0 3px rgba(209,22,32,.15);
}

.cbhc-pm-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    display: block;
    background: #f0ede8;
    padding: 10px;
}

.cbhc-pm-card-info {
    padding: 10px 12px 12px;
}

.cbhc-pm-card-name {
    font-weight: 700;
    font-size: .88rem;
    color: #1a1a1a;
    line-height: 1.3;
    margin: 0 0 4px;
}

.cbhc-pm-card-price {
    font-size: .8rem;
    color: #555;
    margin: 0;
}

.cbhc-pm-card-price strong {
    color: #d11620;
}

/* Variation selector inside the modal */
.cbhc-pm-variation-wrap {
    border-top: 1px solid #eee;
    padding: 16px 24px 20px;
    flex-shrink: 0;
    background: #fafafa;
    display: none;
}

.cbhc-pm-variation-wrap.visible {
    display: block;
}

.cbhc-pm-variation-wrap label {
    font-weight: 700;
    font-size: .9rem;
    color: #333;
    display: block;
    margin-bottom: 8px;
}

.cbhc-pm-variation-wrap select {
    width: 100%;
    max-width: 320px;
    padding: 9px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: .95rem;
}

/* Modal footer */
.cbhc-pm-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.cbhc-pm-cancel {
    padding: 10px 20px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    color: #555;
    transition: background .2s;
}

.cbhc-pm-cancel:hover { background: #f5f5f5; }

.cbhc-pm-confirm {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    background: #d11620;
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter .2s;
}

.cbhc-pm-confirm:hover { filter: brightness(.9); }
.cbhc-pm-confirm:disabled {
    background: #ccc;
    cursor: not-allowed;
    filter: none;
}

/* Empty state */
.cbhc-pm-empty {
    text-align: center;
    padding: 40px 0;
    color: #888;
    font-size: .95rem;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 600px) {
    .cbhc-cust-toggle { flex-direction: column; }
    .cbhc-pm-grid { grid-template-columns: repeat(2, 1fr); }
    .cbhc-pm-modal { max-height: 94vh; border-radius: 10px; }
    .cbhc-pm-header { padding: 16px 16px 14px; }
    .cbhc-pm-body { padding: 14px 16px; }
    .cbhc-pm-footer { padding: 12px 16px; }
    .cbhc-pm-variation-wrap { padding: 12px 16px 16px; }
}
