/* Component-Specific Styles */

/* Header Layout Updates */
.header-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 2rem;
}

.header-title {
    grid-column: 2;
    text-align: center;
}

.header-actions {
    grid-column: 3;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-self: end;
}

.help-btn {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.help-btn:hover {
    background: linear-gradient(135deg, #2980b9 0%, #1f618d 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.help-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Help Modal Styles */
.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    animation: modal-fade-in 0.3s ease;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.help-modal-content {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    animation: modal-slide-in 0.3s ease;
}

@keyframes modal-slide-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.help-header {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.help-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 300;
}

.help-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.help-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.help-tabs {
    display: flex;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

.help-tab {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: #7f8c8d;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.help-tab:hover {
    background: #d5dbdb;
    color: #2c3e50;
}

.help-tab.active {
    background: white;
    color: #2c3e50;
    border-bottom-color: #3498db;
}

.help-content {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
    background: white;
}

.help-tab-content {
    display: none;
}

.help-tab-content.active {
    display: block;
    animation: tab-fade-in 0.3s ease;
}

@keyframes tab-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.help-tab-content h3 {
    margin: 0 0 1.5rem 0;
    color: #2c3e50;
    font-size: 1.4rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.help-section {
    margin-bottom: 2rem;
}

.help-section h4 {
    color: #34495e;
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
}

.help-section h5 {
    color: #2c3e50;
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
}

.help-section ul {
    margin: 0.5rem 0 0 1.5rem;
    line-height: 1.6;
}

.help-section li {
    margin-bottom: 0.5rem;
    color: #555;
}

.help-section p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.help-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.help-mode-card {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

.help-mode-card h5 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.help-mode-card ul {
    margin-top: 1rem;
}

.help-shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 5px;
}

.shortcut-item kbd {
    background: #2c3e50;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: monospace;
    min-width: 2rem;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.shortcut-item span {
    flex: 1;
    color: #555;
    font-size: 0.9rem;
}

/* Responsive Design for Help Modal */
@media (max-width: 768px) {
    .header-content {
        grid-template-columns: 1fr;
        gap: 1rem;
        text-align: center;
    }

    .header-title {
        grid-column: 1;
    }

    .header-actions {
        grid-column: 1;
        justify-self: center;
    }

    .help-modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .help-header {
        padding: 1rem;
    }

    .help-header h2 {
        font-size: 1.2rem;
    }

    .help-content {
        padding: 1rem;
        max-height: 70vh;
    }

    .help-modes {
        grid-template-columns: 1fr;
    }

    .help-shortcuts-grid {
        grid-template-columns: 1fr;
    }

    .help-tabs {
        flex-direction: column;
    }

    .help-tab {
        border-bottom: none;
        border-right: 3px solid transparent;
    }

    .help-tab.active {
        border-right-color: #3498db;
        border-bottom-color: transparent;
    }
}

/* Help Highlights */
.help-highlight {
    background: linear-gradient(90deg, rgba(52, 152, 219, 0.1) 0%, rgba(52, 152, 219, 0.05) 100%);
    border-left: 3px solid #3498db;
    padding-left: 1rem;
    border-radius: 5px;
    transition: all 0.3s ease;
}

/* Battery Dashboard */
.battery-dashboard {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.battery-gauge {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.battery-level {
    flex: 1;
    height: 40px;
    background: #ecf0f1;
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    border: 2px solid #bdc3c7;
}

.battery-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 50%, #f39c12 80%, #e74c3c 100%);
    border-radius: 18px;
    transition: width 0.3s ease;
    width: 100%;
    position: relative;
}

.battery-fill::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 60%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    animation: battery-shine 2s ease-in-out infinite alternate;
}

@keyframes battery-shine {
    0% { opacity: 0.3; }
    100% { opacity: 0.8; }
}

#battery-percentage {
    font-weight: 600;
    font-size: 1.1rem;
    color: #2c3e50;
    min-width: 50px;
    text-align: center;
}

.battery-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.battery-info {
    display: flex;
    justify-content: space-between;
    background: #f8f9fa;
    padding: 0.8rem;
    border-radius: 6px;
    border: 1px solid #ecf0f1;
}

.battery-info span {
    font-size: 0.9rem;
    color: #2c3e50;
}

#battery-voltage,
#battery-current {
    font-weight: 600;
    color: #3498db;
}

.cell-voltages h4 {
    margin-bottom: 0.8rem;
    color: #2c3e50;
    font-size: 0.95rem;
}

.cells-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.cell {
    background: #f8f9fa;
    padding: 0.6rem;
    border-radius: 4px;
    border: 1px solid #ecf0f1;
    font-size: 0.8rem;
    color: #2c3e50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.cell span {
    font-weight: 600;
    color: #27ae60;
}

.cell.low-voltage {
    border-color: #e74c3c;
    background: #fdf2f2;
}

.cell.inactive {
    background: #2c3e50;
    border-color: #7f8c8d;
    opacity: 0.6;
}

.cell.inactive span {
    color: #95a5a6;
}

.cell.low-voltage span {
    color: #e74c3c;
}

/* Obstacle Detection */
.obstacle-detection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sensor-group h4 {
    margin-bottom: 0.8rem;
    color: #2c3e50;
    font-size: 0.95rem;
    text-align: center;
}

.sensors-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
}

.sensor {
    background: #f8f9fa;
    border: 2px solid #27ae60;
    border-radius: 6px;
    padding: 0.6rem 0.4rem;
    text-align: center;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.sensor-label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.2rem;
}

.sensor-value {
    font-weight: 600;
    color: #27ae60;
    font-size: 0.8rem;
}

.sensor.warning {
    border-color: #f39c12;
    background: #fef9e7;
}

.sensor.warning .sensor-value {
    color: #f39c12;
}

.sensor.danger {
    border-color: #e74c3c;
    background: #fdf2f2;
    animation: sensor-pulse 1s ease-in-out infinite alternate;
}

.sensor.danger .sensor-value {
    color: #e74c3c;
}

@keyframes sensor-pulse {
    0% { background: #fdf2f2; }
    100% { background: #f8d7da; }
}



/* CAN Traffic Display */
.can-traffic-section {
    display: flex;
    flex-direction: column;
    flex: 1; /* Take all available space in right panel */
    min-height: 0; /* Allow flex item to shrink below content size */
}

.traffic-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.8rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #ecf0f1;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.traffic-controls button {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.traffic-controls select {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    border: 1px solid #ecf0f1;
}

.traffic-controls label {
    font-size: 0.8rem;
    white-space: nowrap;
}

.can-messages {
    flex: 1;
    background: #2c3e50;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.message-header {
    background: #34495e;
    color: white;
    padding: 0.8rem;
    display: grid;
    grid-template-columns: 80px 60px 1fr;
    gap: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid #2c3e50;
}

.messages-list {
    flex: 1;
    overflow-y: auto;
    background: #2c3e50;
    min-height: 0; /* Allow flex item to shrink and grow properly */
}

.can-message {
    display: grid;
    grid-template-columns: 80px 60px 1fr;
    gap: 1rem;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid rgba(52, 73, 94, 0.3);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #ecf0f1;
    transition: background-color 0.1s ease;
}

.can-message:hover {
    background: rgba(52, 152, 219, 0.1);
}

.can-message.raw {
    border-left: 3px solid #95a5a6;
}

.can-message.decoded {
    border-left: 3px solid #2ecc71;
}

.message-time {
    color: #95a5a6;
    font-size: 0.75rem;
}

.message-id {
    color: #3498db;
    font-weight: 600;
}

.message-content {
    color: #ecf0f1;
}

.message-content.decoded {
    color: #2ecc71;
}

.message-content .signal-name {
    color: #f39c12;
    font-weight: 500;
}

.message-content .signal-value {
    color: #e74c3c;
    font-weight: 600;
}

.message-content .signal-unit {
    color: #95a5a6;
    font-style: italic;
}

/* Raw data formatting */
.message-data {
    font-family: 'Courier New', monospace;
    color: #95a5a6;
}

.message-data .byte {
    margin-right: 0.2rem;
}

.message-data .byte:nth-child(2n) {
    margin-right: 0.5rem;
}

/* Error states */
.can-message.error {
    background: rgba(231, 76, 60, 0.1);
    border-left: 3px solid #e74c3c;
}

.can-message.warning {
    background: rgba(243, 156, 18, 0.1);
    border-left: 3px solid #f39c12;
}

/* Message type indicators */
.message-type-control {
    border-left: 3px solid #3498db;
}

.message-type-sensor {
    border-left: 3px solid #2ecc71;
}

.message-type-battery {
    border-left: 3px solid #f39c12;
}

.message-type-light {
    border-left: 3px solid #9b59b6;
}

.message-type-obstacle {
    border-left: 3px solid #e74c3c;
}

/* Scrollbar styling for webkit browsers */
.messages-list::-webkit-scrollbar {
    width: 8px;
}

.messages-list::-webkit-scrollbar-track {
    background: #34495e;
}

.messages-list::-webkit-scrollbar-thumb {
    background: #7f8c8d;
    border-radius: 4px;
}

.messages-list::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}

/* Timeline styling */
#timeline-slider {
    height: 8px;
    background: #ecf0f1;
    border-radius: 4px;
}

#timeline-slider::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3498db;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.timeline-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #3498db 0%, #2980b9 100%);
    border-radius: 4px;
    transition: width 0.1s ease;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.online {
    background: #d5f4e6;
    color: #27ae60;
}

.status-badge.offline {
    background: #fadbd8;
    color: #e74c3c;
}

.status-badge.warning {
    background: #fef9e7;
    color: #f39c12;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .battery-gauge {
        flex-direction: column;
        align-items: stretch;
    }

    .battery-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .cells-grid {
        grid-template-columns: 1fr;
    }

    .sensors-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .traffic-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .traffic-controls label {
        justify-content: center;
    }

    .message-header,
    .can-message {
        grid-template-columns: 70px 60px 1fr;
        gap: 0.5rem;
        font-size: 0.75rem;
    }
}

/* Light Controls - Updated for center panel */
.light-controls, #center-light-controls {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #ecf0f1;
}

.light-controls h4, #center-light-controls h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 0.95rem;
    text-align: center;
}



.light-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.light-group {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.light-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #34495e;
    margin-right: 0.5rem;
    min-width: 90px;
    display: block;
}

.light-btn {
    min-width: 45px;
    height: 32px;
    margin: 0 2px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    border: 2px solid #bdc3c7;
    background: #ecf0f1;
    color: #2c3e50;
    cursor: pointer;
    transition: all 0.2s ease;
}

.light-btn:hover {
    border-color: #95a5a6;
    transform: translateY(-1px);
}

.light-btn.active {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    border-color: #d68910;
    color: white;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.light-group:first-child .light-btn.active {
    background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%);
    border-color: #f1c40f;
    box-shadow: 0 2px 8px rgba(241, 196, 15, 0.3);
}

.light-group:last-child .light-btn.active {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-color: #e74c3c;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

/* Light Status Indicators for Playback Mode */
.light-indicator {
    display: inline-block;
    min-width: 45px;
    height: 32px;
    margin: 0 2px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    border: 2px solid #bdc3c7;
    background: #ecf0f1;
    color: #7f8c8d;
    text-align: center;
    line-height: 20px;
    transition: all 0.2s ease;
}

.light-indicator.on {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    border-color: #d68910;
    color: white;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
}

.light-group:first-child .light-indicator.on {
    background: linear-gradient(135deg, #f1c40f 0%, #f39c12 100%);
    border-color: #f1c40f;
    box-shadow: 0 2px 8px rgba(241, 196, 15, 0.3);
}

.light-group:last-child .light-indicator.on {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    border-color: #e74c3c;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

/* Obstacle Detection - Updated for center panel */
#center-obstacle-detection {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #ecf0f1;
}

#center-obstacle-detection h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 0.95rem;
    text-align: center;
}

.obstacle-sensors {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

#center-obstacle-detection .sensor-group {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: center;
}

#center-obstacle-detection .sensor-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #34495e;
    margin-bottom: 0;
    min-width: 100px;
    flex-shrink: 0;
}

#center-obstacle-detection .sensors-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    flex: 1;
    max-width: 300px;
}
