/* Debug Tuning Panel - Mobile-First */

.debug-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(320px, 85vw);
    height: 100vh;
    height: 100dvh;
    background: rgba(10, 10, 30, 0.94);
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease-out;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
}

.debug-panel.open {
    transform: translateX(0);
}

/* Header */
.debug-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
    background: rgba(20, 20, 50, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.debug-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

.debug-panel-close {
    width: 34px;
    height: 34px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.debug-panel-close:active {
    background: rgba(255, 255, 255, 0.2);
}

/* Scrollable body */
.debug-panel-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
}

/* Sections */
.debug-section {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.debug-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    background: rgba(255, 255, 255, 0.03);
}

.debug-section-header:active {
    background: rgba(255, 255, 255, 0.07);
}

.debug-section-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.debug-section-reset {
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #aaa;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.debug-section-reset:active {
    background: rgba(234, 67, 53, 0.25);
    color: #f8a09a;
}

.debug-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #8ab4f8;
}

.debug-section-arrow {
    font-size: 10px;
    color: #666;
    transition: transform 0.2s ease;
}

.debug-section.expanded .debug-section-arrow {
    transform: rotate(90deg);
}

.debug-section-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.debug-section.expanded .debug-section-body {
    max-height: 2000px;
}

.debug-section-content {
    padding: 8px 14px 14px;
}

/* Range slider control */
.debug-control {
    margin-bottom: 10px;
}

.debug-control-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.debug-control-name {
    font-size: 11px;
    color: #aaa;
}

.debug-control-value {
    width: 58px;
    height: 26px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #fff;
    font-size: 11px;
    text-align: center;
    font-family: monospace;
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

.debug-control-value:focus {
    border-color: #8ab4f8;
}

.debug-control-value::-webkit-inner-spin-button,
.debug-control-value::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.debug-slider {
    width: 100%;
    height: 28px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    touch-action: none;
}

.debug-slider::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.debug-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: #8ab4f8;
    border-radius: 50%;
    margin-top: -9px;
    border: 2px solid rgba(10, 10, 30, 0.8);
}

.debug-slider::-moz-range-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    border: none;
}

.debug-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: #8ab4f8;
    border-radius: 50%;
    border: 2px solid rgba(10, 10, 30, 0.8);
}

/* Toggle control */
.debug-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.debug-toggle-label {
    font-size: 11px;
    color: #aaa;
}

.debug-toggle {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.debug-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.debug-toggle-track {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    transition: background 0.2s ease;
    cursor: pointer;
}

.debug-toggle input:checked + .debug-toggle-track {
    background: #34a853;
}

.debug-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.debug-toggle input:checked ~ .debug-toggle-thumb {
    transform: translateX(18px);
}

/* Action bar */
.debug-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom, 10px));
    background: rgba(15, 15, 40, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.debug-action-btn {
    flex: 1;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #ddd;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.debug-action-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.debug-action-btn.save {
    background: rgba(52, 168, 83, 0.25);
    border-color: rgba(52, 168, 83, 0.4);
    color: #7deba3;
}

.debug-action-btn.reset {
    background: rgba(234, 67, 53, 0.2);
    border-color: rgba(234, 67, 53, 0.35);
    color: #f8a09a;
}

/* Floating pill button */
.debug-pill {
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 10px));
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(10, 10, 30, 0.85);
    border: 1px solid rgba(138, 180, 248, 0.4);
    color: #8ab4f8;
    font-size: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9998;
    -webkit-tap-highlight-color: transparent;
}

.debug-pill.visible {
    display: flex;
}

/* Toast notification */
.debug-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 30, 60, 0.95);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.debug-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Import modal */
.debug-import-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.debug-import-modal.open {
    display: flex;
}

.debug-import-content {
    background: rgba(20, 20, 50, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 16px;
    width: 100%;
    max-width: 320px;
}

.debug-import-content h3 {
    font-size: 14px;
    margin: 0 0 10px;
    color: #fff;
}

.debug-import-textarea {
    width: 100%;
    height: 180px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #ddd;
    font-family: monospace;
    font-size: 11px;
    padding: 8px;
    resize: none;
    box-sizing: border-box;
}

.debug-import-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.debug-import-buttons button {
    flex: 1;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #ddd;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.debug-import-buttons .import-confirm {
    background: rgba(52, 168, 83, 0.25);
    border-color: rgba(52, 168, 83, 0.4);
    color: #7deba3;
}
