/*!
 * @file        clipper2testpage.css
 * @description Stylesheet for the Clipper2 Test Suite
 * @author      Eltryus - Ricardo Marques
 * @copyright   2025-2026 Eltryus - Ricardo Marques
 * @see         {@link https://github.com/RicardoJCMarques/EasyTrace5000}
 * @license     AGPL-3.0-or-later
 */

/*
 * EasyTrace5000 - Advanced PCB Isolation CAM Workspace
 * Copyright (C) 2025-2026 Eltryus
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

:root {
    /* Theme Colors - UI Chrome */
    --primary: #3b82f6;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg: #f9fafb;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --text-secondary: #6b7280;

    /* Canvas/Shape Rendering Colors */
    --canvas-bg: #ffffff;
    --grid-color: #e5e7eb;

    /* Default shape styles */
    --shape-fill: rgba(59, 130, 246, 0.25);
    --shape-stroke: #3b82f6;
    --hole-stroke: #ef4444;

    /* Input/Output styles */
    --input-fill: rgba(229, 231, 235, 0.25);
    --input-stroke: #9ca3af;
    --output-fill: rgba(16, 185, 129, 0.25);
    --output-stroke: #10b981;

    /* Boolean test specific */
    --subject-fill: rgba(59, 130, 246, 0.25);
    --subject-stroke: #3b82f6;
    --clip-fill: rgba(239, 68, 68, 0.25);
    --clip-stroke: #ef4444;

    /* PCB specific */
    --pcb-fill: rgba(16, 185, 129, 0.25);
    --pcb-stroke: #10b981;

    /* Point-in-polygon specific */
    --pip-inside: #10b981;
    --pip-outside: #ef4444;
    --pip-edge: #f59e0b;

    /* Z-index hierarchy */
    --z-base: 1;
    --z-overlay: 10;
    --z-modal: 100;
    --z-tooltip: 1000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 1rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.site-footer {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Headers */
h1 {
    margin-bottom: 2rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.welcome-message {
    margin: -1rem 0 2rem 0;
    padding: 1.5rem;
    background: var(--surface);
    border-left: 5px solid var(--primary);
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    border-radius: 0 8px 8px 0;
}

.version-badge {
    background: var(--success);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

.test-group-header {
    margin: 2rem 0 1rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--primary);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.test-group-header::before {
    content: '▶';
    font-size: 1rem;
}

/* Test Cards */
.test-grid {
    display: grid;
    gap: 2rem;
}

.test-card {
    background: var(--surface);
    border-radius: 8px;
    padding: 1.5rem;
    position: relative;
    border: 2px solid var(--border);
}

.test-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 8px 8px 0 0;
}

/* Card status states via data attributes */
.test-card[data-status="pending"] {
    border-color: var(--warning);
}

.test-card[data-status="pending"]::before {
    background: var(--warning);
}

.test-card[data-status="success"] {
    border-color: var(--success);
}

.test-card[data-status="success"]::before {
    background: var(--success);
}

.test-card[data-status="error"] {
    border-color: var(--error);
}

.test-card[data-status="error"]::before {
    background: var(--error);
}

.test-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.test-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.test-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

/* Canvas Container */
.canvas-container {
    display: grid;
    grid-template-columns: 800px 1fr;
    gap: 2rem;
    align-items: start;
    margin-bottom: 1rem;
}

.canvas-wrapper {
    position: relative;
    background: var(--canvas-bg);
    border: 2px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
    width: 800px;
    height: 800px;
}

/* Style for controls panel */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Canvas elements */
canvas {
    display: block;
    width: 800px;
    height: 800px;
    image-rendering: optimizeQuality;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 4px;
}

.control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.control input,
.control select {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
    background: white;
}

.control input:focus,
.control select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
}

.btn-toggle {
    background: var(--warning);
    color: white;
}

.btn-toggle:hover {
    background: #d97706;
}

.btn-success {
    background: var(--success);
    color: white;
    font-size: 0.75rem;
    padding: 0.375rem 0.75rem;
}

.btn-success:hover {
    background: #059669;
}

/* Result Display */
.result {
    padding: 1rem;
    background: var(--bg);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: 'Consolas', 'Monaco', monospace;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.test-card[data-status="success"] .result {
    background: #ecfdf5;
    color: #065f46;
    border-color: var(--success);
}

.test-card[data-status="error"] .result {
    background: #fef2f2;
    color: #991b1b;
    border-color: var(--error);
}

.test-card[data-status="pending"] .result {
    background: #fffbeb;
    color: #78350f;
    border-color: var(--warning);
}

/* Stats Display */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 4px;
}

.stat {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--primary);
}

/* Geometry Info */
.geometry-info {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #1f2937;
    color: #10b981;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Consolas', 'Monaco', monospace;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.4;
}

.geometry-info::-webkit-scrollbar {
    width: 8px;
}

.geometry-info::-webkit-scrollbar-track {
    background: #374151;
    border-radius: 4px;
}

.geometry-info::-webkit-scrollbar-thumb {
    background: #10b981;
    border-radius: 4px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

.badge.new {
    background: var(--success);
}

.badge.experimental {
    background: var(--warning);
}

/* Legend */
.legend {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-color {
    width: 16px;
    height: 16px;
    border: 1px solid #333;
    border-radius: 2px;
}

/* Tangency Controls */
.tangency-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    z-index: var(--z-tooltip);
    min-width: 280px;
}

.tangency-controls h4 {
    margin: 0 0 10px 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.tangency-controls .control-group {
    margin-bottom: 12px;
}

.tangency-controls .control-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.tangency-controls .control-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tangency-controls .control-row input {
    flex: 1;
}

.tangency-controls .control-row span {
    min-width: 120px;
    font-size: 12px;
    font-family: monospace;
    color: var(--text);
}

.tangency-controls select,
.tangency-controls input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 12px;
    background: white;
}

.tangency-controls button {
    width: 100%;
    padding: 6px 12px;
    margin-top: 12px;
}

.tangency-info {
    margin-top: 8px;
    padding: 8px;
    border-radius: 4px;
    font-size: 11px;
    display: none;
}

.tangency-info.success {
    display: block;
    background: #ecfdf5;
    color: #065f46;
}

.tangency-info.warning {
    display: block;
    background: #fef3c7;
    color: #92400e;
}

/* Additional Information Section */
.info-card {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.info-card h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.info-card p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.info-card ul {
    color: var(--text);
    line-height: 1.8;
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.info-card a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.info-card a:hover {
    text-decoration: underline;
}

/* Loading Indicator */
.loading {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 8px;
    z-index: var(--z-modal);
}

.loading.active {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes bounce {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(5px); }
}

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

/* Utility Classes */
.u-hidden {
    display: none !important;
}

.u-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.u-text-center {
    text-align: center;
}

.u-mt-1 {
    margin-top: 0.5rem;
}

.u-mt-2 {
    margin-top: 1rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .canvas-container {
        grid-template-columns: 1fr;
    }
    
    .canvas-wrapper {
        width: 100%;
        max-width: 800px;
        height: auto;
        aspect-ratio: 1 / 1;
        margin: 0 auto;
    }

    canvas {
        width: 100%;
        height: 100%;
    }
}

@media (max-width: 768px) {
    .test-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control {
        width: 100%;
        justify-content: space-between;
    }
    
    .tangency-controls {
        bottom: 10px;
        right: 10px;
        left: 10px;
        min-width: auto;
    }
}