/*
 * Name: Camera Control 3D Visualizer
 * File: style.css
 * Description: Core styles and layout for Cametric Web App
 * Author: Dayton Taylor
 * Version: 2.0
 * Last Updated: 2025-11-28
 * Copyright (c) 2025 Dayton Taylor, Digital Air Technologies IDE/UID: CH-660.0.061.013-3
 * All rights reserved.
 */

:root {
    --primary-color: #007bff;
    --bg-glass: #ffffff;
    /* Solid white for the mock-up look, or very high opacity */
    --text-color: #333;
    --accent-color: #6610f2;
    --border-color: #ccc;
    --btn-blue: #007bff;
    --btn-green: #28a745;
    --btn-yellow: #ffc107;
    --btn-red: #dc3545;
    --btn-purple: #6610f2;
    --btn-grey: #666666;
}

body {
    margin: 0;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #e0e0e0;
    color: var(--text-color);
}

#canvas-container {
    width: 100vw;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    /* Use flex to help with positioning if absolute fails */
    flex-direction: column;
    justify-content: flex-end;
    /* Push content to bottom */
    align-items: center;
    /* Center horizontally */
}

/* Title Island */
.title-panel {
    position: absolute;
    top: 30px;
    left: 30px;
    background: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 20;
    /* Ensure it stays on top */
}

.logo-title {
    width: 24px;
    height: auto;
    filter: brightness(0.2);
}

.app-title {
    font-weight: 700;
    font-size: 1rem;
    color: #333;
    white-space: nowrap;
}

/* Main Control Panel */
.panel {
    position: relative;
    /* Changed from absolute to relative within the flex container */
    margin-bottom: 30px;
    /* Space from bottom */
    width: 95%;
    max-width: 1200px;
    background: rgba(255, 255, 255, 0.5);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 20px 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    box-sizing: border-box;
    flex-shrink: 0;
    /* Prevent shrinking */
    transition: height 0.4s cubic-bezier(0.25, 1, 0.5, 1), background 0.4s ease, padding 0.4s ease;
    overflow: hidden;
}

.panel.minimized {
    height: 60px;
    padding: 0;
    background: rgba(255, 255, 255, 0.25);
    /* Light grey with double transparency (half of normal 0.5) */
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.panel-toggle {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 3px;
    cursor: pointer;
    z-index: 20;
    transition: background 0.3s;
}

.panel-toggle:hover {
    background: #ffffff;
}

/* Graph Toggle Bar (only visible when panel is minimized) */
.graph-toggle {
    position: absolute;
    bottom: 100px;
    /* 20px above the panel-toggle which is at 80px (30px margin-bottom + 60px panel height - 10px top position) */
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: var(--btn-grey);
    border-radius: 3px;
    cursor: pointer;
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s, background 0.3s;
    /* Prevent text selection on double-click */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.graph-toggle:hover {
    background: #444444;
}

/* Show graph-toggle only when panel is minimized */
.panel.minimized~.graph-toggle {
    pointer-events: auto;
    opacity: 1;
}

.panel.minimized #controls {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#controls {
    opacity: 1;
    transition: opacity 0.4s ease 0.1s;
    /* Delay fade in */
    height: 100%;
}

h1 {
    display: none;
}

#controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr 1.2fr 0.8fr;
    /* Adjusted ratios */
    gap: 20px;
    align-items: start;
}

.col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    /* Allow shrinking if needed */
}

/* Column 1: Files */
.col-1 .upload-btn {
    background: var(--btn-blue);
    color: white;
    border: none;
    padding: 4px;
    margin-top: -4px;
    margin-bottom: -8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.65rem;
    cursor: pointer;
    width: 100%;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-1 .file-label {
    font-size: 0.75rem;
    color: #666;
    margin-top: -3px;
    margin-bottom: -3px;
    padding-left: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Column 2: Action & Settings */
.col-2 .setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.col-2 label {
    font-size: 0.85rem;
    font-weight: 600;
}

.col-2 input {
    width: 60px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: right;
    font-weight: 600;
}

.col-2 select {
    width: 100%;
    padding: 4px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-weight: 500;
    margin-bottom: 5px;
    box-sizing: border-box;
}

/* Column 3: Status & Playback */
.col-3 {
    background: #f0f0f0;
    padding: 10px;
    border-radius: 8px;
}

.status-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.8rem;
    color: #333;
    margin-bottom: -10px;
}

.status-display div {
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    white-space: nowrap;
}

.playback-controls button {
    flex: 1;
    padding: 2px;
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    cursor: pointer;
}

/* State Controls (Save/Load/Reset) */
.state-controls {
    display: flex;
    gap: 8px;
}

.state-btn {
    flex: 1;
    padding: 4px 2px;
    border: none;
    border-radius: 4px;
    background: #c5c5c5;
    color: white;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
}

.state-btn:hover {
    background: #a0a0a0;
}

.state-btn:active {
    background: #808080;
}

#btn-play {
    background: var(--btn-green);
}

#btn-pause {
    background: var(--btn-yellow);
    color: #FFF;
}

#btn-reset {
    background: var(--btn-red);
}

/* Column 4: Arc, FPS, View */
.col-4 .setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.col-4 label {
    font-size: 0.85rem;
    font-weight: 600;
}

.col-4 input {
    width: 60px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: right;
    font-weight: 600;
}

#playback-fps.world-view-120 {
    color: #ff0000;
    /* Red text for 120fps in world view */
}

/* Column 4 button row */
.button-row {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    align-items: stretch;
    /* Ensure equal heights */
}

.square-btn {
    flex: 0 0 auto;
    width: 36px;
    /* Square width to match height */
    padding: 6px 0;
    /* Match btn-toggle-view padding */
    background: #e0e0e0;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    line-height: 1;
    transition: background 0.2s, color 0.2s;
}

.square-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Reversed direction state */
.square-btn.reversed {
    background: #222;
    color: #fff;
    border-color: #222;
}

#btn-toggle-view {
    flex: 1;
    color: white;
    border: none;
    background: var(--btn-purple);
    padding: 6px;
    /* Original padding restored */
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}

#btn-toggle-view:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Column 5: Branding */
.col-5 {
    position: relative;
    align-items: center;
    text-align: center;
    justify-content: center;
    height: 100%;
    gap: 0;
}

.logo-brand {
    width: 130px;
    /* Constrained width */
    height: auto;
    margin: 0;
    padding: 0;
    display: block;
    position: relative;
    top: -10%;
}

.brand-text {
    position: absolute;
    top: 80%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    z-index: 10;
}

.brand-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: #333;
}

.company-name {
    font-size: 0.7rem;
    color: #666;
}

.company-url {
    font-size: 0.6rem;
    color: var(--primary-color);
    text-decoration: none;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    width: 100%;
    gap: 10px;
}

.setting-row label {
    font-size: 0.8rem;
    color: #333;
    text-transform: none;
    margin-bottom: 0;
    font-weight: 600;
    letter-spacing: 0;
}

.setting-row input {
    width: 60px;
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    padding: 4px 8px;
    border-radius: 6px;
    text-align: right;
    font-weight: 500;
    font-family: 'Inter', monospace;
    font-size: 0.8rem;
}

.setting-row input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.upload-btn {
    width: 100%;
    background: #fff;
    border: 1px solid #ddd;
    color: #333;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.8rem;
    white-space: nowrap;
    text-align: center;
}

.upload-btn:hover {
    background: #f8f9fa;
    border-color: #ccc;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.file-label.external {
    color: var(--btn-blue);
    /* Blue when external file is loaded */
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 0;
    padding: 0 20px;
    border-right: 1px solid #e0e0e0;
    min-width: 140px;
    justify-content: flex-start;
}

.control-group:first-child {
    padding-left: 0;
}

.control-group:last-child {
    border-right: none;
    padding-right: 0;
}

.control-group label {
    font-size: 0.7rem;
    color: #888;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
}

select {
    width: 100%;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

button {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.8rem;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.status-display span {
    color: #000;
    font-weight: 600;
}

.status-display span:first-child {
    font-weight: 700;
    color: #333;
}

.status-display span:last-child {
    font-weight: 500;
    color: #000;
}

/* Specific adjustments for the horizontal layout groups */
.group-files {
    flex: 0 0 200px;
}

.group-action {
    flex: 0 0 120px;
}

.group-settings {
    flex: 0 0 180px;
}

.group-playback {
    flex: 0 0 220px;
}

.upload-row button {
    flex: 1;
    padding: 4px;
    font-size: 0.65rem;
    white-space: nowrap;
    text-transform: capitalize;
    /* First letter caps */
}

.file-label {
    font-size: 0.65rem;
    color: #666;
    margin-bottom: 0px;
    /* Reduced spacing */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 2px;
}

.toggle-btn {
    margin-top: 0px;
    /* Reduced padding above */
    background: var(--btn-grey);
    color: white;
    width: 100%;
    font-size: 0.85rem;
    padding: 8px;
    text-transform: none;
    border: none;
}

.toggle-btn:hover {
    opacity: 0.9;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.playback-controls button {
    padding: 4px 2px;
    font-size: 1rem;
    flex: 1;
}

.step-btn {
    flex: 0 0 24px !important;
    /* Fixed width for step buttons */
    padding: 4px 4px !important;
    font-size: 1rem !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    /* Added background */
    border: 1px solid #ccc;
    border-radius: 4px;
}

.step-btn:hover {
    background: #d0d0d0;
}

/* Graphs */
/* Graphs Wrapper - constrains all three graphs as a group */
#graphs-wrapper {
    position: absolute;
    bottom: 230px;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    max-width: 1200px;
    /* Match control panel */
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 100;
    transition: bottom 0.4s ease;
}

#graphs-wrapper.panel-minimized {
    bottom: 120px;
}

.graph-overlay {
    position: relative;
    /* Changed from absolute to relative within wrapper */
    width: 31%;
    /* Divide space into thirds with small gaps */
    aspect-ratio: 2.35 / 1;
    /* Fixed 2.35:1 aspect ratio */
    background: rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    border-radius: 15px;
    /* Tripled from 5px to 15px */
    padding: 5px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    /* Let clicks pass through to 3D view */
    opacity: 1;
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

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

@keyframes blink-red {

    0%,
    49.9% {
        border-color: red;
    }

    50%,
    100% {
        border-color: transparent;
    }
}

.flash-border {
    border: 2px solid red;
    animation: blink-red 1s linear infinite;
}

/* Individual graph positioning removed - now handled by wrapper flexbox */

.upload-row {
    display: flex;
    gap: 5px;
    margin-top: 4px;
    margin-bottom: 5px;
}

.upload-row button {
    flex: 1;
    padding: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
}

/* Preset button row */
.preset-row {
    display: flex;
    gap: 4px;
    margin-top: 1px;
    margin-bottom: 1px;
}

.preset-btn {
    width: 4px;
    height: 8px;
    /* Doubled from 4px to 8px */
    padding: 0;
    border: none;
    background: #ffffff;
    /* White by default (default files loaded) */
    cursor: pointer;
    flex-shrink: 0;
}

.preset-btn:hover {
    opacity: 0.7;
}

.preset-btn.pending {
    background: var(--btn-yellow);
    /* Yellow when waiting for loop to complete */
}

.preset-btn.loaded {
    background: var(--btn-blue);
    /* Blue when loaded */
}

.graph-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #CCC;
    margin-bottom: 0px;
    text-align: center;
}

.graph-overlay canvas {
    width: 100%;
    height: 100%;
    flex-grow: 1;
}

/* Camera Frame Overlay (16:9 aspect ratio) */
#camera-frame-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 0, 0, 1.0);
    pointer-events: none;
    z-index: 5;
    display: none;
    /* Hidden by default, shown in camera view */
    box-sizing: border-box;
}

/* View mode label - appears above the camera frame */
#view-mode-label {
    position: absolute;
    pointer-events: none;
    z-index: 6;
    /* Above the frame */
    color: rgba(255, 0, 0, 1.0);
    /* Same red as frame */
    font-size: 14px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.5px;
    display: none;
    /* Controlled by JS */
}

/* Camera number label - appears above the camera frame */
#camera-number-label {
    position: absolute;
    pointer-events: none;
    z-index: 6;
    /* Above the frame */
    color: rgba(255, 0, 0, 1.0);
    /* Same red as frame */
    font-size: 14px;
    font-weight: 400;
    /* Normal weight for monospace */
    font-family: 'Courier New', Courier, 'Lucida Console', Monaco, monospace;
    display: none;
    /* Controlled by JS */
    text-align: right;
}

/* Mask overlay - semi-transparent white outside the camera frame */
#camera-frame-overlay-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 4;
    /* Below the frame border but above the 3D scene */
    display: none;
    /* Hidden by default, shown in camera view */
    background: rgba(255, 255, 255, 0.3);
    /* The clip-path will be set dynamically via JavaScript to create the cutout */
}

/* Arc Info Overlay - shows camera distance and arc length in World View */
#arc-info-overlay {
    position: absolute;
    /* right and bottom are set dynamically by JavaScript */
    pointer-events: none;
    z-index: 6;
    color: #000000;
    /* Black text */
    font-size: 14px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0.5px;
    display: none;
    /* Hidden by default, shown in World View via JS */
    text-align: right;
    line-height: 1.6;
    transition: right 0.4s ease, bottom 0.4s ease;
    /* Smooth repositioning */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}