/* Modal Studio CSS - Matching C++ Button Colors and Design */
/* Based on Button.hpp and ofApp.h color definitions */

:root {
    /* Background colors from ofApp.h */
    --dark-background: rgb(26, 25, 24);
    --light-background: rgb(245, 245, 245);
    
    /* Button colors from Button.hpp */
    --button-not-clicked: rgb(250, 250, 250);
    --button-hover: rgb(220, 220, 220);
    --button-clicked: rgb(255, 180, 0);
    --button-border: rgba(211, 211, 211, 0.8);
    --button-text: rgb(40, 40, 40);
    
    /* Text colors from ofApp.h */
    --text-light: rgb(255, 255, 255);
    --text-dark: rgb(10, 10, 10);
    
    /* Button dimensions */
    --button-rounded: 5px;
    --button-border-width: 1px;
}

/* Body and Canvas */
body.scene-modalstudio {
    margin: 0;
    padding: 0;
    overflow: auto;
    min-width: 100vw;
    max-width: 100vw;
    min-height: 990px;
    font-family: 'Source Code Pro', 'Fira Code', 'Monaco', monospace;
    background: rgb(0, 0, 0);
    color: white;
}

/* Modal Studio app container - create stacking context above EigenSpace */
#modalstudio-app {
    position: relative;
    z-index: 1000;
}

#canvas-container {
    margin: 0;
    padding: 0;
    position: relative;
    z-index: 100;
}

body.scene-modalstudio canvas {
    display: block;
    position: relative;
    z-index: 100;
}

/* Audio GUI Container */
#audio-gui-container,
#modalstudio-audio-gui {
    position: fixed;
    bottom: 10px;
    left: 10px;
    width: 320px;
    height: 250px;
    z-index: 1000;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

/* Standard Button Styling */
body.scene-modalstudio button {
    background-color: var(--button-not-clicked);
    color: var(--button-text);
    border: var(--button-border-width) solid var(--button-border);
    border-radius: var(--button-rounded);
    padding: 8px 16px;
    font-family: 'Source Code Pro', 'Fira Code', 'Monaco', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
    margin: 2px;
}

body.scene-modalstudio button:hover {
    background-color: var(--button-hover);
}

/* Hide EigenSpace buttons when in Modal Studio scene */
body.scene-modalstudio #viz-mode-toggle,
body.scene-modalstudio #nav-to-modalstudio {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Scene Controls */
#scene-controls {
    position: fixed;
    top: 5px;
    right: 5px;
    z-index: 9999;
    display: flex;
    gap: 1px;
}

body.scene-modalstudio .scene-button {
    background: rgba(0, 111, 229, 0.8) !important;
    border: none !important;
    color: white !important;
    padding: 7px 20px;
    font-size: 12px;
    font-family: 'Source Code Pro', monospace;
    font-weight: normal;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1;
    margin: 0 !important;
}

body.scene-modalstudio .scene-button:hover {
    background: rgba(0, 111, 229, 1) !important;
}

body.scene-modalstudio .scene-button.active {
    background: rgba(0, 111, 229, 1) !important;
    font-weight: 600;
}

button:active,
button.active {
    background-color: var(--button-clicked);
    border-color: var(--button-border);
}

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

/* Primary buttons (highlighted actions) */
button.primary {
    background-color: var(--button-clicked);
    color: var(--text-dark);
}

button.primary:hover {
    background-color: rgb(255, 195, 40);
}

button.primary:active {
    background-color: rgb(255, 165, 0);
}

/* Secondary buttons (less prominent) */
button.secondary {
    background-color: transparent;
    border: var(--button-border-width) solid var(--button-border);
}

button.secondary:hover {
    background-color: rgba(80, 80, 80, 0.1);
}

/* Small buttons */
button.small {
    padding: 4px 8px;
    font-size: 10px;
}

/* Large buttons */
button.large {
    padding: 12px 24px;
    font-size: 14px;
}

/* Button groups */
.button-group {
    display: inline-flex;
    gap: 0;
    margin: 4px;
}

.button-group button {
    margin: 0;
    border-radius: 0;
}

.button-group button:first-child {
    border-top-left-radius: var(--button-rounded);
    border-bottom-left-radius: var(--button-rounded);
}

.button-group button:last-child {
    border-top-right-radius: var(--button-rounded);
    border-bottom-right-radius: var(--button-rounded);
}

.button-group button:not(:last-child) {
    border-right: none;
}

/* Input fields matching button style */
input[type="text"],
input[type="number"],
input[type="range"],
select {
    background-color: var(--button-not-clicked);
    color: var(--button-text);
    border: var(--button-border-width) solid var(--button-border);
    border-radius: var(--button-rounded);
    padding: 6px 12px;
    font-family: 'Source Code Pro', 'Fira Code', 'Monaco', monospace;
    font-size: 12px;
    outline: none;
    margin: 4px;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    border-color: var(--button-clicked);
    background-color: white;
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--button-border);
    border: none;
    padding: 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--button-clicked);
    cursor: pointer;
    border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--button-clicked);
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

/* Labels */
label {
    font-family: 'Source Code Pro', 'Fira Code', 'Monaco', monospace;
    font-size: 12px;
    color: var(--button-text);
    margin: 4px;
}

/* Control panels */
.control-panel {
    position: absolute;
    background-color: rgba(250, 250, 250, 0.95);
    border: var(--button-border-width) solid var(--button-border);
    border-radius: var(--button-rounded);
    padding: 12px;
    box-shadow: 0 2px 2px rgba(0, 0, 0, 0.15);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: var(--dark-background);
        --text-color: var(--text-light);
    }
    
    body {
        background-color: var(--dark-background);
    }
    
    .control-panel {
        background-color: rgba(26, 25, 24, 0.95);
    }
    
    label {
        color: var(--text-light);
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

.flex-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.flex-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

/* Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(40, 40, 40, 0.95);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    pointer-events: none;
    margin-bottom: 4px;
}

/* ============================================================================
   MIDI PANEL STYLES
   ============================================================================ */

.midi-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 400px;
    background: rgba(23, 23, 23, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    z-index: 9998;
    opacity: 0;
    font-weight: normal;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    font-family: 'Source Code Pro', monospace;
}

.midi-panel.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.midi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.midi-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(250, 250, 250, 1);
    letter-spacing: 0.5px;
}

.midi-close-btn {
    background: transparent;
    border: 1px solid rgba(150, 150, 150, 0.3);
    color: rgba(150, 150, 150, 1);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.midi-close-btn:hover {
    border-color: rgba(255, 255, 255, 0.6);
    color: rgba(255, 255, 255, 1);
    background: rgba(255, 255, 255, 0.05);
}

.midi-content {
    padding: 20px;
}

.midi-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(150, 150, 150, 0.5);
    box-shadow: 0 0 8px rgba(150, 150, 150, 0.3);
    transition: all 0.3s ease;
}

.status-indicator.connected {
    background: rgba(0, 255, 100, 1);
    box-shadow: 0 0 12px rgba(0, 255, 100, 0.6);
    animation: pulse 2s ease-in-out infinite;
}

#status-text {
    color: rgba(250, 250, 250, 1);
    flex: 1;
}

.midi-piano-section {
    margin-top: 16px;
    margin-bottom: 12px;
    width: 100%;
    display: flex;
    justify-content: center;
}

body.scene-modalstudio .midi-piano-btn {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    background: rgb(11, 174, 17);
    color: white;
    border: none;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Source Code Pro', monospace;
}

body.scene-modalstudio .midi-piano-btn:hover {
    background: rgb(24, 185, 29);
}

body.scene-modalstudio .midi-piano-btn.disabled {
    background: rgba(158, 158, 158, 0.8);
}

body.scene-modalstudio .midi-piano-btn.disabled:hover {
    background: rgba(158, 158, 158, 1);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.midi-device-section {
    margin-bottom: 20px;
}

.midi-device-section label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    color: rgba(200, 200, 200, 1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.custom-dropdown {
    position: relative;
    width: 100%;
    cursor: pointer;
    user-select: none;
    border-radius: 8px;
}

.dropdown-selected {
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px !important;
    color: rgba(250, 250, 250, 1);
    font-family: 'Source Code Pro', monospace;
    font-size: 13px;
    transition: all 0.2s ease;
}

.dropdown-selected:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.7);
}

.dropdown-options {
    position: absolute;
    border-radius: 8px;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}

.dropdown-option {
    padding: 10px 12px;
    border-radius: 8px;
    color: rgba(250, 250, 250, 1);
    font-family: 'Source Code Pro', monospace;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-option:hover {
    background: rgba(0, 128, 255, 0.779);
}

.dropdown-option:last-child {
    border-bottom: none;
}

.device-selector-row {
    display: flex;
    gap: 5px;
    align-items: stretch;
}

.midi-device-container {
    flex: 1;
}

body.scene-modalstudio .midi-refresh-btn {
    background: rgb(20, 20, 20);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-top: 4px;
    color: rgba(250, 250, 250, 1);
    font-size: 25px;
    width: 33px;
    height: 33px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

body.scene-modalstudio .midi-refresh-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.7);
}

.midi-info {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 12px;
    color: rgba(200, 200, 200, 1);
}

.info-row:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.info-value {
    color: rgba(5, 213, 255, 1);
    font-weight: 600;
}

body.scene-modalstudio .midi-panic-btn {
    width: 100%;
    padding: 10px;
    background: rgb(255, 170, 0);
    border: none;
    color: rgb(38, 38, 38);
    font-family: 'Source Code Pro', monospace;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body.scene-modalstudio .midi-panic-btn:hover {
    background: rgb(255, 200, 0);
}

body.scene-modalstudio .midi-panic-btn:active {
    background: rgb(255, 50, 3);
    color: rgb(211, 211, 211);
    transform: scale(0.99);
}

/* Modal Studio MIDI button - match EigenSpace styling */
#modalstudio-midi-toggle {
    background: rgba(0, 111, 229, 0.8);
    transition: all 0.2s ease;
}

#modalstudio-midi-toggle:hover {
    background: rgba(0, 111, 229, 1);
}

#modalstudio-midi-toggle .midi-icon {
    font-size: 12px;
    line-height: 1;
}

/* Modal Studio Info button - match EigenSpace styling */
#modalstudio-info-button {
    background: rgba(0, 111, 229, 0.8);
    border: none;
    color: white;
    padding: 7px 20px;
    font-size: 12px;
    font-family: 'Source Code Pro', monospace;
    font-weight: normal;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease;
    line-height: 1;
}

#modalstudio-info-button:hover {
    background: rgba(0, 111, 229, 1);
}

#modalstudio-info-button .info-icon {
    font-size: 14px;
    line-height: 1;
}

/* Modal Studio Info Overlay */
#modalstudio-info-overlay.info-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
}

#modalstudio-info-overlay .info-panel {
    background: rgb(255, 250, 240);
    border-radius: 10px;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 40px;
    margin: 20px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    scrollbar-color: rgba(209, 209, 209, 0.8) rgba(240, 240, 240, 0.0) !important;
}

#modalstudio-info-overlay .header-section {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: none;
    padding-bottom: 20px;
}

#modalstudio-info-overlay .main-title {
    font-size: 30px;
    font-weight: 600;
    margin: 0 0 5px 0;
    color: rgba(16, 16, 16, 1);
}

#modalstudio-info-overlay .subtitle {
    font-size: 15px;
    color: rgba(16, 16, 16, 1);
    font-weight: 600;
    letter-spacing: 1px;
}

#modalstudio-info-overlay .content-section {
    line-height: 1.6;
}

#modalstudio-info-overlay .section {
    margin-bottom: 25px;
}

#modalstudio-info-overlay h3 {
    font-size: 16px;
    color: rgba(16, 16, 16, 1);
    margin: 20px 0 10px 0;
    font-weight: 600;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#modalstudio-info-overlay p {
    margin: 10px 0;
    color: rgba(16, 16, 16, 1);
    font-size: 14px;
    line-height: 1.8;
}

#modalstudio-info-overlay ul {
    margin: 10px 0;
    padding-left: 30px;
    color: rgba(16, 16, 16, 1);
}

#modalstudio-info-overlay li {
    margin: 5px 0;
}

#modalstudio-info-overlay .modal-image {
    margin: 20px 0;
    text-align: center;
}

#modalstudio-info-overlay .modal-image img {
    max-width: 80%;
    border-radius: 10px;
    box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
}

#modalstudio-info-overlay .image-caption {
    margin-top: 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
}

#modalstudio-info-overlay .paper-link {
    color: rgba(0, 111, 229, 1);
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 111, 229, 0.3);
    transition: all 0.2s ease;
}

#modalstudio-info-overlay .paper-link:hover {
    border-bottom-color: rgba(0, 111, 229, 1);
}

#modalstudio-info-overlay strong {
    color: rgba(0, 0, 0, 1);
    font-weight: 500;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#modalstudio-info-overlay .close-button {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    color: rgba(16, 16, 16, 1);
    font-size: 32px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

#modalstudio-info-overlay .close-button:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: rotate(90deg);
}

/* Citation section styling */
#modalstudio-info-overlay .citation-section {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 20px;
    margin-top: 10px;
}

#modalstudio-info-overlay .citation-text {
    font-family: 'Georgia', serif;
    font-style: italic;
    font-size: 14px;
    line-height: 1.6;
    color: rgba(16, 16, 16, 0.9);
    background: rgba(0, 0, 0, 0.05);
    padding: 15px;
    border-radius: 5px;
    border-left: 3px solid rgba(0, 111, 229, 1);
}
