/**
 * CSS Analyzer Tool - Custom Styles
 * 
 * Professional, responsive CSS with dark/light theme support
 * Optimized for CSS analysis results display and user experience
 */

/* CSS Analyzer Specific Variables */
:root {
    --css-success: #198754;
    --css-warning: #ffc107;
    --css-danger: #dc3545;
    --css-info: #0dcaf0;
    --css-critical: #721c24;
    --css-suggestion: #6f42c1;
    
    --gradient-success: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    --gradient-warning: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    --gradient-danger: linear-gradient(135deg, #dc3545 0%, #e91e63 100%);
    --gradient-info: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%);
    
    --results-bg: #ffffff;
    --results-border: #e9ecef;
    --card-hover-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1);
    --element-bg: #f8f9fa;
    --element-border: #dee2e6;
}

/* Dark theme variables */
[data-bs-theme="dark"] {
    --results-bg: #2d3748;
    --results-border: #4a5568;
    --element-bg: #1a202c;
    --element-border: #2d3748;
}

/* Progress Section Styling */
.progress-container {
    background: var(--results-bg);
    border: 1px solid var(--results-border);
    border-radius: 15px;
    padding: 2rem;
    margin: 2rem 0;
    position: relative;
    overflow: hidden;
}

.progress-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        rgba(var(--bs-primary-rgb), 0.03) 25%, 
        transparent 25%, 
        transparent 50%, 
        rgba(var(--bs-primary-rgb), 0.03) 50%, 
        rgba(var(--bs-primary-rgb), 0.03) 75%, 
        transparent 75%);
    background-size: 20px 20px;
    animation: move-stripes 2s linear infinite;
}

@keyframes move-stripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 20px; }
}

.scanning-animation {
    display: inline-block;
    animation: scan-pulse 2s ease-in-out infinite;
}

@keyframes scan-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.05); }
}

/* Results Section Styling */
#resultsSection {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Health Score Circle */
.health-score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin: 0 auto 1rem;
}

.health-score-excellent {
    background: var(--gradient-success);
    color: white;
}

.health-score-good {
    background: var(--gradient-info);
    color: white;
}

.health-score-warning {
    background: var(--gradient-warning);
    color: #000;
}

.health-score-poor {
    background: var(--gradient-danger);
    color: white;
}

.health-score-circle .score-number {
    font-size: 2rem;
    font-weight: bold;
}

.health-score-circle .score-label {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* Summary Cards */
.summary-card {
    border: 1px solid var(--results-border);
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    background: var(--results-bg);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-hover-shadow);
}

.summary-card .card-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.summary-card .card-number {
    font-size: 2.5rem;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.summary-card .card-label {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0;
}

/* Performance Impact Indicators */
.performance-impact {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.performance-impact-low {
    background-color: rgba(25, 135, 84, 0.1);
    color: var(--css-success);
    border: 1px solid rgba(25, 135, 84, 0.2);
}

.performance-impact-medium {
    background-color: rgba(255, 193, 7, 0.1);
    color: #bf9000;
    border: 1px solid rgba(255, 193, 7, 0.2);
}

.performance-impact-high {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--css-danger);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

/* CSS Property Breakdown */
.css-property-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--element-bg);
    border: 1px solid var(--element-border);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.css-property-item:hover {
    background: rgba(var(--bs-primary-rgb), 0.05);
    border-color: var(--bs-primary);
}

.css-property-name {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #e83e8c;
}

.css-property-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.css-property-count {
    font-weight: bold;
    color: var(--bs-primary);
}

.css-property-percentage {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Element Details */
.element-detail {
    border: 1px solid var(--element-border);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
    background: var(--results-bg);
}

.element-header {
    background: var(--element-bg);
    padding: 1rem;
    border-bottom: 1px solid var(--element-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.element-header:hover {
    background: rgba(var(--bs-primary-rgb), 0.05);
}

.element-tag {
    font-family: 'Courier New', monospace;
    background: var(--bs-primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.element-identifier {
    font-family: 'Courier New', monospace;
    color: #6f42c1;
    font-size: 0.9rem;
}

.element-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.element-complexity {
    background: rgba(255, 193, 7, 0.1);
    color: #bf9000;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.element-property-count {
    background: rgba(13, 202, 240, 0.1);
    color: #0a7fa8;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.element-content {
    padding: 1rem;
    display: none;
}

.element-content.show {
    display: block;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
}

.element-style {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-x: auto;
}

[data-bs-theme="dark"] .element-style {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

/* Recommendations Section */
.recommendation-item {
    border: 1px solid var(--element-border);
    border-radius: 10px;
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.recommendation-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.recommendation-critical {
    border-left: 4px solid var(--css-danger);
}

.recommendation-warning {
    border-left: 4px solid var(--css-warning);
}

.recommendation-suggestion {
    border-left: 4px solid var(--css-suggestion);
}

.recommendation-info {
    border-left: 4px solid var(--css-info);
}

.recommendation-success {
    border-left: 4px solid var(--css-success);
}

.recommendation-header {
    background: var(--element-bg);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.recommendation-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.recommendation-critical .recommendation-icon {
    background: rgba(220, 53, 69, 0.1);
    color: var(--css-danger);
}

.recommendation-warning .recommendation-icon {
    background: rgba(255, 193, 7, 0.1);
    color: #bf9000;
}

.recommendation-suggestion .recommendation-icon {
    background: rgba(111, 66, 193, 0.1);
    color: var(--css-suggestion);
}

.recommendation-info .recommendation-icon {
    background: rgba(13, 202, 240, 0.1);
    color: var(--css-info);
}

.recommendation-success .recommendation-icon {
    background: rgba(25, 135, 84, 0.1);
    color: var(--css-success);
}

.recommendation-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.recommendation-content {
    padding: 0 1rem 1rem 1rem;
}

.recommendation-description {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.recommendation-solution {
    background: rgba(var(--bs-primary-rgb), 0.05);
    border: 1px solid rgba(var(--bs-primary-rgb), 0.1);
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Page Metrics */
.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--element-border);
}

.metric-item:last-child {
    border-bottom: none;
}

.metric-label {
    font-weight: 500;
    color: #495057;
    font-size: 0.875rem;
}

.metric-value {
    font-weight: 600;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

/* Export and Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn-export {
    background: var(--gradient-info);
    border: none;
    color: white;
    transition: all 0.3s ease;
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3);
    color: white;
}

/* Responsive Design */
@media (max-width: 768px) {
    .health-score-circle {
        width: 100px;
        height: 100px;
    }
    
    .health-score-circle .score-number {
        font-size: 1.5rem;
    }
    
    .summary-card .card-number {
        font-size: 2rem;
    }
    
    .element-stats {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .css-property-stats {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-end;
    }
    
    .action-buttons {
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .progress-container {
        padding: 1.5rem 1rem;
        margin: 1rem 0;
    }
    
    .summary-card {
        padding: 1rem;
    }
    
    .element-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .element-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .recommendation-header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
}

/* Print Styles */
@media print {
    .progress-container,
    .action-buttons,
    #exportBtn,
    .btn {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .element-content {
        display: block !important;
    }
    
    .recommendation-item {
        page-break-inside: avoid;
    }
    
    body {
        font-size: 12px;
    }
    
    .health-score-circle {
        border: 2px solid #000;
    }
}

/* Loading States */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scanning-animation {
        animation: none;
    }
}

/* Focus States */
.element-header:focus,
button:focus,
.btn:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Utility Classes */
.text-monospace {
    font-family: 'Courier New', monospace !important;
}

.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.border-start-primary {
    border-left: 3px solid var(--bs-primary) !important;
}

.bg-light-primary {
    background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
}

/* Theme Toggle Animation */
.rotating {
    animation: rotate 0.3s ease-in-out;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(180deg);
    }
}
