﻿/* ── CategoryPopup.css ── */

/* Overlay */
.cpop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: cpop-fade-in 0.18s ease;
    box-sizing: border-box;
}

@keyframes cpop-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Modal card */
.cpop-modal {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px 32px 24px;
    width: 100%;
    max-width: 560px;
    max-height: min(92vh, 900px);
    margin: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    animation: cpop-slide-up 0.2s ease;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes cpop-slide-up {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.cpop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.cpop-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1a1d23;
    margin: 0;
}

.cpop-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid #e2e5ec;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    flex-shrink: 0;
}

    .cpop-close-btn:hover {
        background: #f3f4f6;
        color: #1a1d23;
    }

.cpop-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
}

/* Image upload row */
.cpop-image-row {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 24px;
}

/* Preview box */
.cpop-preview-box {
    flex-shrink: 0;
    width: 140px;
    height: 130px;
    border-radius: 12px;
    background: #f7f8fa;
    border: 1.5px dashed #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cpop-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.cpop-preview-icon {
    opacity: 0.55;
}

.cpop-preview-clickable {
    cursor: pointer;
}

.hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Upload controls */
.cpop-upload-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 2px;
    min-width: 0;
}

.cpop-field-label {
    font-size: 0.93rem;
    font-weight: 600;
    color: #1a1d23;
    display: flex;
    align-items: center;
    gap: 3px;
}

.cpop-required {
    color: #e53935;
    font-size: 0.85rem;
}

.cpop-hint {
    font-size: 0.82rem;
    color: #2563eb;
    margin: 0 0 8px;
}

.cpop-upload-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Circle icon buttons */
.cpop-icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid #e2e5ec;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #374151;
    transition: background 0.15s, border-color 0.15s;
    padding: 0;
}

    .cpop-icon-circle:hover {
        background: #f0f1f4;
        border-color: #c5c9d4;
    }

.cpop-icon-delete {
    color: #e53935;
    border-color: #fcdada;
}

    .cpop-icon-delete:hover {
        background: #fff5f5;
        border-color: #f5b7b7;
    }

/* Category Name field */
.cpop-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 22px;
}

.cpop-input {
    width: 100%;
    height: 48px;
    border: 1.5px solid #e2e5ec;
    border-radius: 10px;
    padding: 0 14px;
    font-size: 0.93rem;
    color: #1a1d23;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    background: #fff;
}

    .cpop-input:focus {
        border-color: #2563eb;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    }

.cpop-input-error {
    border-color: #e53935 !important;
}

/* Error message */
.cpop-error {
    font-size: 0.79rem;
    color: #e53935;
    margin: 2px 0 0;
}

/* Visibility toggle */
.cpop-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cpop-toggle-btn {
    position: relative;
    width: 44px;
    height: 24px;
    border-radius: 99px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.cpop-toggle-off {
    background: #e2e8f0;
}

.cpop-toggle-on {
    background: #3b82f6;
}

.cpop-toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
    display: block;
}

.cpop-toggle-on .cpop-toggle-knob {
    transform: translateX(20px);
}

.cpop-toggle-text {
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
}

/* Footer */
.cpop-footer {
    display: flex;
    gap: 14px;
    flex-shrink: 0;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid #f0f1f4;
}

.cpop-btn-cancel,
.cpop-btn-save {
    flex: 1;
    height: 50px;
    border-radius: 10px;
    font-size: 0.97rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cpop-btn-cancel {
    background: #f3f4f6;
    color: #374151;
    border: 1.5px solid #e2e5ec;
}

    .cpop-btn-cancel:hover {
        background: #e9eaed;
    }

.cpop-btn-save {
    background: #2563eb;
    color: #fff;
}

    .cpop-btn-save:hover:not(:disabled) {
        background: #1d55d4;
    }

    .cpop-btn-save:disabled {
        opacity: 0.65;
        cursor: not-allowed;
    }

/* Save spinner */
.cpop-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cpop-spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes cpop-spin {
    to {
        transform: rotate(360deg);
    }
}

.addon-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 160px;
    overflow-y: auto;
    margin-top: 0.35rem;
    padding: 0.5rem;
    border: 1px solid #e2e5ec;
    border-radius: 10px;
    background: #f8f9fb;
}

.addon-check-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
}

.addon-check-item:hover {
    background: #eef2ff;
}

.addon-check-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #3b82f6;
    flex-shrink: 0;
}

.addon-check-name {
    flex: 1;
}

.addon-check-price {
    font-size: 0.8rem;
    color: #6b7280;
}

/* Tablet / small screens */
@media (max-width: 1024px) {
    .cpop-overlay {
        align-items: flex-start;
        padding: 12px;
    }

    .cpop-modal {
        max-width: 100%;
        max-height: calc(100vh - 24px);
        padding: 20px 16px 16px;
        border-radius: 14px;
    }

    .cpop-title {
        font-size: 1.15rem;
    }

    .cpop-image-row {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
    }

    .cpop-preview-box {
        width: 100%;
        height: 140px;
    }

    .cpop-field {
        margin-bottom: 18px;
    }

    .cpop-btn-cancel,
    .cpop-btn-save {
        height: 46px;
        font-size: 0.92rem;
    }

    .addon-checklist {
        max-height: 120px;
    }
}

.cpop-colors {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}

.cpop-color {
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    flex: 0 0 52px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    cursor: pointer;
    box-sizing: border-box;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.cpop-color.selected {
    box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px #1a1d23;
}

@media (max-width: 480px) {
    .cpop-overlay {
        padding: 8px;
    }

    .cpop-modal {
        max-height: calc(100vh - 16px);
        padding: 16px 12px 12px;
    }

    .cpop-footer {
        flex-direction: column-reverse;
        gap: 10px;
    }
}
