/*
 * Test Pattern Generator Module - Feature Flag: test_pattern_generator
 * Professional styling for calibration patterns interface
 * Version 8.3.6 - August 24, 2025
 */

/* Main test pattern panel */
.test-pattern-panel {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin: 15px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.pattern-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #dee2e6;
    background: #ffffff;
    border-radius: 8px 8px 0 0;
}

.pattern-header h3 {
    margin: 0;
    color: #495057;
    font-size: 1.1rem;
    font-weight: 600;
}

#test-pattern-toggle {
    padding: 6px 12px;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

#test-pattern-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Pattern controls content */
.pattern-controls-content {
    padding: 16px;
}

.pattern-categories {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pattern-category h4 {
    margin: 0 0 12px 0;
    color: #343a40;
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid #007bff;
    padding-bottom: 4px;
}

.pattern-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

/* Pattern selection buttons */
.pattern-btn {
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pattern-btn:hover {
    border-color: #007bff;
    color: #007bff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

.pattern-btn:active {
    transform: translateY(0);
}

.pattern-btn.active {
    background: #007bff;
    color: #ffffff;
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.3);
}

.pattern-btn.active:hover {
    background: #0056b3;
    border-color: #0056b3;
}

/* Pattern actions */
.pattern-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

#clear-pattern {
    flex: 1;
    min-width: 120px;
}

#export-pattern {
    flex: 1;
    min-width: 120px;
}

/* Pattern status indicator */
.pattern-status {
    margin-top: 12px;
    padding: 8px 12px;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1565c0;
    text-align: center;
}

/* Floating panel variant for pages without sidebar */
.test-pattern-floating {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 320px;
    z-index: 1000;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.test-pattern-floating .test-pattern-panel {
    margin: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Category-specific button styling */
.pattern-category:nth-child(1) h4 { border-bottom-color: #dc3545; } /* Calibration - Red */
.pattern-category:nth-child(2) h4 { border-bottom-color: #28a745; } /* Geometric - Green */  
.pattern-category:nth-child(3) h4 { border-bottom-color: #ffc107; } /* Color - Yellow */

.pattern-category:nth-child(1) .pattern-btn:hover { border-color: #dc3545; color: #dc3545; }
.pattern-category:nth-child(2) .pattern-btn:hover { border-color: #28a745; color: #28a745; }
.pattern-category:nth-child(3) .pattern-btn:hover { border-color: #ffc107; color: #ffc107; }

.pattern-category:nth-child(1) .pattern-btn.active { background: #dc3545; border-color: #dc3545; }
.pattern-category:nth-child(2) .pattern-btn.active { background: #28a745; border-color: #28a745; }
.pattern-category:nth-child(3) .pattern-btn.active { background: #ffc107; border-color: #ffc107; color: #212529; }

/* Responsive design */
@media (max-width: 768px) {
    .test-pattern-floating {
        position: relative;
        top: auto;
        right: auto;
        width: 100%;
        max-height: none;
        margin: 15px 0;
    }

    .pattern-buttons {
        grid-template-columns: 1fr;
    }

    .pattern-actions {
        flex-direction: column;
    }

    .pattern-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .pattern-header h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .pattern-controls-content {
        padding: 12px;
    }
    
    .pattern-btn {
        min-height: 40px;
        font-size: 0.8rem;
    }

    .pattern-categories {
        gap: 16px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .test-pattern-panel {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .pattern-header {
        background: #374151;
        border-color: #4a5568;
    }

    .pattern-header h3 {
        color: #f7fafc;
    }

    .pattern-category h4 {
        color: #f7fafc;
    }

    .pattern-btn {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #718096;
    }

    .pattern-btn:hover {
        background: #4a5568;
        color: #ffffff;
    }

    .pattern-status {
        background: #2d3748;
        border-color: #4a5568;
        color: #90cdf4;
    }
}

/* Loading states */
.pattern-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.pattern-btn.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

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

/* Professional mode integration */
body.professional-installer .pattern-category:nth-child(2) {
    order: -1; /* Prioritize geometric patterns for installers */
}

body.professional-integrator .pattern-category:nth-child(1) {
    order: -1; /* Prioritize calibration patterns for integrators */
}

/* Custom pattern upload section */
.pattern-upload {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: #f8f9fa;
    border: 2px dashed #6f42c1;
    border-radius: 8px;
    text-align: center;
}

.upload-info {
    color: #6c757d;
    font-size: 11px;
    line-height: 1.4;
    margin-top: 8px;
}

.upload-info small {
    display: block;
}

#upload-pattern-btn {
    align-self: center;
    min-width: 140px;
    font-weight: 600;
}

#upload-pattern-btn:hover {
    background: #5a359a !important;
    border-color: #5a359a !important;
}

.upload-success {
    color: #28a745;
    font-weight: 600;
    margin-top: 8px;
    font-size: 12px;
}

.upload-error {
    color: #dc3545;
    font-weight: 600;
    margin-top: 8px;
    font-size: 12px;
}

/* Loading state for upload button */
#upload-pattern-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

#upload-pattern-btn.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .pattern-btn {
        border-width: 3px;
    }
    
    .pattern-btn:focus {
        outline: 3px solid #005fcc;
        outline-offset: 2px;
    }
}