/* Logo Upload Modal Styles */
.d2-logo-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    /* Ensure overlay receives clicks even if global styles disable pointer events */
    pointer-events: auto !important;
}

.d2-logo-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: d2LogoModalSlideIn 0.3s ease-out;
    /* Explicitly re-enable interactions inside the modal */
    pointer-events: auto !important;
}

/* Absolutist guard: all descendants interactive */
.d2-logo-modal * { pointer-events: auto !important; }

@keyframes d2LogoModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.d2-logo-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.d2-logo-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
}

.d2-logo-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #718096;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.d2-logo-modal-close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.d2-logo-modal-body {
    padding: 24px;
}

.d2-logo-upload-section {
    margin-bottom: 32px;
}

.d2-logo-upload-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.d2-logo-upload-option {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    background: #f7fafc;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.d2-logo-upload-option:hover {
    border-color: #4299e1;
    background: #ebf8ff;
}

.d2-logo-upload-option:active {
    transform: translateY(1px);
}

.d2-logo-upload-icon {
    margin-right: 12px;
    color: #4a5568;
}

.d2-logo-upload-option:hover .d2-logo-upload-icon {
    color: #4299e1;
}

.d2-logo-upload-text strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 2px;
}

.d2-logo-upload-text small {
    font-size: 12px;
    color: #718096;
}

.d2-logo-list-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#d2-logo-count {
    font-size: 12px;
    color: #718096;
    font-weight: 400;
}

.d2-logo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 130px;
    gap: 6px;
    padding: 15px;
    min-height: 100px;
}

.d2-logo-grid.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    background: #f7fafc;
}

.d2-logo-empty-state {
    text-align: center;
    color: #718096;
    font-size: 14px;
}

.d2-logo-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 2px solid #e2e8f0;
    transition: all 0.2s;
    cursor: pointer;
}

.d2-logo-item:hover {
    border-color: #4299e1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.d2-logo-item.selected {
    border-color: #48bb78;
    background: #f0fff4;
}

.d2-logo-item.pending {
    border-color: #ed8936;
    background: #fffaf0;
}

.d2-logo-item.verified {
    border-color: #48bb78;
}

.d2-logo-item.rejected {
    border-color: #f56565;
    background: #fff5f5;
    opacity: 0.7;
}

.d2-logo-preview {
    width: 100%;
    height: 80px;
    object-fit: contain;
    background: #fff;
}

.d2-logo-info {
    padding: 8px;
    text-align: center;
}

.d2-logo-filename {
    font-size: 11px;
    color: #4a5568;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.d2-logo-status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.d2-logo-status.pending {
    background: #fed7aa;
    color: #9a3412;
}

.d2-logo-status.verified {
    background: #bbf7d0;
    color: #166534;
}

.d2-logo-status.rejected {
    background: #fecaca;
    color: #991b1b;
}

.d2-logo-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.d2-logo-item:hover .d2-logo-actions {
    opacity: 1;
}

.d2-logo-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s;
}

.d2-logo-delete-btn {
    background: #fed7d7;
    color: #c53030;
}

.d2-logo-delete-btn:hover {
    background: #feb2b2;
}

.d2-logo-select-btn {
    background: #bee3f8;
    color: #2b6cb0;
}

.d2-logo-select-btn:hover {
    background: #90cdf4;
}

.d2-logo-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: #718096;
}

.d2-logo-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #4299e1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Selected logo indicator */
.d2-logo-selected-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(72, 187, 120, 0.9);
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.d2-logo-item.selected .d2-logo-selected-indicator {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .d2-logo-modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .d2-logo-upload-options {
        grid-template-columns: 1fr;
    }
    
    .d2-logo-grid {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 110px;
        gap: 6px;
        padding: 10px;
    }
    
    .d2-logo-modal-header,
    .d2-logo-modal-body {
        padding: 16px;
    }
}

/* Upload progress indicator */
.d2-logo-upload-progress {
    margin-top: 16px;
    padding: 12px;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #4299e1;
}

.d2-logo-upload-progress-text {
    font-size: 14px;
    color: #2d3748;
    margin-bottom: 8px;
}

.d2-logo-upload-progress-bar {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
}

.d2-logo-upload-progress-fill {
    height: 100%;
    background: #4299e1;
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Toast notifications */
.d2-logo-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 10001;
    animation: d2LogoToastSlideIn 0.3s ease-out;
}

.d2-logo-toast.success {
    background: #48bb78;
}

.d2-logo-toast.error {
    background: #f56565;
}

@keyframes d2LogoToastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Design picker specific styles - matching FPD exactly */
.d2-design-item {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-flow: column;
    position: relative;
    border-radius: var(--fpd-border-radius, 4px);
    border: 1px solid #e1e4e8;
    overflow: hidden;
    transition: all 0.2s ease;
    background: #fff;
}

.d2-design-item:hover {
    border-color: #007cba;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}


.d2-logo-select-btn {
    background: #48bb78;
    color: white;
}

.d2-logo-select-btn:hover {
    background: #38a169;
}

/* Ensure design picker modal appears above logo modal */
#d2-design-picker-modal {
    z-index: 10002 !important;
}

/* Design grid layout adjustments - matching FPD exactly */
.d2-design-item .d2-logo-preview {
    width: 100%;
    height: 100%;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: contain;
    border-radius: var(--fpd-border-radius, 4px);
    object-fit: contain;
}
