/**
 * WPP Designer Modal Styles
 * Fullscreen modal overlay for product personalization
 */

/* Custom Adelia Font - loaded from plugin assets */
@font-face {
    font-family: 'Adelia';
    src: url('../fonts/adelia.ttf') format('truetype'),
        url('../fonts/adelia.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Modal Overlay */
.wpp-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 999999;
    overflow: hidden;
}

.wpp-modal-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #f5f5f5;
}

/* Modal Header */
.wpp-modal-header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #ddd;
    gap: 20px;
}

.wpp-modal-close {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.wpp-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.wpp-close-text {
    font-size: 14px;
    font-weight: 500;
}

.wpp-modal-title {
    flex: 1;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.wpp-modal-price {
    font-size: 20px;
    font-weight: 700;
    color: #e74c3c;
}

/* Modal Body */
.wpp-modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.wpp-modal-sidebar {
    width: 300px;
    background: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wpp-sidebar-handle {
    display: none;
}

/* Tabs */
.wpp-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
}

.wpp-tab {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.wpp-tab:hover {
    color: #e74c3c;
}

.wpp-tab.active {
    color: #e74c3c;
    border-bottom-color: #e74c3c;
}

/* Tab Content */
.wpp-tab-content {
    display: none;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.wpp-tab-content.active {
    display: block;
}

/* Upload Area */
.wpp-upload-area {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fafafa;
}

.wpp-upload-area:hover,
.wpp-upload-area.dragover {
    border-color: #e74c3c;
    background: #fff5f5;
}

.wpp-upload-icon {
    font-size: 36px;
    margin-bottom: 8px;
}

.wpp-upload-text {
    margin: 0 0 12px;
    color: #666;
    font-size: 14px;
}

/* Uploaded Images Grid */
.wpp-uploaded-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
}

.wpp-image-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.wpp-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wpp-image-thumb:hover {
    border-color: #e74c3c;
    transform: scale(1.05);
}

.wpp-image-thumb.selected {
    border-color: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.3);
}

.wpp-remove-image {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 22px;
    opacity: 0;
    transition: opacity 0.2s;
}

.wpp-image-thumb:hover .wpp-remove-image {
    opacity: 1;
}

/* Form Fields */
.wpp-field {
    margin-bottom: 14px;
}

.wpp-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.wpp-field input,
.wpp-field select,
.wpp-field textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.wpp-field input:focus,
.wpp-field select:focus,
.wpp-field textarea:focus {
    border-color: #e74c3c;
    outline: none;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.1);
}

.wpp-field-row {
    display: flex;
    gap: 10px;
}

.wpp-field-row .wpp-field {
    flex: 1;
}

/* Canvas Area */
.wpp-modal-canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow: auto;
}

.wpp-canvas-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wpp-toolbar-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.wpp-toolbar-btn:hover:not(:disabled) {
    border-color: #e74c3c;
    background: #fff5f5;
}

.wpp-toolbar-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.wpp-toolbar-sep {
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 0 4px;
}

#wpp-zoom-level {
    min-width: 45px;
    text-align: center;
    font-size: 13px;
    color: #666;
}

.wpp-canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    border-radius: 8px;
    overflow: auto;
}

#wpp-canvas {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.wpp-zone-status {
    margin-top: 12px;
    text-align: center;
}

.wpp-zone-count {
    font-size: 14px;
    color: #666;
    padding: 6px 16px;
    background: #fff;
    border-radius: 20px;
    display: inline-block;
}

/* Modal Footer */
.wpp-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #ddd;
}

/* Buttons */
.wpp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.wpp-btn-primary {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.wpp-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
    color: #fff !important;
}

.wpp-btn-outline {
    background: transparent;
    border: 2px solid #ddd;
    color: #666;
}

.wpp-btn-outline:hover {
    border-color: #999;
    color: #333;
}

.wpp-btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

/* Loading overlay */
.wpp-modal-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.wpp-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    border-top-color: #e74c3c;
    border-radius: 50%;
    animation: wpp-spin 0.8s linear infinite;
}

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

/* Alert Modal */
.wpp-alert-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
}

.wpp-alert-content {
    background: #fff;
    padding: 32px;
    border-radius: 12px;
    text-align: center;
    max-width: 350px;
}

.wpp-alert-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.wpp-alert-content p {
    margin: 0 0 20px;
    color: #333;
    line-height: 1.5;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .wpp-modal-header {
        padding: 10px 15px;
    }

    .wpp-close-text {
        display: none;
    }

    .wpp-modal-title {
        font-size: 15px;
    }

    .wpp-modal-body {
        flex-direction: column;
    }

    .wpp-modal-sidebar {
        position: fixed;
        bottom: 70px;
        left: 0;
        right: 0;
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-right: none;
        border-top: 1px solid #ddd;
        border-radius: 16px 16px 0 0;
        z-index: 10;
        transform: translateY(calc(100% - 50px));
        transition: transform 0.3s ease;
    }

    .wpp-modal-sidebar.expanded {
        transform: translateY(0);
    }

    .wpp-sidebar-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: 8px auto;
        cursor: pointer;
    }

    .wpp-modal-canvas-area {
        padding: 10px;
        padding-bottom: 60px;
    }

    .wpp-canvas-toolbar {
        flex-wrap: wrap;
        padding: 6px 8px;
    }

    .wpp-toolbar-btn {
        width: 32px;
        height: 32px;
    }

    .wpp-modal-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 20;
        padding: 12px 15px;
    }

    .wpp-btn-lg {
        padding: 12px 24px;
        font-size: 14px;
    }

    .wpp-uploaded-images {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Engraving Mode Styles */
.wpp-engraving-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    flex: 1;
    max-height: 100%;
    overflow-y: auto;
}

.wpp-engraving-preview {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    min-height: 350px;
    max-height: 65vh;
    overflow: hidden;
}

.wpp-svg-preview-area {
    flex: 1;
    overflow: auto;
    padding: 20px;
    text-align: center;
}

.wpp-svg-preview-area svg {
    display: inline-block;
    transition: width 0.2s ease, height 0.2s ease;
}

/* Engraving Zoom Controls */
.wpp-engraving-zoom-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.wpp-zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.wpp-zoom-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.wpp-zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

.wpp-zoom-fit {
    font-size: 14px;
    margin-left: 8px;
}

.wpp-engraving-input-area {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
}

.wpp-engraving-input-area label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.wpp-engraving-input-area input[type="text"] {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.2s;
}

.wpp-engraving-input-area input[type="text"]:focus {
    outline: none;
    border-color: #c8a97e;
}

.wpp-char-counter {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: #888;
    text-align: right;
}

.wpp-engraving-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

/* Multi-text field inputs for engraving */
.wpp-text-field-input {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.wpp-text-field-input:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.wpp-text-field-input label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #333;
    font-size: 14px;
}

.wpp-text-field-input input[type="text"] {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.2s;
}

.wpp-text-field-input input[type="text"]:focus {
    outline: none;
    border-color: #c8a97e;
}

.wpp-text-field-input .wpp-char-counter {
    display: inline-block;
    margin-top: 5px;
    font-size: 12px;
    color: #999;
}

.wpp-engraving-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

.wpp-engraving-textarea:focus {
    outline: none;
    border-color: #c8a97e;
}

.wpp-engraving-input-area h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #333;
}

/* Engraving Format Controls */
.wpp-engraving-format-controls {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.wpp-format-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.wpp-format-field {
    flex: 1;
    min-width: 100px;
}

.wpp-format-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

.wpp-format-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s;
}

.wpp-format-select:focus {
    outline: none;
    border-color: #c8a97e;
}

.wpp-format-field-size {
    max-width: 100px;
}

.wpp-format-field-color {
    max-width: 80px;
}

.wpp-format-color {
    width: 100%;
    height: 36px;
    padding: 2px;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
}

.wpp-format-color::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.wpp-format-color::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

/* Font selector with preview */
.wpp-format-field-font {
    flex: 2;
    min-width: 180px;
}

.wpp-font-select {
    font-size: 15px;
    padding: 10px 12px;
}

.wpp-font-select option {
    padding: 8px 10px;
    font-size: 16px;
}

.wpp-font-select optgroup {
    font-style: normal;
    font-weight: 600;
    color: #666;
    padding: 5px 0;
}

@media (max-width: 768px) {
    .wpp-format-row {
        flex-direction: column;
    }

    .wpp-format-field,
    .wpp-format-field-size,
    .wpp-format-field-color {
        max-width: 100%;
    }
}

/* Inline SVG Text Editing */
.wpp-engraving-inline-edit .wpp-engraving-preview {
    flex: 1;
    min-height: 400px;
}

.wpp-engraving-toolbar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 15px 20px;
}

.wpp-engraving-toolbar .wpp-engraving-hint {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.wpp-svg-preview-area {
    position: relative;
}

/* Make SVG text elements look editable */
.wpp-editable-text {
    cursor: text !important;
}

.wpp-editable-text:hover {
    opacity: 0.6;
}

/* Empty text placeholder - visible but faint */
.wpp-empty-text {
    opacity: 0.3;
    fill: #999 !important;
}

/* Overlay text editor - clearly visible above SVG */
.wpp-text-overlay-editor {
    position: absolute;
    z-index: 1000;
    background: #fff !important;
    border: 3px solid #e74c3c;
    border-radius: 6px;
    padding: 8px 15px;
    outline: none;
    text-align: left;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    color: #333 !important;
    min-width: 200px;
    font-size: 18px !important;
}

.wpp-text-overlay-editor:focus {
    border-color: #c0392b;
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
}

/* Engraving Mode Responsive */
@media (max-width: 768px) {
    .wpp-engraving-container {
        padding: 10px;
        gap: 15px;
        overflow-y: auto;
        max-height: calc(100vh - 180px);
        padding-bottom: 20px;
    }

    .wpp-engraving-inline-edit {
        flex-direction: column;
        min-height: auto;
    }

    .wpp-engraving-inline-edit .wpp-engraving-preview {
        min-height: 300px;
        flex: none;
    }

    .wpp-svg-preview-area {
        min-height: 200px;
        max-height: none;
        overflow: visible;
    }

    .wpp-svg-preview-area svg {
        min-height: 250px;
        width: 100%;
    }

    .wpp-engraving-preview {
        min-height: 280px;
    }

    .wpp-engraving-toolbar {
        padding: 12px;
        margin-top: 10px;
    }

    .wpp-engraving-toolbar .wpp-format-row {
        flex-direction: column;
        gap: 12px;
    }

    .wpp-engraving-toolbar .wpp-format-field {
        max-width: 100%;
    }

    .wpp-engraving-input-area {
        padding: 15px;
    }

    .wpp-text-field-input input[type="text"] {
        padding: 10px 12px;
        font-size: 14px;
    }
}

@media (min-width: 1200px) {
    .wpp-svg-preview-area svg {
        min-height: 400px;
    }

    .wpp-engraving-preview {
        min-height: 450px;
    }
}

/* Saved Personalization Section - shown on product page */
.wpp-saved-personalization {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #27ae60;
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.15);
}

.wpp-saved-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.wpp-saved-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #27ae60;
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    flex: 1;
}

.wpp-edit-saved,
.wpp-remove-saved {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.wpp-edit-saved {
    background: #fff;
    color: #666;
}

.wpp-edit-saved:hover {
    background: #e74c3c;
    color: #fff;
}

.wpp-remove-saved {
    background: #fff;
    color: #999;
}

.wpp-remove-saved:hover {
    background: #e74c3c;
    color: #fff;
}

.wpp-saved-preview {
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wpp-saved-preview img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
    display: block;
}

.wpp-saved-hint {
    margin: 12px 0 0;
    font-size: 13px;
    color: #666;
    font-style: italic;
    text-align: center;
}

@media (max-width: 768px) {
    .wpp-saved-personalization {
        padding: 12px;
        margin: 15px 0;
    }

    .wpp-saved-preview img {
        max-height: 150px;
    }
}

/* Text Edit Overlay Button - appears when text is selected */
.wpp-text-edit-overlay-btn {
    position: absolute;
    z-index: 1000;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: #fff;
    border: 2px solid #fff;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    transform: translateX(-50%);
    transition: all 0.2s;
    white-space: nowrap;
}

.wpp-text-edit-overlay-btn:hover {
    background: linear-gradient(135deg, #2980b9 0%, #1f6391 100%);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.5);
    transform: translateX(-50%) translateY(-2px);
}

.wpp-text-edit-overlay-btn:active {
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 768px) {
    .wpp-text-edit-overlay-btn {
        padding: 10px 20px;
        font-size: 15px;
    }
}