/* ==========================================================================
   Burf Platform - Unified Stylesheet
   ========================================================================== */

/* ==========================================================================
   Common/Reset Styles
   ========================================================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
}

/* ==========================================================================
   CSS Variables
   ========================================================================== */

:root {
    --bg-dark-primary: #0a0e27;
    --bg-dark-secondary: #1a1f3a;
    --border-dark: #2a3354;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --accent-blue: #4fc3f7;
    --accent-blue-hover: #29b6f6;
    --accent-red: #e53935;
    --accent-green: #4caf50;
    --status-online: #4caf50;
    --status-offline: #f44336;
}

/* ==========================================================================
   Common Header
   ========================================================================== */

header {
    background: #1a1f3a;
    padding: 15px 30px;
    border-bottom: 2px solid #2a3354;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #4fc3f7;
    font-size: 20px;
}

/* ==========================================================================
   Common Buttons
   ========================================================================== */

button {
    background: #4fc3f7;
    color: #0a0e27;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.3s;
}

button:hover {
    background: #29b6f6;
}

.btn-link {
    background: #666;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
}

.btn-link:hover {
    background: #555;
}

/* ==========================================================================
   Status Indicators
   ========================================================================== */

.status-online {
    color: var(--status-online);
}

.status-offline {
    color: var(--status-offline);
}

.connection-status {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
}

/* ==========================================================================
   Login Page
   ========================================================================== */

body.login-page {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.public-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.public-header h1 {
    color: white;
    font-size: 20px;
}

.public-header .btn-link {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.public-header .btn-link:hover {
    background: rgba(255, 255, 255, 0.25);
}

.login-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    color: #1e3c72;
    margin-bottom: 10px;
    text-align: center;
}

.subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #333;
    font-weight: 500;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #2a5298;
}

.login-container button {
    width: 100%;
    padding: 12px;
    background: #2a5298;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.login-container button:hover {
    background: #1e3c72;
}

.error {
    background: #fee;
    color: #c33;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-size: 14px;
}

/* ==========================================================================
   Robots List Page
   ========================================================================== */

body.robots-page {
    background: #0a0e27;
    color: #e0e0e0;
}

.logout-btn {
    background: #e53935;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}

.logout-btn:hover {
    background: #c62828;
}

.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.robots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.robot-card {
    background: #1a1f3a;
    border: 1px solid #2a3354;
    border-radius: 10px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.robot-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(79, 195, 247, 0.3);
}

.robot-id {
    font-size: 18px;
    font-weight: 600;
    color: #4fc3f7;
    margin-bottom: 10px;
}

.robot-info {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 15px;
}

.open-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #4fc3f7;
    color: #0a0e27;
    text-align: center;
    text-decoration: none;
    border-radius: 5px;
    font-weight: 600;
    transition: background 0.3s;
}

.open-btn:hover {
    background: #29b6f6;
}

.no-robots {
    text-align: center;
    color: #aaa;
    font-size: 18px;
    margin-top: 100px;
}

/* ==========================================================================
   Robot Control Pages - Common Styles
   ========================================================================== */

body.robot-page {
    background: #0a0e27;
    color: #e0e0e0;
    overflow-x: hidden;
}

.back-btn {
    background: #666;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}

.robot-badge {
    background: #2a3354;
    color: #4fc3f7;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 14px;
    font-weight: normal;
    margin-left: 10px;
}

.robot-page .container {
    display: grid;
    grid-template-columns: 1fr 600px 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1800px;
    margin: 0 auto;
}

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: #1a1f3a;
    border: 1px solid #2a3354;
    border-radius: 10px;
    padding: 20px;
}

.panel h3 {
    color: #4fc3f7;
    margin-bottom: 15px;
    font-size: 16px;
}

/* Video container */
#video-container {
    position: relative;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 4/3;
}

#webrtc-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Dual video streams (RGB + Depth) */
.center-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.video-streams {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.video-panel {
    position: relative;
}

.video-label {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
}

.depth-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #0f1429;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #2a3354;
}

.depth-display {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.depth-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
    font-size: 13px;
    text-align: center;
}

/* Hide placeholder when depth image loads */
.depth-display[src]:not([src=""]):not([src*="data:image/gif"]) + .depth-placeholder {
    display: none;
}

/* Joystick controls */
.joystick-zone {
    width: 200px;
    height: 200px;
    background: #0f1429;
    border: 2px solid #2a3354;
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
}

.joystick-label {
    text-align: center;
    margin-bottom: 10px;
    color: #aaa;
    font-size: 14px;
}

/* Speech controls */
.speech-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.speech-group input {
    flex: 1;
    padding: 10px;
    background: #0f1429;
    border: 1px solid #2a3354;
    border-radius: 5px;
    color: white;
}

/* Sensor data display */
.sensor-data {
    font-size: 13px;
    line-height: 1.8;
}

.sensor-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #2a3354;
}

.sensor-label {
    color: #aaa;
}

.sensor-value {
    color: #4fc3f7;
    font-weight: 600;
}

/* Pill indicators */
.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.pill-yes {
    background: #4caf50;
    color: white;
}

.pill-no {
    background: #666;
    color: #ccc;
}

.pill-warn {
    background: #ff9800;
    color: white;
}

/* Sensor grids */
.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 5px;
    margin: 5px 0;
}

.sensor-grid-item {
    background: #0f1429;
    padding: 5px;
    border-radius: 5px;
    text-align: center;
    font-size: 11px;
}

.sensor-grid-item.active {
    background: #4caf50;
    color: white;
}

/* Slider controls */
.slider-group {
    margin-bottom: 15px;
}

.slider-group label {
    display: block;
    margin-bottom: 5px;
    color: #ccc;
    font-size: 14px;
}

.slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    background: #2a3354;
    border-radius: 3px;
    outline: none;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4fc3f7;
    border-radius: 50%;
    cursor: pointer;
}

.slider-value {
    display: inline-block;
    min-width: 40px;
    text-align: right;
    color: #4fc3f7;
    font-weight: 600;
}

/* Emotion buttons */
.emotion-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.emotion-btn {
    background: #2a3354;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.emotion-btn:hover {
    background: #3a4364;
}

.emotion-btn:active {
    background: #4fc3f7;
}

/* Control mode toggle */
.control-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1f3a;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid #2a3354;
}

.control-mode-toggle label {
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #4fc3f7;
    transition: 0.3s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #4caf50;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(30px);
}

.gamepad-status {
    font-size: 12px;
    color: #aaa;
    margin-left: 10px;
}

.gamepad-status.connected {
    color: #4caf50;
}

/* Color picker */
.color-picker-group {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
}

input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* Afobot: Control grid buttons */
.control-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 250px;
    margin: 0 auto;
}

.control-grid .control-btn {
    background: #ff9800;
    height: 60px;
    font-size: 18px;
}

.control-grid .control-btn:hover {
    background: #fb8c00;
}

.control-grid .center-btn {
    background: #666;
    font-size: 12px;
}

/* Control button group */
.control-btn-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.control-btn {
    background: #2a3354;
    color: white;
    padding: 40px 30px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.control-btn:hover {
    background: #3a4364;
    transform: translateY(-2px);
}

.control-btn:active {
    background: #4fc3f7;
    transform: translateY(0);
}

.control-btn.active {
    background: #4fc3f7;
    color: #0a0e27;
}

.control-icon {
    font-size: 32px;
}

.info-text {
    color: #aaa;
    font-size: 12px;
    text-align: center;
    margin-top: 10px;
}

/* ROS2 specific: Vector displays */
.sensor-vector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 5px;
}

.vector-item {
    background: #0f1429;
    padding: 5px;
    border-radius: 3px;
    text-align: center;
    font-size: 11px;
}

.vector-label {
    color: #888;
    font-size: 9px;
}

.vector-value {
    color: #4fc3f7;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* ROS2 specific: LiDAR display */
#lidar-canvas {
    width: 100%;
    height: 500px;
    background: #0f1429;
    border-radius: 5px;
    display: block;
}

.lidar-info {
    margin-top: 10px;
    font-size: 11px;
    color: #888;
    text-align: center;
}

/* ==========================================================================
   Alpha/Dev Ribbon
   ========================================================================== */

.alpha-ribbon {
    position: fixed;
    top: 20px;
    right: -35px;
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    color: white;
    padding: 8px 40px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    transform: rotate(45deg);
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    text-transform: uppercase;
}

/* ==========================================================================
   Supported Robots Page
   ========================================================================== */

.page-description {
    color: #aaa;
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 30px;
    max-width: 800px;
}

.header-links {
    display: flex;
    gap: 10px;
}

.robot-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.robot-type-card {
    background: #1a1f3a;
    border: 1px solid #2a3354;
    border-radius: 12px;
    padding: 25px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.robot-type-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(79, 195, 247, 0.2);
}

.robot-type-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.robot-type-header h2 {
    color: #4fc3f7;
    font-size: 20px;
    margin: 0;
}

.robot-type-badge {
    background: #2a3354;
    color: #aaa;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 600;
}

.robot-type-description {
    color: #aaa;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.capabilities-section {
    margin-bottom: 15px;
}

.capabilities-section h4 {
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.capability-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.capability {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.capability.yes {
    background: rgba(76, 175, 80, 0.2);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.capability.no {
    background: rgba(102, 102, 102, 0.2);
    color: #888;
    border: 1px solid rgba(102, 102, 102, 0.3);
}

.capability.partial {
    background: rgba(255, 152, 0, 0.2);
    color: #ff9800;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.info-section {
    background: #1a1f3a;
    border: 1px solid #2a3354;
    border-radius: 12px;
    padding: 25px;
    margin-top: 20px;
}

.info-section h3 {
    color: #4fc3f7;
    margin-bottom: 15px;
}

.info-section p {
    color: #aaa;
    line-height: 1.6;
    margin-bottom: 15px;
}

.info-section ul {
    color: #aaa;
    margin-left: 20px;
    line-height: 1.8;
}

.info-section .link {
    color: #4fc3f7;
    text-decoration: none;
}

.info-section .link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Afobot Head Tilt Controls
   ========================================================================== */

.head-tilt-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 200px;
    margin: 0 auto;
}

.tilt-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ff9800;
    color: #0a0e27;
    padding: 15px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    min-height: 60px;
}

.tilt-btn:hover {
    background: #fb8c00;
    transform: scale(1.02);
}

.tilt-btn:active {
    background: #f57c00;
    transform: scale(0.98);
}

.tilt-btn.center {
    background: #666;
    color: white;
}

.tilt-btn.center:hover {
    background: #555;
}

.tilt-arrow {
    font-size: 24px;
    line-height: 1;
}

.tilt-label {
    font-size: 14px;
    margin-top: 4px;
}

.rotation-controls {
    display: flex;
    gap: 10px;
    max-width: 300px;
    margin: 0 auto;
}

.rotation-controls .tilt-btn {
    flex: 1;
}
