/**
 * Frontend Designer CSS
 */

/* Modal  Overlay */
#dp-designer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
}

.dp-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.dp-modal-content {
    position: relative;
    max-width: 1600px;
    height: 90vh;
    max-height: 90vh;
    margin: 5vh auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Modal Header */
.dp-modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dp-modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.dp-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    line-height: 1;
}

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

/* Modal Body - Container for 3-column grid */
.dp-modal-body {
    padding: 20px;
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Page Navigation - stays at top */
.dp-page-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 12px;
    background: #f5f5f5;
    border-radius: 5px;
}

/* 3-Column Grid */
.dp-designer-grid {
    display: grid;
    grid-template-columns: 220px 1fr 320px;
    gap: 20px;
    height: calc(100% - 60px);
    overflow: hidden;
}

/* Left Column - Preview */
.dp-preview-column {
    display: flex;
    flex-direction: column;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    overflow: hidden;
}

.dp-preview-column h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

.dp-preview-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 3px;
}

/* Page Thumbnails */
.dp-page-thumbnail {
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.dp-page-thumbnail:hover {
    border-color: #23282d;
    box-shadow: 0 2px 8px rgba(34, 113, 177, 0.2);
    transform: translateX(3px);
}

.dp-page-thumbnail.active {
    border-color: #23282d;
    background: #f0f7ff;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

.dp-thumbnail-canvas {
    display: block;
    width: 100%;
    border-radius: 4px;
}

.dp-thumbnail-label {
    margin-top: 4px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #666;
}

.dp-page-thumbnail.active .dp-thumbnail-label {
    color: #23282d;
}

/* Center Column - Main Canvas */
.dp-canvas-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Canvas Controls (Snapping, etc.) */
.dp-canvas-controls {
    padding: 10px;
    background: #f9f9f9;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.dp-snap-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    user-select: none;
}

.dp-snap-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.dp-snap-toggle:hover {
    color: #23282d;
}

/* Canvas Wrapper */
.dp-canvas-wrapper {
    flex: 1;
    display: block;
    overflow: auto !important;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    background: #f5f5f5;
    width: 100%;
    height: 100%;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

/* FabricJS Canvas Container (represents the white page) */
.canvas-container {
    /* background-color: #fff !important;  <-- REFMOVED to reveal background image on wrapper */
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    /* The requested hairline */
    margin: 0 auto !important; /* Horizontally center */
}

#dp-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* Right Column - Upload Zones */
.dp-upload-column {
    display: flex;
    flex-direction: column;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 15px;
    overflow: hidden;
}

.dp-upload-column h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    font-weight: 600;
}

/* Sidebar Toggle Tabs */
.dp-sidebar-tabs {
    display: flex;
    gap: 0;
    margin: -15px -15px 12px -15px;
    border-bottom: 2px solid #ddd;
}

.dp-sidebar-tab {
    flex: 1;
    padding: 9px 6px;
    background: #f0f0f0;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.15s, color 0.15s;
    margin-bottom: -2px;
}

.dp-sidebar-tab:hover {
    background: #e3e8f0;
    color: #1d6b99;
}

.dp-sidebar-tab.active {
    background: #fff;
    border-bottom: 2px solid #23282d;
    color: #23282d;
    font-weight: 600;
}

/* Global Text Editor Wrapper */
.dp-global-text-wrap {
    padding: 4px 0;
}

/* Text Block List */
.dp-text-block-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 5px;
    background: #fff;
    gap: 6px;
}

.dp-tbi-preview {
    flex: 1;
    font-size: 12px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dp-tbi-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.dp-tbi-edit {
    font-size: 14px !important;
    padding: 1px 6px !important;
}

.dp-tbi-delete {
    font-size: 14px !important;
    padding: 1px 6px !important;
    border-color: #dc3232 !important;
}


#dp-zone-cards {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Page Navigation Buttons */
.dp-page-nav button {
    padding: 8px 16px;
    background: #23282d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.dp-page-nav button:hover:not(:disabled) {
    background: #111111;
}

.dp-page-nav button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.dp-page-info {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Zone Card - Compact for sidebar */
.dp-zone-card {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    background: #fff;
}

.dp-zone-card h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #333;
    font-weight: 600;
}

/* Dropzone */
.dp-dropzone {
    border: 2px dashed #ccc;
    border-radius: 5px;
    padding: 30px 15px;
    text-align: center;
    background: #fafafa;
    cursor: pointer;
    transition: all 0.2s;
}

.dp-dropzone:hover {
    border-color: #23282d;
    background: #f0f7ff;
}

.dp-dropzone.dragover {
    border-color: #23282d;
    background: #e1f0ff;
}

.dp-dropzone p {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 14px;
}

.dp-dropzone input[type="file"] {
    display: none;
}

/* Uploaded Files List */
.dp-uploaded-files {
    margin-top: 15px;
}

/* File List */
.file-list {
    margin-top: 10px;
}

.file-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    margin-bottom: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    position: relative;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    padding-right: 30px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-dpi {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 6px;
    border-radius: 3px;
    display: inline-block;
    width: fit-content;
}

.file-dpi.dpi-ok {
    background: #d4edda;
    color: #155724;
}

.file-dpi.dpi-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.file-item .remove-file {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-item .remove-file:hover {
    background: #c82333;
}

/* Modal Footer */
.dp-modal-footer {
    display: flex;
    align-items: center;
    padding: 20px 30px;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
}

/* Vertical Text Properties Panel */
#dp-text-properties {
    display: none;
    position: absolute;
    z-index: 1000;
    background: #ffffff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2);
    border: 1px solid #ddd;
    flex-direction: column;
    gap: 10px;
    min-width: 190px;
}

.dp-prop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dp-prop-row label {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    white-space: nowrap;
}

.dp-prop-row input[type="color"] {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    cursor: pointer;
}

.dp-prop-row input[type="number"],
.dp-prop-row select {
    flex: 1;
    min-width: 0;
}

.dp-text-styles {
    display: flex;
    gap: 4px;
}

#dp-text-delete {
    /* Overridden by inline style - small circle icon */
    width: auto !important;
    margin-top: 0;
}

.dp-cancel-btn {
    padding: 10px 24px;
    background: #f3f4f6;
    color: #333;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.dp-cancel-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.dp-save-design-btn {
    padding: 10px 24px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
}

.dp-save-design-btn:hover {
    background: #229954;
}

/* Order Form Integration */
.dp-design-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #23282d;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.dp-design-upload-btn:hover {
    background: #111111;
}

.dp-design-upload-btn .dashicons {
    font-size: 16px;
    line-height: 1;
}

.dp-design-status-hidden {
    display: none;
}

[class*="dp-design-status-"] {
    display: none;
    margin-left: 10px;
    padding: 4px 10px;
    background: #d5f5e3;
    color: #27ae60;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 1200px) {
    .dp-designer-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
    }

    .dp-preview-column {
        order: 1;
        max-height: 200px;
    }

    .dp-canvas-column {
        order: 2;
        min-height: 400px;
    }

    .dp-upload-column {
        order: 3;
        max-height: 300px;
    }
}

@media (max-width: 768px) {
    .dp-modal-content {
        max-width: 95%;
        max-height: 95vh;
        margin: 2.5vh auto;
    }

    .dp-modal-body {
        padding: 15px;
    }

    #dp-canvas {
        max-width: 100%;
        height: auto;
    }
}

/* New Styles for Thumbnails and Dropzone */
.dp-thumb-img {
    width: 100%;
    height: 80px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: #eee;
    margin-bottom: 5px;
    border-radius: 3px;
}

.dp-upload-area {
    border: 2px dashed #ccc;
    padding: 15px;
    text-align: center;
    border-radius: 5px;
    background: #fdfdfd;
    transition: all 0.2s;
    margin-top: 10px;
}

.dp-upload-area.dragover {
    border-color: #23282d;
    background: #f0f7ff;
}

/* Layout Download Button */
.dp-btn-download {
    background-color: #f0f0f1;
    color: #23282d;
    border: 1px solid #23282d;
    border-radius: 4px;
    padding: 0 15px;
    height: 38px;
    line-height: 36px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dp-btn-download:hover {
    background-color: #23282d;
    color: #fff;
    text-decoration: none;
}

.dp-btn-download:disabled {
    opacity: 0.6;
    cursor: wait;
}