/* Modal */
.ld-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
}

.ld-modal.active {
    display: flex;
    align-items: stretch;
    justify-content: center;
}

.ld-modal-content {
    background: #fff;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    border-radius: 0;
}

.ld-modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: #fff;
}

.ld-modal-header h2 {
    margin: 0;
    font-size: 20px;
    white-space: nowrap;
}

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

.ld-close:hover {
    color: #333;
}

/* Three-column body */
.ld-modal-body {
    display: grid;
    grid-template-columns: min-content fit-content(800px) 1fr;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* When PDF column is hidden, collapse the third column */
.ld-modal-body .ld-pdf-column[style*="display:none"] {
    display: none !important;
}

.ld-modal-body:has(.ld-pdf-column[style*="display:none"]) {
    grid-template-columns: min-content fit-content(800px);
}

/* Column 1 — sidebar */
.ld-sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    border-right: 1px solid #e0e0e0;
    box-sizing: border-box;
    min-width: 280px;
}

.ld-sidebar h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 12px;
    color: #222;
}

.ld-sidebar label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 15px;
}

.ld-sidebar label span:first-child {
    font-weight: 600;
    font-size: 14px;
}

.ld-sidebar label span:last-child {
    font-size: 12px;
    color: #666;
    text-align: right;
}

.ld-sidebar input[type="range"] {
    width: 100%;
}

.ld-sidebar button {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}

#ld-upload-btn {
    background: #45ad37;
    color: #fff;
}

#ld-reset {
    background: #f0f0f0;
    color: #333;
}

#ld-remove {
    background: #dc3545;
    color: #fff;
}

.ld-hint {
    font-size: 12px;
    color: #666;
    margin: 5px 0;
}

#ld-logo-info {
    padding: 10px;
    background: #f0f0f0;
    border-radius: 4px;
    margin: 10px 0;
}

#ld-logo-name {
    font-size: 12px;
    margin: 5px 0;
    word-break: break-all;
}

hr {
    margin: 16px 0;
    border: none;
    border-top: 1px solid #e0e0e0;
}

/* Branding positions */
.ld-branding-positions {
    margin-top: 4px;
}

.ld-position-row {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.ld-position-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.ld-position-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.ld-position-code {
    font-size: 15px;
    font-weight: 700;
    color: #222;
    min-width: 20px;
}

.ld-position-name {
    font-size: 12px;
    color: #666;
}

.ld-position-select {
    width: 100%;
    min-width: 240px;
    padding: 7px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
    background: #fafafa;
    cursor: pointer;
}

/* Column 2 — canvas */
.ld-canvas-area {
    background: #f5f5f5;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: auto;
    border-right: 1px solid #e0e0e0;
}

.ld-tip {
    color: #666;
    font-size: 14px;
    margin: 0 0 15px;
}

#ld-canvas-container {
    position: relative;
}

#ld-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.95);
    padding: 20px;
    border-radius: 8px;
    display: none;
}

#ld-loading.show {
    display: block;
}

/* Column 3 — PDF viewer */
.ld-pdf-column {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f9f9f9;
}

.ld-pdf-column h3 {
    font-size: 14px;
    font-weight: 700;
    color: #222;
    margin: 0;
    padding: 14px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #fff;
    flex-shrink: 0;
}

.ld-pdf-iframe {
    flex: 1;
    width: 100%;
    border: none;
    display: block;
    min-height: 0;
}

/* Footer */
.ld-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-end;
    flex-shrink: 0;
    background: #fff;
}

.ld-footer-notice {
    flex: 1;
    font-size: 12px;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    background: #fafafa;
    line-height: 1.4;
}

.ld-modal-footer button {
    padding: 12px 28px;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

#ld-save {
    background: #45ad37;
    color: #fff;
}

#ld-close-btn {
    background: #f0f0f0;
    color: #333;
}

/* Designs Grid */
.ld-designs-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
    gap: 15px !important;
    margin-top: 20px !important;
}

.ld-design-card {
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    background: #fff !important;
    position: relative !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
}

.ld-delete-design {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background: rgba(220, 53, 69, 0.95) !important;
    color: #fff !important;
    border: none !important;
    font-size: 18px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    z-index: 10 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3) !important;
    transition: background 0.2s !important;
}

.ld-delete-design:hover {
    background: rgba(200, 35, 51, 1) !important;
}

.ld-design-preview {
    aspect-ratio: 1 !important;
    background: #fafafa !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px !important;
}

.ld-design-preview img {
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: contain !important;
}

.ld-design-info {
    padding: 12px !important;
}

.ld-design-info h4 {
    margin: 0 0 6px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    min-height: 36px !important;
    display: flex !important;
    align-items: flex-start !important;
    line-height: 1.3 !important;
}

.ld-design-info p {
    margin: 0 0 4px !important;
    font-size: 12px !important;
    color: #666 !important;
}

.ld-design-date {
    font-size: 11px !important;
    color: #999 !important;
    margin-bottom: 10px !important;
}

.ld-edit-btn {
    display: block !important;
    width: 100% !important;
    padding: 8px 10px !important;
    background: #45ad37 !important;
    color: #fff !important;
    text-align: center !important;
    text-decoration: none !important;
    border-radius: 3px !important;
    font-weight: 600 !important;
    margin-bottom: 6px !important;
    font-size: 12px !important;
    border: none !important;
    transition: background 0.2s !important;
}

.ld-edit-btn:hover {
    background: #3a9330 !important;
}

.ld-design-actions {
    display: flex !important;
    gap: 6px !important;
}

.ld-design-actions a {
    flex: 1 !important;
    padding: 6px 8px !important;
    text-align: center !important;
    text-decoration: none !important;
    font-size: 11px !important;
    border-radius: 3px !important;
    transition: background 0.2s !important;
}

/* Designer Page */
.ld-designer-page {
    max-width: 1600px;
    margin: 40px auto;
    padding: 0 20px;
}

.ld-designer-page h1 {
    font-size: clamp(20px, 4vw, 32px);
}

.ld-designer-layout {
    display: flex;
    gap: 30px;
    margin-top: 30px;
}

.ld-designer-sidebar {
    width: 350px;
    flex-shrink: 0;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ld-designer-canvas {
    flex: 1;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 600px;
    position: relative;
}

.ld-designer-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
}

.ld-designer-footer button,
.ld-designer-footer a {
    padding: 14px 28px;
    border-radius: 5px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    border: none;
    cursor: pointer;
}

.ld-btn-secondary {
    background: #f0f0f0;
    color: #333;
}

/* Mobile — stack columns vertically, hide PDF */
@media (max-width: 900px) {
    .ld-modal-body {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .ld-sidebar {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .ld-canvas-area {
        border-right: none;
        min-height: 350px;
    }

    .ld-pdf-column {
        display: none;
    }

    .ld-designer-layout {
        flex-direction: column;
    }

    .ld-designer-sidebar {
        width: 100%;
    }

    .ld-designer-canvas {
        padding: 15px;
        min-height: 400px;
    }

    .ld-designer-footer {
        flex-direction: column;
    }

    .ld-designer-footer button,
    .ld-designer-footer a {
        width: 100%;
        text-align: center;
    }
}

/* Colour swatches */
.ld-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #ccc;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    flex-shrink: 0;
}

.ld-swatch:hover {
    transform: scale(1.15);
    border-color: #555;
}

.ld-swatch.selected {
    border-color: #000;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000;
}

/* Colour image thumbnails */
.ld-colour-thumb {
    cursor: pointer;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    transition: border-color 0.15s;
}

.ld-colour-thumb:hover {
    border-color: #45ad37;
}

.ld-colour-thumb.selected {
    border-color: #45ad37;
    box-shadow: 0 0 0 2px rgba(69,173,55,0.3);
}

.ld-colour-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}



