/**
 * Scanner Test Page Styles
 * Experimental scanner and keyboard testing interface
 */

/* ============================================================================
   CONTAINER
   ============================================================================ */

.scanner-test-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    background: var(--background-color);
    min-height: 100vh;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.test-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: var(--card-background);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.test-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.test-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    flex: 1;
    text-align: center;
}

.close-test-btn {
    background: var(--error-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-test-btn:hover {
    background: var(--error-hover-color);
    transform: translateY(-1px);
}

/* ============================================================================
   CONFIG PANEL
   ============================================================================ */

.config-panel {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.config-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
}

.config-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.config-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.config-option:hover {
    border-color: var(--primary-color);
    background: var(--hover-background);
}

.config-option input[type="radio"] {
    margin-top: 0.25rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.config-option input[type="radio"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

.config-option span {
    display: block;
}

.config-option span:first-of-type {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.config-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 400 !important;
}

/* ============================================================================
   SCAN TEST AREA
   ============================================================================ */

.scan-test-area {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.test-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
}

.scan-status {
    padding: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
    background: var(--background-color);
    color: var(--text-secondary);
    border: 2px solid var(--border-color);
}

.scan-status.success {
    background: #d4edda;
    color: #155724;
    border-color: #28a745;
}

.scan-status.error {
    background: #f8d7da;
    color: #721c24;
    border-color: #dc3545;
}

.scan-input-wrapper {
    margin-bottom: 1rem;
}

.scan-input {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--background-color);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.scan-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
}

.scan-input[readonly] {
    background: var(--hover-background);
    cursor: not-allowed;
}

.scan-result {
    padding: 1rem;
    background: var(--background-color);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.scan-result-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.scan-result-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
}

.scan-buffer {
    padding: 1rem;
    background: var(--background-color);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.scan-buffer-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.scan-buffer-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    min-height: 1.75rem;
}

.expected-section {
    padding: 1rem;
    background: #e7f3ff;
    border: 2px solid #0066cc;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.expected-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #004499;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.expected-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0066cc;
    font-family: 'Courier New', monospace;
}

.test-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.test-btn {
    flex: 1;
    padding: 0.875rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.test-btn:hover {
    background: var(--primary-hover-color);
    transform: translateY(-1px);
}

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

/* ============================================================================
   EVENT LOG
   ============================================================================ */

.event-log-section {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.event-log {
    max-height: 400px;
    overflow-y: auto;
    background: var(--background-color);
    border-radius: 8px;
    padding: 0.5rem;
}

.log-entry {
    display: grid;
    grid-template-columns: 50px 80px 150px 1fr;
    gap: 0.5rem;
    padding: 0.5rem;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Courier New', monospace;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-number {
    color: var(--text-secondary);
    font-weight: 600;
}

.log-time {
    color: var(--text-secondary);
}

.log-type {
    color: var(--primary-color);
    font-weight: 600;
}

.log-details {
    color: var(--text-primary);
}

/* ============================================================================
   INFO PANEL
   ============================================================================ */

.info-panel {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.info-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
}

.info-title:not(:first-child) {
    margin-top: 1.5rem;
}

.info-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.info-list li {
    margin-bottom: 0.5rem;
}

.info-list li:last-child {
    margin-bottom: 0;
}

.info-list strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================================================
   TELEMETRY PANEL
   ============================================================================ */

.telemetry-panel {
    background: var(--card-background);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.telemetry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.telemetry-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--background-color);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.telemetry-item.success {
    border-color: var(--success-color);
    background: rgba(34, 197, 94, 0.05);
}

.telemetry-item.error {
    border-color: var(--error-color);
    background: rgba(239, 68, 68, 0.05);
}

.telemetry-item.pending {
    border-color: var(--border-color);
    opacity: 0.7;
}

.telemetry-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    opacity: 0.5;
}

.telemetry-item.success .telemetry-icon {
    opacity: 1;
    filter: invert(48%) sepia(79%) saturate(2476%) hue-rotate(86deg) brightness(118%) contrast(119%);
}

.telemetry-item.error .telemetry-icon {
    opacity: 1;
    filter: invert(27%) sepia(51%) saturate(2878%) hue-rotate(346deg) brightness(104%) contrast(97%);
}

.telemetry-content {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
}

.telemetry-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.telemetry-status {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.telemetry-item.success .telemetry-status {
    color: var(--success-color);
    font-weight: 600;
}

.telemetry-item.error .telemetry-status {
    color: var(--error-color);
    font-weight: 600;
}

.telemetry-summary {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--background-color);
    border-radius: 8px;
    text-align: center;
}

#telemetrySummary {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================================================
   CAMERA SCANNER
   ============================================================================ */

.camera-scanner-wrapper {
    margin-bottom: 1rem;
}

#qr-reader {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    border-radius: 8px;
    overflow: hidden;
    background: var(--background-color);
}

/* Style the video element */
#qr-reader video {
    width: 100% !important;
    height: auto !important;
    border-radius: 8px;
}

/* Style the scanning region */
#qr-reader__scan_region {
    background: rgba(0, 0, 0, 0.1) !important;
    border-radius: 8px !important;
}

/* Customize the scanning box */
#qr-reader__scan_region > div {
    border: 3px solid var(--primary-color) !important;
    box-shadow: 0 0 0 99999px rgba(0, 0, 0, 0.5);
}

/* Style the dashboard (camera selection, etc.) */
#qr-reader__dashboard {
    padding: 1rem !important;
}

#qr-reader__dashboard_section {
    padding: 0.5rem !important;
}

#qr-reader__dashboard_section_csr select {
    padding: 0.5rem !important;
    border-radius: 6px !important;
    border: 2px solid var(--border-color) !important;
    background: var(--background-color) !important;
    color: var(--text-primary) !important;
    font-size: 0.875rem !important;
}

#qr-reader__dashboard_section_csr button {
    padding: 0.5rem 1rem !important;
    border-radius: 6px !important;
    background: var(--primary-color) !important;
    color: white !important;
    border: none !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    margin-top: 0.5rem !important;
}

/* Hide file scanner if not needed */
#qr-reader__dashboard_section_fsr {
    display: none !important;
}

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

.camera-controls button {
    padding: 0.875rem 1.5rem;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.camera-controls button:hover {
    background: var(--error-hover-color);
    transform: translateY(-1px);
}

.camera-controls button:active {
    transform: translateY(0);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .scanner-test-container {
        padding: 0.75rem;
    }

    .test-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .test-title {
        order: -1;
        flex-basis: 100%;
        text-align: left;
        font-size: 1.125rem;
    }

    .test-badge {
        order: -2;
    }

    .log-entry {
        grid-template-columns: 40px 70px 1fr;
        font-size: 0.7rem;
    }

    .log-type {
        grid-column: 3;
    }

    .log-details {
        grid-column: 1 / -1;
        margin-top: 0.25rem;
        padding-left: 0.5rem;
        border-left: 2px solid var(--primary-color);
    }
}
