/* ============================================================
   REGROOVE AUDIO TOOLS - SHARED STYLES
   ============================================================ */

/* CSS Variables */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #2a2a2a;
    --accent: #CF1A37;
    --accent-dim: #a01528;
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --border: #333333;
    --shadow: rgba(207, 26, 55, 0.3);
}

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

/* Body */
body {
    font-family: Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0;
    min-height: 100vh;
}

/* Top Banner */
.top-banner {
    background: var(--accent);
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.hamburger-button {
    background: none;
    border: none;
    color: white !important;
    font-size: 1.8em;
    cursor: pointer;
    padding: 5px 10px;
    transition: opacity 0.2s;
    line-height: 1;
    width: auto !important;
}

.hamburger-button:hover {
    opacity: 0.8;
}

.hamburger-button:active,
.hamburger-button:focus {
    background: none !important;
    outline: none;
}

.banner-title {
    font-size: 1.1em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-primary);
    line-height: 1;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.section-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 768px) {
    .section-row {
        grid-template-columns: 1fr;
    }
}

/* Section Styles */
.section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
}

.section-title {
    color: #0066FF;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title:hover {
    color: #3388FF;
}

.section-title .toggle {
    font-size: 14px;
    transition: transform 0.2s;
}

.section-title.collapsed .toggle {
    transform: rotate(-90deg);
}

.section-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Common Controls */
button, select, input[type="number"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-family: Arial, sans-serif;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

button:hover, select:hover {
    border-color: #4a4a4a;
    background: #3a3a3a;
}

button:active:not(.hamburger-button) {
    background: #0066FF;
    color: var(--text-primary);
}

button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

button:disabled:hover {
    border-color: var(--border);
    background: var(--bg-tertiary);
}

button.connected {
    background: #00AA00;
    border-color: #00FF00;
}

select {
    width: 100%;
}

input[type="number"] {
    width: 70px;
    text-transform: none;
}

.midi-controls {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.status {
    display: flex;
    gap: 20px;
    font-size: 12px;
    margin-top: 15px;
}

.status-item {
    color: #666;
}

.status-item span {
    color: #0066FF;
    font-weight: bold;
}

.status-item.connected span {
    color: #00FF00;
}

.controller-visual {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s;
    width: 100%;
}

.controller-visual:hover {
    border-color: #CF1A37;
}

.controller-visual:fullscreen {
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 0;
    width: 100vw;
    height: 100vh;
    gap: 10px;
    flex-wrap: wrap;
}

/* Landscape: joysticks on the right */
@media (orientation: landscape) {
    .controller-visual:fullscreen {
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .controller-visual:fullscreen .button-grid,
    .controller-visual:fullscreen .trigger-pads-grid {
        width: min(65vw, calc(85vh - 90px));
        height: min(65vw, calc(85vh - 90px));
        flex-shrink: 0;
    }

    .controller-visual:fullscreen .axis-display {
        display: flex;
        flex-direction: column;
        width: auto;
        height: min(65vw, calc(85vh - 90px));
        flex: 1;
        max-width: 33vw;
        gap: 10px;
    }

    .controller-visual:fullscreen .axis-item {
        flex: 1;
    }
}

/* Portrait: joysticks below */
@media (orientation: portrait) {
    .controller-visual:fullscreen {
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .controller-visual:fullscreen .button-grid,
    .controller-visual:fullscreen .trigger-pads-grid {
        width: min(95vw, calc(62vh - 90px));
        height: min(95vw, calc(62vh - 90px));
        flex-shrink: 0;
    }

    .controller-visual:fullscreen .axis-display {
        display: flex;
        flex-direction: row;
        width: min(95vw, calc(62vh - 90px));
        flex: 1;
        max-height: calc(32vh - 90px);
    }

    .controller-visual:fullscreen .axis-item {
        flex: 1;
    }
}

.controller-visual::after {
    content: '⛶ ';
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 12px;
    color: #666;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.7);
    padding: 3px 6px;
    border-radius: 2px;
    z-index: 10;
}

.controller-visual:hover::after {
    opacity: 1;
    color: #CF1A37;
}

.controller-visual:fullscreen::after {
    content: '✕';
    display: block;
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    color: var(--text-primary);
    opacity: 0.6;
    transition: opacity 0.2s, color 0.2s;
    pointer-events: auto;
    background: rgba(207, 26, 55, 0.8);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    font-weight: bold;
}

.controller-visual:fullscreen::after:hover {
    opacity: 1;
    background: rgba(207, 26, 55, 1);
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
}

.controller-button {
    aspect-ratio: 1;
    background: var(--bg-tertiary);
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    text-transform: uppercase;
    transition: all 0.1s;
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

.controller-button:hover {
    border-color: #0066FF;
}

.controller-button.active {
    background: #CF1A37;
    border-color: #ff3333;
    transform: scale(0.95);
}

.controller-button .label {
    font-weight: bold;
    margin-bottom: 3px;
}

.controller-button .value {
    font-size: 9px;
    color: #666;
}

.axis-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
}

.axis-item {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 4px;
    padding: 15px;
    position: relative;
}

.axis-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #0066FF;
    margin-bottom: 8px;
}

.axis-value {
    font-size: 14px;
    font-weight: bold;
    font-family: monospace;
    color: var(--text-primary);
}

.joystick-pad {
    width: 150px;
    height: 150px;
    background: var(--bg-primary);
    border: 2px solid #3a3a3a;
    border-radius: 8px;
    position: relative;
    margin: 10px auto;
    cursor: crosshair;
    touch-action: none;
}

.joystick-stick {
    width: 30px;
    height: 30px;
    background: #CF1A37;
    border: 2px solid #ff3333;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: background 0.1s;
}

.joystick-pad:hover .joystick-stick {
    background: #ff3333;
}

.joystick-pad.active .joystick-stick {
    background: #0066FF;
    border-color: #3388FF;
}

.mapping-config {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 12px;
}

.mapping-label {
    color: var(--text-secondary);
    font-weight: bold;
}

input[type="number"] {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid #3a3a3a;
    padding: 5px;
    border-radius: 4px;
    width: 70px;
    font-size: 12px;
}

.info {
    font-size: 11px;
    color: #666;
    margin-top: 10px;
    line-height: 1.5;
}

.channel-select {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.channel-select label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.channel-select select {
    width: 100%;
}

.device-select {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.device-select label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.preset-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.preset-button {
    flex: 1;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    text-align: center;
    transition: all 0.2s;
}

.preset-button:hover {
    border-color: #0066FF;
}

.preset-button.active {
    background: #0066FF;
    border-color: #3388FF;
}

/* Device Manager Styles */
.device-card {
    background: var(--bg-primary);
    border: 1px solid var(--bg-tertiary);
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.device-header {
    margin-bottom: 10px;
}

.device-enable {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.device-enable input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
}

.device-name {
    font-size: 14px;
    font-weight: bold;
    color: var(--text-primary);
}

.device-config {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--bg-tertiary);
}

.device-config.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.device-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 10px;
    align-items: center;
}

.device-row label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.device-row select {
    width: 100%;
}

.trigger-device-selector {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-primary);
    border: 2px solid #0066FF;
    border-radius: 4px;
}

.section-subtitle {
    font-size: 12px;
    color: #0066FF;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    font-weight: bold;
}

.trigger-device-selector select {
    width: 100%;
    margin-bottom: 10px;
}

/* Trigger Pads Configuration */
.trigger-config-panel {
    background: var(--bg-primary);
    border: 2px solid #0066FF;
    border-radius: 4px;
    padding: 15px;
    margin-top: 10px;
    width: 100%;
    flex-shrink: 0;
}

/* In fullscreen mode, position controls at bottom */
.controller-visual:fullscreen .trigger-config-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(10px);
    z-index: 100;
    padding: 10px 15px;
}

.trigger-config-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
}

/* Normal view: side by side when space allows */
.controller-visual:not(:fullscreen) .trigger-config-row {
    flex-wrap: nowrap;
}

@media (max-width: 600px) {
    .controller-visual:not(:fullscreen) .trigger-config-row {
        flex-wrap: wrap;
    }
}

/* Fullscreen: always side by side */
.controller-visual:fullscreen .trigger-config-row {
    flex-wrap: nowrap;
    justify-content: center;
}

.trigger-config-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 150px;
}

.trigger-config-item label {
    font-size: 11px;
    color: #0066FF;
    text-transform: uppercase;
    font-weight: bold;
}

.trigger-config-item select {
    width: 100%;
}

/* Scene System */
.scene {
    display: none;
}

.scene.active {
    display: block;
}

/* Navigation Menu */
.menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.menu-overlay.active {
    display: block;
}

.menu-panel {
    position: fixed;
    top: 0;
    left: -100%;
    width: 300px;
    height: 100vh;
    background: var(--bg-secondary);
    z-index: 1000;
    transition: left 0.3s ease;
    padding: 20px;
}

.menu-panel.active,
.menu-panel.open {
    left: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
}

.menu-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
    padding: 5px 10px;
    border-radius: 4px;
}

.menu-close:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.menu-items {
    margin-top: 60px;
}

.nav-item {
    display: block;
    width: 100%;
    padding: 15px 20px;
    margin-bottom: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    border-radius: 5px;
    transition: background 0.2s;
}

.nav-item:hover {
    background: #3a3a3a;
}

.nav-item.active {
    background: #0066FF;
    color: white;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 15px 20px;
    margin-bottom: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1em;
    cursor: pointer;
    text-align: left;
    border-radius: 5px;
    transition: background 0.2s;
    text-transform: none;
    letter-spacing: normal;
}

.menu-item:hover {
    background: #3a3a3a;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1001;
}

.modal-overlay.active {
    display: block;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1002;
}

.modal.active {
    display: block;
}

.modal-header {
    background: var(--accent);
    padding: 15px 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.3em;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin: 0;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-body h3 {
    margin: 0 0 5px 0;
    color: var(--accent);
    font-size: 1.5em;
}

.modal-body p {
    margin: 10px 0;
    line-height: 1.6;
    color: var(--text-secondary);
}

