/* AGF Custom Flake Blend Builder */

/* Reset box-sizing for plugin scope */
.agf-builder-wrap,
.agf-builder-wrap * {
    box-sizing: border-box;
}

.agf-builder-wrap {
    max-width: 1200px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    position: relative;
}

/* ---- TOP SECTION: Two Panels ---- */
.agf-builder-top {
    display: flex;
    gap: 24px;
    margin-bottom: 32px;
}

.agf-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 24px;
}

.agf-selection-panel {
    flex: 1;
    min-width: 0;
}

.agf-preview-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.agf-panel-title {
    margin: 0 0 16px;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

/* ---- Form Fields ---- */
.agf-field {
    margin-bottom: 16px;
}

.agf-field label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: #444;
    margin-bottom: 4px;
}

.agf-field input[type="text"],
.agf-field textarea,
.agf-field select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.agf-field input[type="text"]:focus,
.agf-field textarea:focus,
.agf-field select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.15);
}

/* ---- Selected Colors List ---- */
.agf-selected-colors {
    min-height: 60px;
    margin-bottom: 12px;
}

.agf-empty-message {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
    margin: 0;
}

.agf-selected-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 4px;
    background: #f8f8f8;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    transition: background-color 0.15s;
}

.agf-selected-color-row:hover {
    background: #f0f0f0;
}

.agf-selected-swatch {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    border: 1px solid #ddd;
    flex-shrink: 0;
    object-fit: cover;
}

.agf-selected-info {
    flex: 1;
    min-width: 0;
}

.agf-selected-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agf-selected-code {
    font-size: 0.75rem;
    color: #888;
}

/* ---- Slider Wrap ---- */
.agf-slider-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.agf-percentage-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    cursor: pointer;
    min-width: 60px;
}

.agf-percentage-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2271b1;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    transition: transform 0.1s;
}

.agf-percentage-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.agf-percentage-slider::-webkit-slider-thumb:active {
    transform: scale(1.2);
    background: #135e96;
}

.agf-percentage-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #2271b1;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.agf-percentage-slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: #ddd;
}

.agf-pct-display {
    font-size: 0.9rem;
    font-weight: 700;
    color: #333;
    min-width: 38px;
    text-align: right;
    flex-shrink: 0;
}

.agf-remove-btn {
    background: none;
    border: none;
    color: #cc0000;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    flex-shrink: 0;
    transition: background-color 0.15s;
}

.agf-remove-btn:hover {
    background: #fee;
}

/* ---- Percentage Bar ---- */
.agf-percentage-bar {
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.agf-percentage-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 4px;
    transition: width 0.3s ease, background-color 0.3s ease;
    background: #cc0000;
}

.agf-percentage-bar-fill.agf-valid {
    background: #28a745;
}

.agf-percentage-bar-fill.agf-over {
    background: #cc0000;
}

.agf-percentage-status {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.agf-warning {
    color: #cc0000;
    font-weight: 600;
    font-size: 0.8rem;
}

/* ---- Buttons ---- */
.agf-btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.agf-btn-primary {
    background: #2271b1;
    color: #fff;
    width: 100%;
}

.agf-btn-primary:hover:not(:disabled) {
    background: #135e96;
}

.agf-btn-primary:disabled {
    background: #b0b0b0;
    cursor: not-allowed;
    opacity: 0.7;
}

.agf-btn-add {
    background: #28a745;
    color: #fff;
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 4px;
}

.agf-btn-add:hover {
    background: #218838;
}

.agf-btn-add:disabled {
    background: #999;
    cursor: not-allowed;
}

/* ---- Messages ---- */
.agf-message {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.agf-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.agf-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ---- Canvas Preview ---- */
.agf-base-coat-field {
    margin-bottom: 12px;
}

.agf-canvas-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#agf-blend-canvas {
    width: 100%;
    max-width: 600px;
    height: auto;
    border: 2px solid #333;
    border-radius: 6px;
    background: #000;
}

.agf-canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    border-radius: 6px;
}

/* ---- Category Filters ---- */
.agf-category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.agf-category-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #555;
    transition: all 0.2s;
    text-transform: capitalize;
}

.agf-category-btn:hover {
    border-color: #999;
    background: #f5f5f5;
}

.agf-category-btn.agf-active {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* ---- Color Grid ---- */
.agf-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.agf-color-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.15s, box-shadow 0.15s;
    text-align: center;
}

.agf-color-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.agf-color-card.agf-selected {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

.agf-color-card-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #f0f0f0;
}

.agf-color-card-body {
    padding: 10px;
}

.agf-color-card-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #333;
    margin-bottom: 2px;
}

.agf-color-card-code {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 8px;
}

/* ---- Loading & Spinner ---- */
.agf-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: agf-spin 0.8s linear infinite;
}

.agf-spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: agf-spin 0.8s linear infinite;
}

@keyframes agf-spin {
    to { transform: rotate(360deg); }
}

.agf-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    border-radius: 8px;
    z-index: 100;
    font-size: 1rem;
}

/* ---- Utility ---- */
.agf-hidden {
    display: none !important;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .agf-builder-top {
        flex-direction: column;
    }

    .agf-color-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .agf-category-filters {
        justify-content: center;
    }

    .agf-selected-color-row {
        flex-wrap: wrap;
    }

    .agf-slider-wrap {
        flex-basis: 100%;
        order: 10;
        margin-top: 4px;
    }

    .agf-percentage-slider::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
    }

    .agf-percentage-slider::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }
}

/* ---- Lead Capture Modal ---- */
.agf-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

.agf-modal {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    max-width: 440px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.agf-modal h3 {
    margin: 0 0 8px;
    font-size: 1.4rem;
    color: #031A40;
}

.agf-modal p {
    color: #666;
    margin: 0 0 20px;
    font-size: 0.95rem;
}

.agf-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}

.agf-modal-close:hover {
    color: #333;
}

.agf-modal .agf-field input[type="text"],
.agf-modal .agf-field input[type="email"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
}

.agf-modal .agf-field input:focus {
    border-color: #031A40;
    outline: none;
    box-shadow: 0 0 0 2px rgba(3, 26, 64, 0.15);
}

.agf-modal .agf-btn-primary {
    background: #031A40;
    margin-top: 8px;
}

.agf-modal .agf-btn-primary:hover {
    background: #052a5c;
}

@media (max-width: 480px) {
    .agf-panel {
        padding: 16px;
    }

    .agf-color-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 8px;
    }

    .agf-color-card-body {
        padding: 6px;
    }

    .agf-modal {
        padding: 24px;
    }
}
