/* Custom Mug Designer Frontend Stylesheet with Modal Layout */

:root {
    --d-primary: #6366f1;
    --d-primary-hover: #4f46e5;
    --d-bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --d-card-bg: rgba(255, 255, 255, 0.85);
    --d-border: rgba(99, 102, 241, 0.15);
    --d-text: #1f2937;
    --d-text-light: #4b5563;
    --d-success: #10b981;
    --d-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.08);
}

/* Scope CSS variables inside the plugin section wrapper */
.d-mug-designer-section {
    --d-primary: var(--d-btn-color, #6366f1);
    --d-primary-hover: var(--d-btn-color, #4f46e5);
}

/* Base button trigger styling */
.d-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    background: var(--d-primary) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12) !important;
    cursor: pointer;
    transition: all 0.3s ease !important;
    margin-bottom: 15px;
}

.d-trigger-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18) !important;
    background: var(--d-primary) !important;
    filter: brightness(0.9);
}

/* Design Summary Box on Product page */
.d-design-summary {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    animation: fadeIn 0.4s ease forwards;
}

.d-summary-title {
    display: block;
    font-weight: 700;
    color: #166534;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.d-summary-details {
    display: flex;
    align-items: center;
    gap: 15px;
}

.d-summary-thumb-wrapper {
    background: #ffffff;
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.d-summary-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.d-summary-side-text {
    font-size: 0.9rem;
    color: #1e293b;
}

.d-summary-side-text .d-side-val {
    color: var(--d-primary);
    font-weight: 600;
}

.d-edit-link {
    background: none !important;
    border: none !important;
    color: var(--d-primary) !important;
    padding: 0 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    text-decoration: underline !important;
    text-align: left;
    transition: color 0.2s;
}

.d-edit-link:hover {
    color: var(--d-primary-hover) !important;
}

/* Modal Popup Styles */
.d-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.d-modal-dialog {
    background: #ffffff;
    width: 100%;
    max-width: 850px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modalZoom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalZoom {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.d-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none !important;
    border: none !important;
    font-size: 1.8rem;
    font-weight: 500;
    color: #94a3b8;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
    transition: color 0.2s, transform 0.1s ease;
    z-index: 10;
    outline: none !important;
    box-shadow: none !important;
    -webkit-tap-highlight-color: transparent;
}

.d-modal-close:hover,
.d-modal-close:focus {
    color: #ef4444;
    background: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.d-modal-close:active {
    transform: scale(0.85);
    background: none !important;
}

.d-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #f1f5f9;
}

.d-modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: #0f172a;
}

.d-modal-body {
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-flow: row wrap;
    gap: 30px;
}

/* Modal columns */
.d-modal-visualizer {
    flex: 1 1 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.d-modal-controls {
    flex: 1.2 1 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Side switcher tabs inside modal */
.d-side-tabs {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 30px;
    width: 100%;
    max-width: 320px;
}

.d-side-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.25s ease;
    outline: none;
    white-space: nowrap;
}

.d-side-tab:hover {
    color: #0f172a;
}

.d-side-tab.active {
    background: #ffffff;
    color: var(--d-primary);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.05);
}

/* Mug canvas preview container inside modal */
.d-mug-canvas-container {
    position: relative;
    width: 320px;
    height: 320px;
    background: #f8fafc;
    border-radius: 24px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.02);
}

#d-mug-mockup-bg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    pointer-events: none;
    transition: transform 0.4s ease;
}

/* Dynamic handle flipping */
#d-mug-mockup-bg.d-handle-left {
    transform: scaleX(-1);
}

#d-mug-canvas {
    position: absolute;
    top: 24%;
    left: 28%;
    width: 44%;
    height: 52%;
    z-index: 2;
    background: transparent;
    cursor: grab;
}

#d-mug-canvas:active {
    cursor: grabbing;
}

.d-mug-overlay-highlight {
    position: absolute;
    top: 24%;
    left: 28%;
    width: 44%;
    height: 52%;
    z-index: 3;
    pointer-events: none;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0) 0%, 
        rgba(255,255,255,0.2) 30%, 
        rgba(255,255,255,0.3) 50%, 
        rgba(255,255,255,0) 80%
    );
    mix-blend-mode: overlay;
    border-radius: 4px;
}

/* Dropzone image upload styling */
.d-upload-box {
    border: 2px dashed rgba(99, 102, 241, 0.3);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    background: #f8fafc;
    transition: all 0.25s ease;
}

.d-upload-box:hover {
    border-color: var(--d-primary);
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.05);
}

.d-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0 !important;
}

#d-mug-file-input {
    display: none !important;
}

.d-upload-icon {
    font-size: 2.2rem;
    transition: transform 0.25s ease;
}

.d-upload-box:hover .d-upload-icon {
    transform: translateY(-4px);
}

.d-upload-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--d-primary);
}

.d-upload-file-name {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--d-success);
    font-weight: 500;
    word-break: break-all;
}

/* Adjustments */
.d-designer-adjustments {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    animation: fadeIn 0.4s ease forwards;
}

.d-adjustment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
    margin-bottom: 5px;
}

.d-adjustment-header h5 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
}

.d-reset-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.d-reset-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.d-slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.d-slider-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.d-slider-group input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #cbd5e1;
    border-radius: 3px;
    outline: none;
    margin: 8px 0;
}

.d-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--d-primary);
    cursor: pointer;
    transition: transform 0.1s;
}

.d-slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.25);
}

.d-slider-group input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--d-primary);
    cursor: pointer;
    transition: transform 0.1s;
}

.d-slider-group input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.25);
}

.d-tip-text {
    margin: 5px 0 0 0;
    font-size: 0.8rem;
    color: #64748b;
    font-style: italic;
}

.d-modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: flex-end;
}

.d-btn-apply {
    padding: 12px 28px !important;
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    background: var(--d-primary) !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2) !important;
}

.d-btn-apply:hover {
    background: var(--d-primary-hover) !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Shrunken Upload box when image is loaded */
.d-upload-box.d-has-image {
    padding: 12px 20px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-style: solid;
}
.d-upload-box.d-has-image .d-upload-label {
    flex-direction: row;
    justify-content: center;
    gap: 10px;
}
.d-upload-box.d-has-image .d-upload-icon {
    font-size: 1.3rem;
}
.d-upload-box.d-has-image .d-upload-text {
    font-size: 0.85rem;
}

/* Helper drag-to-move instruction */
.d-drag-instruction {
    margin-top: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed rgba(99, 102, 241, 0.2);
    border-radius: 20px;
    padding: 6px 16px;
    text-align: center;
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
    animation: fadeIn 0.4s ease;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .d-modal-overlay {
        padding: 8px;
    }
    .d-modal-dialog {
        max-height: 98vh;
        border-radius: 16px;
    }
    .d-modal-header {
        padding: 15px 20px;
    }
    .d-modal-header h3 {
        font-size: 1.2rem;
    }
    .d-modal-close {
        top: 10px;
        right: 15px;
    }
    .d-modal-body {
        padding: 15px;
        gap: 20px;
        flex-flow: column nowrap !important;
    }
    .d-modal-visualizer,
    .d-modal-controls {
        flex: 1 1 auto;
        width: 100%;
    }
    .d-modal-visualizer {
        align-items: center !important;
    }
    .d-mug-canvas-container {
        width: 280px;
        height: 280px;
        margin: 0 auto !important;
    }
    .d-modal-footer {
        padding: 12px 15px;
    }
    .d-btn-apply {
        width: 100%;
        text-align: center;
    }
    .d-designer-adjustments {
        padding: 12px !important;
        gap: 12px !important;
    }
    .d-slider-group input[type="range"]::-webkit-slider-thumb {
        width: 22px !important;
        height: 22px !important;
    }
    .d-slider-group input[type="range"]::-moz-range-thumb {
        width: 22px !important;
        height: 22px !important;
    }

    /* Stack product page designer elements vertically on mobile */
    .d-mug-designer-section {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
    }
    
    .d-trigger-btn {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 5px !important;
        display: block !important;
    }

    .d-design-summary {
        width: 100% !important;
        max-width: 100% !important;
    }

    form.cart {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    form.cart .quantity {
        margin: 0 0 5px 0 !important;
        display: inline-flex !important;
        justify-content: center !important;
        width: 100% !important;
    }

    form.cart .quantity input.qty {
        width: 100% !important;
        max-width: 120px !important;
    }

    form.cart .single_add_to_cart_button {
        width: 100% !important;
        margin-left: 0 !important;
    }
}

/* Pricing Tiers Table */
.d-pricing-tiers-table {
    margin-top: 15px;
    margin-bottom: 20px;
    background: #ffffff;
    border: 1px solid var(--d-border);
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    width: 100%;
    max-width: 320px;
}

.d-pricing-tiers-table h6 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--d-text);
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 6px;
}

.d-pricing-tiers-table ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.d-pricing-tiers-table li {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--d-text-light);
}

.d-pricing-tiers-table li strong {
    color: var(--d-primary);
    font-weight: 700;
}
