/**
 * Layer Customizer - Frontend Styles
 */

/* Variables */
:root {
    --lc-primary: #3a86ff;
    --lc-primary-dark: #2667cc;
    --lc-secondary: #8338ec;
    --lc-success: #06d6a0;
    --lc-warning: #ffc107;
    --lc-danger: #ef476f;
    --lc-dark: #1a1a2e;
    --lc-gray-50: #fafafa;
    --lc-gray-100: #f5f5f5;
    --lc-gray-200: #e5e5e5;
    --lc-gray-300: #d4d4d4;
    --lc-gray-400: #a3a3a3;
    --lc-gray-500: #737373;
    --lc-gray-600: #525252;
    --lc-gray-700: #404040;
    --lc-gray-800: #262626;
    --lc-radius-sm: 8px;
    --lc-radius-md: 12px;
    --lc-radius-lg: 16px;
    --lc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --lc-shadow-md: 0 4px 20px rgba(0, 0, 0, 0.12);
    --lc-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.15);
    --lc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Main Wrapper */
.lc-customizer-wrapper {
    margin: 30px 0;
    padding: 30px;
    background: linear-gradient(135deg, var(--lc-gray-50) 0%, #ffffff 100%);
    border-radius: var(--lc-radius-lg);
    box-shadow: var(--lc-shadow-md);
}

.lc-customizer-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--lc-dark);
    margin: 0 0 25px;
    text-align: center;
    background: linear-gradient(135deg, var(--lc-primary), var(--lc-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.lc-customizer-container {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 30px;
    align-items: start;
}

/* Canvas Area */
.lc-canvas-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: var(--lc-gray-100);
    border-radius: var(--lc-radius-md);
    min-height: 400px;
}

.lc-canvas-container {
    position: relative;
    background: #ffffff;
    border-radius: var(--lc-radius-sm);
    box-shadow: var(--lc-shadow-lg);
    overflow: hidden;
    max-width: 100%;
}

.lc-canvas-layers,
.lc-canvas-custom,
.lc-canvas-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.lc-canvas-custom,
.lc-canvas-text {
    pointer-events: auto;
}

/* Layer Images */
.lc-layer-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

/* Custom Image Elements */
.lc-custom-element {
    position: absolute;
    cursor: move;
    user-select: none;
    touch-action: none;
}

.lc-custom-element img {
    max-width: 100%;
    max-height: 100%;
    pointer-events: none;
}

.lc-custom-element.selected {
    outline: 2px dashed var(--lc-primary);
    outline-offset: 2px;
}

.lc-custom-element .lc-resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--lc-primary);
    border-radius: 50%;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
}

.lc-custom-element.selected .lc-resize-handle {
    opacity: 1;
}

.lc-custom-element .lc-resize-handle.se {
    right: -6px;
    bottom: -6px;
}

.lc-custom-element .lc-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: var(--lc-danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lc-custom-element.selected .lc-delete-btn {
    opacity: 1;
}

/* Text Elements */
.lc-text-element {
    position: absolute;
    cursor: move;
    user-select: none;
    touch-action: none;
    padding: 5px 10px;
    white-space: nowrap;
}

.lc-text-element.selected {
    outline: 2px dashed var(--lc-primary);
    outline-offset: 2px;
}

.lc-text-element .lc-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: var(--lc-danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lc-text-element.selected .lc-delete-btn {
    opacity: 1;
}

/* Controls Panel */
.lc-controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lc-layers-panel,
.lc-custom-image-panel,
.lc-text-panel {
    background: #ffffff;
    border-radius: var(--lc-radius-md);
    padding: 20px;
    box-shadow: var(--lc-shadow-sm);
}

.lc-layers-panel h4,
.lc-custom-image-panel h4,
.lc-text-panel h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--lc-gray-800);
    margin: 0 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--lc-gray-100);
}

/* Accordion */
.lc-accordion-item {
    margin-bottom: 10px;
    border: 1px solid var(--lc-gray-200);
    border-radius: var(--lc-radius-sm);
    overflow: hidden;
}

.lc-accordion-item:last-child {
    margin-bottom: 0;
}

.lc-accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: var(--lc-gray-50);
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--lc-gray-700);
    transition: var(--lc-transition);
}

.lc-accordion-header:hover {
    background: var(--lc-gray-100);
}

.lc-accordion-title {
    flex: 1;
    text-align: left;
}

.lc-required-badge {
    color: var(--lc-danger);
    font-weight: 700;
    margin-right: 8px;
}

.lc-accordion-icon {
    width: 20px;
    height: 20px;
    position: relative;
    transition: transform 0.3s;
}

.lc-accordion-icon::before,
.lc-accordion-icon::after {
    content: '';
    position: absolute;
    background: var(--lc-gray-500);
    transition: var(--lc-transition);
}

.lc-accordion-icon::before {
    top: 50%;
    left: 4px;
    width: 12px;
    height: 2px;
    transform: translateY(-50%);
}

.lc-accordion-icon::after {
    top: 4px;
    left: 50%;
    width: 2px;
    height: 12px;
    transform: translateX(-50%);
}

.lc-accordion-item.open .lc-accordion-icon::after {
    transform: translateX(-50%) rotate(90deg);
    opacity: 0;
}

.lc-accordion-content {
    display: none;
    padding: 15px;
    background: #ffffff;
}

.lc-accordion-item.open .lc-accordion-content {
    display: block;
}

.lc-category-desc {
    font-size: 0.85rem;
    color: var(--lc-gray-500);
    margin: 0 0 12px;
}

/* Segment Options */
.lc-segments-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
}

.lc-segment-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
}

.lc-segment-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.lc-segment-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--lc-radius-sm);
    border: 2px solid var(--lc-gray-200);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lc-gray-100);
    transition: var(--lc-transition);
}

.lc-segment-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lc-segment-option input:checked+.lc-segment-thumb {
    border-color: var(--lc-primary);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.2);
}

.lc-segment-option:hover .lc-segment-thumb {
    border-color: var(--lc-gray-400);
}

.lc-no-selection {
    background: var(--lc-gray-200);
}

.lc-no-selection .dashicons {
    color: var(--lc-gray-500);
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.lc-segment-name {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--lc-gray-600);
    line-height: 1.2;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lc-segment-price {
    display: block;
    font-size: 0.7rem;
    color: var(--lc-success);
    font-weight: 600;
    margin-top: 2px;
}

/* Upload Zone */
.lc-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: var(--lc-gray-50);
    border: 2px dashed var(--lc-gray-300);
    border-radius: var(--lc-radius-md);
    cursor: pointer;
    transition: var(--lc-transition);
}

.lc-upload-zone:hover {
    border-color: var(--lc-primary);
    background: rgba(58, 134, 255, 0.05);
}

.lc-upload-zone.dragover {
    border-color: var(--lc-primary);
    background: rgba(58, 134, 255, 0.1);
}

.lc-upload-zone .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: var(--lc-gray-400);
    margin-bottom: 10px;
    transition: var(--lc-transition);
}

.lc-upload-zone:hover .dashicons {
    color: var(--lc-primary);
}

.lc-upload-zone p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--lc-gray-500);
}

/* Custom Images List */
.lc-custom-images-list {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.lc-custom-image-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: var(--lc-radius-sm);
    overflow: hidden;
    border: 2px solid var(--lc-gray-200);
}

.lc-custom-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lc-custom-image-item .lc-remove-image {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--lc-danger);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Text Controls */
.lc-text-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lc-text-controls input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--lc-gray-300);
    border-radius: var(--lc-radius-sm);
    font-size: 0.95rem;
    transition: var(--lc-transition);
}

.lc-text-controls input[type="text"]:focus {
    outline: none;
    border-color: var(--lc-primary);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.1);
}

.lc-text-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.lc-text-options select,
.lc-text-options input[type="number"] {
    padding: 8px 10px;
    border: 1px solid var(--lc-gray-300);
    border-radius: var(--lc-radius-sm);
    font-size: 0.85rem;
    transition: var(--lc-transition);
}

.lc-text-options select {
    flex: 1;
    min-width: 120px;
}

.lc-text-options input[type="color"] {
    width: 40px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--lc-gray-300);
    border-radius: var(--lc-radius-sm);
    cursor: pointer;
}

.lc-text-controls .button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--lc-primary), var(--lc-secondary));
    color: white;
    border: none;
    border-radius: var(--lc-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--lc-transition);
}

.lc-text-controls .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(58, 134, 255, 0.4);
}

.lc-text-controls .button .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Text Elements List */
.lc-text-elements-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lc-text-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--lc-gray-50);
    border-radius: var(--lc-radius-sm);
}

.lc-text-list-item span {
    flex: 1;
    font-size: 0.85rem;
    color: var(--lc-gray-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lc-text-list-item button {
    background: none;
    border: none;
    color: var(--lc-gray-500);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--lc-transition);
}

.lc-text-list-item button:hover {
    color: var(--lc-danger);
}

/* Loading Overlay */
.lc-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: var(--lc-radius-md);
}

.lc-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--lc-gray-200);
    border-top-color: var(--lc-primary);
    border-radius: 50%;
    animation: lc-spin 1s linear infinite;
}

@keyframes lc-spin {
    to {
        transform: rotate(360deg);
    }
}

.lc-loading-overlay p {
    margin: 15px 0 0;
    color: var(--lc-gray-600);
    font-size: 0.9rem;
}

/* Responsive */
@media screen and (max-width: 900px) {
    .lc-customizer-container {
        grid-template-columns: 1fr;
    }

    .lc-canvas-wrapper {
        order: -1;
    }

    .lc-canvas-container {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 4/3;
    }
}

@media screen and (max-width: 600px) {
    .lc-customizer-wrapper {
        margin: 15px 0;
        padding: 20px 15px;
    }

    .lc-customizer-title {
        font-size: 1.25rem;
    }

    .lc-segments-options {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }

    .lc-segment-thumb {
        width: 50px;
        height: 50px;
    }

    .lc-text-options {
        flex-direction: column;
    }

    .lc-text-options select {
        width: 100%;
    }
}