/* ===========================
   DITHERING MODAL
   Add this to the end of style.css
   =========================== */

/* Modal Overlay */
.dither-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dither-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

/* Modal Content */
.dither-modal-content {
    position: relative;
    width: 850px;
    max-width: 90vw;
    max-height: 85vh;
    background: rgba(15, 23, 42, 0.98);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Header */
.dither-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.dither-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #ffffff;
    margin: 0;
}

.dither-modal-close {
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.dither-modal-close:hover {
    color: #ffffff;
}

/* Status Bar */
.dither-status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 25px;
    background: rgba(30, 41, 59, 0.5);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.status-icon {
    font-size: 18px;
}

.status-text {
    font-size: 14px;
    color: #cbd5e1;
}

.dither-status-bar.ready .status-text {
    color: #10b981;
}

.dither-status-bar.uploading .status-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Modal Body: Two Columns */
.dither-modal-body {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    padding: 20px 25px;
    flex: 1;
    overflow-y: auto;
}

.column-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #94a3b8;
    margin: 0 0 10px 0;
}

/* Left Column: Algorithms */
.dither-algorithms-column {
    display: flex;
    flex-direction: column;
}

/* Algorithm Cards */
.dither-card {
    position: relative;
    padding: 12px 14px;
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid rgba(148, 163, 184, 0.2);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dither-card:hover {
    border-color: #60a5fa;
    transform: translateX(3px);
}

.dither-card.selected {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(139, 92, 246, 0.25));
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.card-content {
    flex: 1;
}

.card-name {
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 2px;
}

.card-speed {
    font-size: 11px;
    color: #94a3b8;
}

.card-badge {
    font-size: 11px;
    font-weight: 600;
    color: #10b981;
    margin-right: 8px;
}

.card-radio {
    font-size: 20px;
    color: #cbd5e1;
    min-width: 20px;
    text-align: center;
}

.dither-card.selected .card-radio {
    color: #3b82f6;
}

.dither-card.selected .card-radio::before {
    content: '●';
}

.dither-card:not(.selected) .card-radio::before {
    content: '○';
}

/* Right Column: Description */
.dither-description-column {
    display: flex;
    flex-direction: column;
}

.description-box {
    flex: 1;
    padding: 15px;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 6px;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.6;
}

.description-placeholder {
    color: #64748b;
    font-style: italic;
    margin: 0;
}

.description-box p {
    margin: 0 0 15px 0;
}

.description-box p:last-child {
    margin-bottom: 0;
}

/* Footer Buttons */
.dither-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    width: 100%;
    box-sizing: border-box;
}

.dither-about-link {
    color: #64748b;
    font-size: 13px;
    text-decoration: none;
    transition: color 0.3s;
    flex-shrink: 0;
    order: -1; /* Force to appear first */
}

.dither-about-link:hover {
    color: #94a3b8;
    text-decoration: underline;
}

.dither-footer-buttons {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
}

.dither-btn-cancel,
.dither-btn-apply {
    padding: 10px 25px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
}

.dither-btn-cancel {
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.dither-btn-cancel:hover {
    background: rgba(30, 41, 59, 1);
    border-color: rgba(148, 163, 184, 0.5);
}

.dither-btn-apply {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.dither-btn-apply:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
    transform: translateY(-2px);
}

.dither-btn-apply:disabled {
    background: rgba(30, 41, 59, 0.8);
    color: #64748b;
    cursor: not-allowed;
    box-shadow: none;
}

/* Processing Overlay */
.dither-processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

/* Laser Dithering Animation Container */
.processing-spinner {
    width: 100px;
    height: 80px;
    position: relative;
    margin-bottom: 20px;
}

/* Laser beam scanning horizontally */
.processing-spinner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        #3b82f6 20%, 
        #60a5fa 50%, 
        #3b82f6 80%, 
        transparent 100%);
    box-shadow: 0 0 15px #3b82f6, 0 0 30px #3b82f6;
    animation: laserScan 2s ease-in-out infinite;
}

/* Dot grid that appears as laser passes */
.processing-spinner::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    width: 80px;
    height: 60px;
    background-image: 
        radial-gradient(circle, #60a5fa 1.5px, transparent 1.5px);
    background-size: 10px 10px;
    animation: dotsAppear 2s ease-in-out infinite;
    mask-image: linear-gradient(to bottom, black, black 50%, transparent 50%);
    -webkit-mask-image: linear-gradient(to bottom, black, black 50%, transparent 50%);
}

@keyframes laserScan {
    0%, 100% { 
        top: 0; 
        opacity: 1;
    }
    45% { 
        top: 70px; 
        opacity: 1;
    }
    50% {
        top: 70px;
        opacity: 0;
    }
    55% {
        top: 0;
        opacity: 0;
    }
    60% {
        top: 0;
        opacity: 1;
    }
}

@keyframes dotsAppear {
    0% {
        mask-image: linear-gradient(to bottom, black 0%, transparent 0%);
        -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 0%);
    }
    45% {
        mask-image: linear-gradient(to bottom, black 100%, transparent 100%);
        -webkit-mask-image: linear-gradient(to bottom, black 100%, transparent 100%);
    }
    50%, 55% {
        opacity: 0.3;
    }
    60% {
        mask-image: linear-gradient(to bottom, black 0%, transparent 0%);
        -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 0%);
        opacity: 1;
    }
}

.processing-text {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.processing-time {
    font-size: 14px;
    color: #94a3b8;
}

/* Responsive */
@media (max-width: 768px) {
    .dither-modal-body {
        grid-template-columns: 1fr;
    }
    
    .dither-modal-content {
        width: 95vw;
        max-height: 95vh;
    }
    
    .dither-card {
        padding: 15px 12px;
    }
    
    .card-name {
        font-size: 15px;
    }
}
