/* ============================================================
   Color Picker Frontend — modal UI
   ============================================================ */

/* ---------------------------------------------------------------
   Trigger field
--------------------------------------------------------------- */

.hcp-utcp-container {
    margin: 16px 0 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hcp-utcp-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hcp-utcp-field > label {
    font-weight: 600;
    font-size: 0.9rem;
}

.hcp-utcp-system-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.hcp-utcp-system-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.hcp-utcp-trigger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.hcp-utcp-trigger {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    text-align: left;
}

.hcp-utcp-trigger:hover {
    border-color: #d1d1d1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.07);
}

.hcp-utcp-trigger:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.hcp-utcp-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px dashed #e2e2e2;
    transition: border 0.2s ease;
    box-sizing: border-box;
}

.hcp-utcp-color-swatch.has-color {
    border: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.hcp-utcp-color-swatch-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    min-width: 0;
}

.hcp-utcp-color-code {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hcp-utcp-color-code.hcp-utcp-color-code-placeholder {
    color: #9ca3af;
    font-weight: normal;
}

.hcp-utcp-color-code-helper {
    font-size: 12px;
    color: #6b7280;
    font-weight: normal;
}

/* ---------------------------------------------------------------
   Dialog / Modal
--------------------------------------------------------------- */

.hcp-utcp-dialog {
    border: 1px solid #e0e0e0;
    border-radius: 1rem;
    padding: 0;
    width: min(1500px, 90dvw);
    height: max(600px, 80dvh);
    max-height: 90dvh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.hcp-utcp-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.hcp-utcp-dialog-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 90vh;
    overflow: hidden;
}

/* Header */

.hcp-utcp-dialog-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e0e0e0;
}

.hcp-utcp-dialog-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

#hcp-utcp-dialog-selected {
    font-weight: 400;
    color: #6b7280;
    font-size: 0.95rem;
}

.hcp-utcp-dialog-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    padding: 0 4px;
    transition: color 0.15s ease;
}

.hcp-utcp-dialog-close:hover {
    color: #111;
}

/* Body: two-pane layout */

.hcp-utcp-dialog-body {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* ---------------------------------------------------------------
   Left pane — grid + controls
--------------------------------------------------------------- */

.hcp-utcp-dialog-left {
    flex: 2;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1rem 1.25rem;
    border-right: 1px solid #e0e0e0;
}

.hcp-utcp-search-row {
    flex-shrink: 0;
    margin-bottom: 0.75rem;
    padding-inline: 5px;
}

.hcp-utcp-search-row input {
    width: 100%;
    max-width: 320px;
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.hcp-utcp-search-row input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Color grid */

.hcp-utcp-color-grid {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
    padding: 5px;
    align-content: start;
    transition: opacity 0.15s ease;
}

.hcp-utcp-color-grid.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.hcp-utcp-color-box {
    height: 80px;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.hcp-utcp-color-box > span {
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hcp-utcp-color-box:hover > span {
    opacity: 0.5;
}

/* Skeleton loader cells */

.hcp-utcp-color-skeleton {
    height: 80px;
    border-radius: 0.5rem;
    background: linear-gradient(90deg, #eee 0%, #f7f7f7 50%, #eee 100%);
    background-size: 200% 100%;
    animation: hcp-skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes hcp-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.hcp-utcp-color-box.is-selected {
    border-color: hsl(221, 83%, 53%);
    outline: 3px solid hsl(221, 83%, 93%);
}

.hcp-utcp-color-box span {
    font-size: small;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
}

.hcp-utcp-loading,
.hcp-utcp-no-results {
    grid-column: 1 / -1;
    padding: 1.5rem 1rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.9rem;
}

/* Pagination */

.hcp-utcp-pagination {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    justify-content: center;
    padding-top: 0.75rem;
}

.hcp-utcp-pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 6px;
    background: white;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
    line-height: 1;
}

.hcp-utcp-pagination-btn:hover:not(:disabled) {
    border-color: #2563eb;
    color: #2563eb;
}

.hcp-utcp-pagination-btn.is-current {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.hcp-utcp-pagination-btn.is-disabled,
.hcp-utcp-pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hcp-utcp-pagination-btn.is-dots {
    background: none;
    border: none;
    box-shadow: none;
    cursor: default;
}

/* ---------------------------------------------------------------
   Right pane — preview + thumbnails + save
--------------------------------------------------------------- */

.hcp-utcp-dialog-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.25rem;
    min-height: 0;
    min-width: 0;
}

.hcp-utcp-preview-label {
    font-size: 20px;
    font-weight: 500;
    color: #111827;
    padding-block: 1rem;
}

.hcp-utcp-preview {
    flex: 0 0 auto;
    aspect-ratio: 16 / 9;
    border-radius: 5px;
    overflow: hidden;
    border: 2px solid #e2e2e2;
}

.hcp-utcp-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Colour is painted as this element's background and shows through the
       PNG's transparent paintable areas — animate that, not box-shadow. */
    transition: background-color 0.2s ease;
}

/* Thumbnails */

.hcp-utcp-thumbnails {
    flex-shrink: 0;
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding-top: 0.5rem;
    padding-bottom: 1rem;
}

.hcp-utcp-thumbnail {
    width: 80px;
    height: 60px;
    border: 2px solid #e2e2e2;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease, border-color 0.3s ease;
    padding: 0;
    background: none;
}

.hcp-utcp-thumbnail:hover {
    opacity: 0.85;
}

.hcp-utcp-thumbnail.is-active {
    opacity: 1;
    border-color: #2563eb;
}

.hcp-utcp-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Save button row */

.hcp-utcp-submit-row {
    flex-shrink: 0;
    margin-top: auto;
    display: flex;
    justify-content: flex-end;
    padding: 5px;
}

.hcp-utcp-submit {
    min-width: 100px;
    padding: 0.6rem 1.2rem;
    background-color: #2563eb;
    border: 1px solid #2563eb;
    color: white;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.hcp-utcp-submit:hover:not(:disabled) {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
}

.hcp-utcp-submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---------------------------------------------------------------
   Responsive — stack panes vertically on mobile
--------------------------------------------------------------- */

@media (max-width: 768px) {
    .hcp-utcp-dialog {
        width: 94vw;
        height: max(560px, 85dvh);
        max-height: 90dvh;
    }

    .hcp-utcp-dialog-body {
        flex-direction: column;
    }

    .hcp-utcp-dialog-left {
        flex: 1;
        border-right: none;
        min-height: 0;
    }

    .hcp-utcp-search-row input {
        max-width: none;
    }

    /* Hide preview entirely on mobile — give all space to the color grid */
    .hcp-utcp-preview-label,
    .hcp-utcp-preview,
    .hcp-utcp-thumbnails {
        display: none;
    }

    .hcp-utcp-dialog-right {
        flex: 0 0 auto;
        border-top: 1px solid #e0e0e0;
        padding: 0.75rem 1rem;
    }

    .hcp-utcp-submit-row {
        margin-top: 0;
        padding: 0;
        justify-content: stretch;
    }

    .hcp-utcp-submit {
        width: 100%;
        padding: 0.75rem;
    }
}
