/**
 * Domain Selector Modal Styles
 * User-Controlled Scan Depth Feature
 *
 * Responsive modal design with preset cards and custom slider
 */

/* Modal Overlay */
#domain-selector-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#domain-selector-overlay.active {
    display: block;
    opacity: 1;
}

/* Modal Container */
#domain-selector-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    /* Flexbox for sticky footer */
    flex-direction: column;
}

#domain-selector-modal.active {
    display: flex;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Modal Header */
.domain-selector-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0; /* Prevent header from shrinking */
}

.domain-selector-header h2 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

.domain-selector-header p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

.domain-info {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.domain-info strong {
    font-size: 16px;
}

.variation-count {
    font-size: 20px;
    font-weight: 700;
}

/* Modal Body */
.domain-selector-body {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* Important for flex scrolling */
}

/* Warning Message */
#domain-selector-warning {
    display: none;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    font-size: 14px;
}

/* Preset Grid */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

/* Preset Card */
.preset-card {
    position: relative;
    padding: 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.preset-card.active {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.25);
}

.preset-card.recommended::before {
    content: "RECOMMENDED";
    position: absolute;
    top: -10px;
    right: 10px;
    background: #28a745;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.preset-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
}

.preset-details {
    margin-bottom: 12px;
}

.preset-details div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 14px;
}

.preset-details span:first-child {
    color: #6c757d;
}

.preset-details span:last-child {
    color: #2c3e50;
    font-weight: 600;
}

.preset-description {
    font-size: 13px;
    color: #6c757d;
    margin-top: 8px;
    line-height: 1.4;
}

/* Custom Preset Section */
.custom-preset-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
}

.custom-preset-section.active {
    border-color: #667eea;
    background: #f0f4ff;
}

.custom-preset-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.custom-preset-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.custom-domain-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

/* Slider */
.slider-container {
    margin-top: 16px;
}

#domain-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e9ecef;
    border-radius: 3px;
    outline: none;
}

#domain-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

#domain-slider::-webkit-slider-thumb:hover {
    background: #5568d3;
    transform: scale(1.2);
}

#domain-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #667eea;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

#domain-slider::-moz-range-thumb:hover {
    background: #5568d3;
    transform: scale(1.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: #6c757d;
}

/* Modal Footer */
.domain-selector-footer {
    padding: 20px 30px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevent footer from shrinking - keeps it sticky */
}

.footer-info {
    font-size: 13px;
    color: #6c757d;
}

.footer-actions {
    display: flex;
    gap: 12px;
}

.footer-actions button {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#cancel-scan-button {
    background: #e9ecef;
    color: #6c757d;
}

#cancel-scan-button:hover {
    background: #dee2e6;
}

#start-scan-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#start-scan-button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#start-scan-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Responsive Design - Small Laptop (height-based) */
@media (max-height: 800px) {
    #domain-selector-modal {
        max-height: 95vh;
    }

    .domain-selector-header {
        padding: 16px 24px;
    }

    .domain-selector-header h2 {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .domain-selector-header p {
        font-size: 13px;
    }

    .domain-info {
        margin-top: 8px;
        padding: 8px 12px;
    }

    .variation-count {
        font-size: 18px;
    }

    .domain-selector-body {
        padding: 20px;
    }

    .preset-grid {
        gap: 12px;
        margin-bottom: 20px;
    }

    .preset-card {
        padding: 14px;
    }

    .preset-title {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .preset-details div {
        margin-bottom: 4px;
    }

    .preset-description {
        font-size: 12px;
        margin-top: 6px;
    }

    .custom-preset-section {
        margin-top: 20px;
        padding: 14px;
    }

    .custom-preset-header h3 {
        font-size: 16px;
    }

    .custom-domain-value {
        font-size: 20px;
    }

    .domain-selector-footer {
        padding: 14px 24px;
    }

    .footer-actions button {
        padding: 8px 20px;
    }
}

/* Responsive Design - Tablet/Mobile (width-based) */
@media (max-width: 768px) {
    #domain-selector-modal {
        width: 95%;
        max-height: 95vh;
    }

    .domain-selector-header {
        padding: 20px;
    }

    .domain-selector-body {
        padding: 20px;
    }

    .preset-grid {
        grid-template-columns: 1fr;
    }

    .preset-details div {
        margin-bottom: 4px;
        font-size: 13px;
    }

    /* Hide descriptions on mobile to save space */
    .preset-description {
        display: none;
    }

    /* Show description only for selected card */
    .preset-card.active .preset-description {
        display: block;
    }

    .domain-selector-footer {
        flex-direction: column;
        gap: 12px;
        padding: 16px 20px;
    }

    .footer-info {
        text-align: center;
    }

    .footer-actions {
        width: 100%;
        flex-direction: column;
    }

    .footer-actions button {
        width: 100%;
        min-height: 44px; /* Touch-friendly */
    }
}

@media (max-width: 480px) {
    #domain-selector-modal {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .domain-selector-header {
        padding: 16px;
    }

    .domain-selector-header h2 {
        font-size: 18px;
    }

    .domain-selector-header p {
        font-size: 12px;
    }

    .domain-info {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        padding: 8px;
    }

    .domain-selector-body {
        padding: 16px;
    }

    .preset-card {
        padding: 12px;
    }

    .preset-title {
        font-size: 15px;
    }

    .custom-preset-section {
        padding: 12px;
        margin-top: 16px;
    }

    .custom-preset-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .custom-preset-header h3 {
        font-size: 15px;
    }

    .custom-domain-value {
        font-size: 18px;
    }

    .domain-selector-footer {
        padding: 12px 16px;
    }
}

/* Loading State */
#start-scan-button.loading {
    position: relative;
    color: transparent;
}

#start-scan-button.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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