/* ==========================================================================
   Keyboard Tester Stylesheet (Aethvion Labs Theme)
   ========================================================================== */

/* Main Grid Layout */
.kb-tester-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    margin-top: 20px;
}

@media (max-width: 1200px) {
    .kb-tester-grid {
        grid-template-columns: 1fr;
    }
}

/* Tool Hero Header */
.tool-intro-section {
    padding: 30px 24px;
    background: linear-gradient(135deg, rgba(13, 20, 38, 0.6) 0%, rgba(7, 10, 19, 0.9) 100%);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: 12px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.tool-intro-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%);
    pointer-events: none;
}

.tool-subtitle {
    font-size: 1rem;
    color: var(--text-secondary, #8F9CAE);
    max-width: 800px;
    margin-top: 10px;
    line-height: 1.6;
}

/* Glass Card Base */
.glass-card {
    background: rgba(18, 26, 47, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 240, 255, 0.1);
    border-radius: 12px;
    padding: 24px;
    position: relative;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Panels */
.workspace-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Metrics Dashboard */
.metrics-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    background: rgba(13, 20, 38, 0.7);
    border-color: rgba(0, 240, 255, 0.15);
}

.metric-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 110px;
}

.metric-item.flex-stretch {
    flex-grow: 1;
}

.metric-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary, #8F9CAE);
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    color: #ffffff;
}

.metric-value.text-glow-cyan {
    color: #00F0FF;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
}

.metric-value.text-glow-purple {
    color: #dca8ff;
    text-shadow: 0 0 10px rgba(220, 168, 255, 0.4);
}

.metric-value.text-mono {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.3rem;
}

.metric-actions {
    margin-left: auto;
}

@media (max-width: 768px) {
    .metrics-container {
        flex-direction: column;
        align-items: stretch;
    }
    .metric-actions {
        margin-left: 0;
        margin-top: 10px;
    }
}

/* Keyboard Container and Capture Focus */
.keyboard-canvas {
    position: relative;
    padding: 30px 20px 20px 20px;
    background: rgba(7, 10, 19, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.15);
    overflow-x: auto;
    outline: none;
}

.keyboard-canvas:focus-within {
    border-color: rgba(0, 240, 255, 0.5);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

/* Focus Capture Overlay */
.focus-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 10, 19, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: pointer;
    border-radius: 11px;
    transition: opacity 0.25s ease;
}

.focus-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 24px;
    max-width: 400px;
}

.overlay-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    animation: bounce 2s infinite;
}

.overlay-content h3 {
    font-family: 'Orbitron', sans-serif;
    color: #00F0FF;
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.overlay-content p {
    font-size: 0.9rem;
    color: var(--text-secondary, #8F9CAE);
    line-height: 1.5;
}

/* Physical Keyboard Wrapper */
.keyboard-tkl {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 980px; /* Force minimum width to prevent wrapping */
    margin: 0 auto;
}

/* Keyboard Row */
.keyboard-row {
    display: flex;
    gap: 7px;
    width: 100%;
}

.row-spacer {
    height: 8px;
}

/* Key Caps Base */
.key {
    height: 45px;
    min-width: 45px;
    background: rgba(25, 34, 57, 0.5);
    border: 1px solid rgba(0, 240, 255, 0.18);
    border-bottom-width: 3px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: default;
    user-select: none;
    box-sizing: border-box;
    transition: background 0.05s ease, border-color 0.05s ease, box-shadow 0.05s ease, color 0.05s ease, transform 0.05s ease;
    text-align: center;
    line-height: 1.2;
    padding: 3px 6px;
}

/* Key Cap Size Modifiers */
.key.double { width: 97px; }
.key.one-half { width: 71px; }
.key.one-three-quarter { width: 84px; }
.key.two-one-quarter { width: 108px; }
.key.two-three-quarter { width: 132px; }
.key.space { flex-grow: 1; min-width: 300px; max-width: 400px; }
.key.esc { background: rgba(220, 50, 50, 0.15); border-color: rgba(220, 50, 50, 0.4); }

/* Spacer Sizes */
.spacer-sm { width: 15px; }
.spacer-md { width: 28px; }
.spacer-lg { width: 45px; }
.spacer-xl { width: 108px; }

/* Keyboard key states */
.key.active {
    background: rgba(0, 240, 255, 0.9) !important;
    border-color: #00F0FF !important;
    border-bottom-width: 1px !important;
    color: #070a13 !important;
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.7) !important;
    transform: translateY(2px) scale(0.96);
}

.key.tested {
    border-color: rgba(138, 43, 226, 0.7);
    border-bottom-color: rgba(138, 43, 226, 0.9);
    background: rgba(138, 43, 226, 0.12);
    color: #e5cdff;
    box-shadow: inset 0 0 6px rgba(138, 43, 226, 0.2);
}

/* Presets Diagnostic Panel */
.diagnostic-presets {
    border-color: rgba(138, 43, 226, 0.15);
}

.panel-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.glow-text-cyan {
    color: #00F0FF;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.glow-text-purple {
    color: #c084fc;
    text-shadow: 0 0 10px rgba(138, 43, 226, 0.3);
}

.glow-text-green {
    color: #00FF66;
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.3);
}

.panel-sub {
    font-size: 0.85rem;
    color: var(--text-secondary, #8F9CAE);
    margin-bottom: 20px;
    line-height: 1.5;
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.preset-card {
    background: rgba(13, 20, 38, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color 0.2s, background-color 0.2s;
}

.preset-card.active {
    border-color: rgba(251, 191, 36, 0.3);
    background: rgba(251, 191, 36, 0.05);
}

.preset-card.passed {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.05);
}

.preset-card.failed {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.05);
}

.preset-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preset-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
}

.badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.badge-pending {
    background: rgba(255, 255, 255, 0.08);
    color: #a0aec0;
}

.badge-active {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    animation: pulse-orange 1s infinite alternate;
}

.badge-passed {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    text-shadow: 0 0 5px rgba(16, 185, 129, 0.4);
}

.badge-failed {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    text-shadow: 0 0 5px rgba(239, 68, 68, 0.4);
}

.preset-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.preset-keys kbd {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.preset-card.active .preset-keys kbd {
    border-color: rgba(251, 191, 36, 0.4);
}

.preset-card.passed .preset-keys kbd {
    border-color: rgba(16, 185, 129, 0.4);
    color: #a7f3d0;
}

.preset-desc {
    font-size: 0.75rem;
    color: var(--text-secondary, #8F9CAE);
    line-height: 1.4;
}

/* Right Control Panel */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

/* Sound controls styling */
.switch-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.switch-select-label {
    font-size: 0.85rem;
    color: var(--text-secondary, #8F9CAE);
}

.cyber-select {
    width: 100%;
    background: rgba(13, 20, 38, 0.7);
    border: 1px solid rgba(0, 240, 255, 0.2);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 6px;
    outline: none;
    font-size: 0.85rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s;
}

.cyber-select:focus {
    border-color: #00F0FF;
}

.cyber-select option {
    background: #0f172a;
    color: #ffffff;
}

.volume-slider-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.volume-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary, #8F9CAE);
}

.cyber-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.cyber-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #00F0FF;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
    cursor: pointer;
}

.cyber-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: none;
    border-radius: 50%;
    background: #00F0FF;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
    cursor: pointer;
}

/* Retro Terminal Event Logger */
.panel-terminal {
    flex-grow: 1;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    border-color: rgba(0, 255, 102, 0.15);
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.terminal-header h3 {
    margin: 0;
    font-size: 1rem;
}

.terminal-actions {
    display: flex;
    gap: 8px;
}

.btn-cyber-xs {
    padding: 3px 8px;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cyber-xs:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.btn-cyber-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid rgba(0, 240, 255, 0.3);
    color: #00F0FF;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.05);
}

.btn-cyber-sm:hover {
    background: #00F0FF;
    color: #070a13;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

.terminal-screen {
    flex-grow: 1;
    background: rgba(4, 8, 15, 0.9);
    border: 1px solid rgba(0, 255, 102, 0.2);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    line-height: 1.45;
    color: #00FF66;
    overflow-y: auto;
    max-height: 290px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.terminal-screen::-webkit-scrollbar {
    width: 6px;
}

.terminal-screen::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

.terminal-screen::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 102, 0.3);
    border-radius: 3px;
}

.terminal-line {
    white-space: pre-wrap;
    word-break: break-all;
    border-left: 2px solid transparent;
    padding-left: 6px;
}

.terminal-line.down {
    border-left-color: #00F0FF;
    color: #a7f3d0;
}

.terminal-line.up {
    border-left-color: rgba(138, 43, 226, 0.5);
    color: #8c8f94;
}

.terminal-line.system-msg {
    color: #fbbf24;
}

.terminal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    font-size: 0.72rem;
    color: var(--text-secondary, #8F9CAE);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00FF66;
    box-shadow: 0 0 6px #00FF66;
}

.status-dot.pulsing {
    animation: status-pulse 1.5s infinite;
}

.status-dot.offline {
    background: #ef4444;
    box-shadow: 0 0 6px #ef4444;
    animation: none;
}

.kb-capture-active {
    font-style: italic;
    color: rgba(0, 240, 255, 0.7);
}

/* Informational Guide Block */
.kb-tester-guide-section {
    margin-top: 24px;
    border-color: rgba(255, 255, 255, 0.05);
}

.kb-tester-guide-section h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.guide-col h3 {
    font-size: 1rem;
    color: #ffffff;
    margin-bottom: 10px;
    font-weight: 600;
}

.guide-col p {
    font-size: 0.85rem;
    color: var(--text-secondary, #8F9CAE);
    line-height: 1.5;
}

.guide-col kbd {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.75rem;
}

/* Keyframes and Animations */
@keyframes status-pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

@keyframes pulse-orange {
    0% { box-shadow: 0 0 2px rgba(251, 191, 36, 0.2); }
    100% { box-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }
}

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

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .status-dot.pulsing,
    .badge-active,
    .overlay-icon {
        animation: none !important;
    }
}
