/* Common styles */
* {
    box-sizing: border-box;
}

/* Main page styles */
.main-page body {
    font-family: Arial, sans-serif;
    padding: 20px;
    background-color: #f0f0f0;
    margin: 0;
}

.main-page .container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.main-page button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    margin: 10px 5px;
}

.main-page button:hover {
    background-color: #0056b3;
}

.main-page .log-section {
    margin-top: 20px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    background-color: #f8f9fa;
}

.main-page .log-header {
    padding: 12px 15px;
    background-color: #e9ecef;
    border-bottom: 1px solid #dee2e6;
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    transition: background-color 0.2s;
}

.main-page .log-header:hover {
    background-color: #dee2e6;
}

.main-page .toggle-icon {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.main-page .toggle-icon.expanded {
    transform: rotate(180deg);
}

.main-page .log {
    background-color: #f8f9fa;
    padding: 15px;
    font-family: monospace;
    font-size: 12px;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.main-page .log.collapsed {
    max-height: 0;
    padding: 0 15px;
    overflow: hidden;
}

.main-page .status {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
}

.main-page .success { 
    background-color: #d4edda; 
    color: #155724; 
}

.main-page .warning { 
    background-color: #fff3cd; 
    color: #856404; 
}

.main-page .error { 
    background-color: #f8d7da; 
    color: #721c24; 
}

/* Sub page styles */
.sub-page body {
    font-family: Arial, sans-serif;
    padding: 20px;
    background: #2c3e50;
    color: white;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.sub-page .container {
    text-align: center;
    background: rgba(255,255,255,0.1);
    padding: 50px;
    border-radius: 10px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    width: 100%;
    max-width: none;
}

.sub-page h1 {
    font-size: 3em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.sub-page .info {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    font-family: monospace;
    font-size: 14px;
    text-align: left;
}

.sub-page button {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    margin: 10px;
    font-size: 16px;
}

.sub-page button:hover {
    background: rgba(255,255,255,0.3);
}

/* Sub-page system data styles */
.sub-page .systems-section {
    margin-top: 10px;
    width: 100%;
}

.sub-page .system-controls {
    background-color: rgba(255,255,255,0.1);
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.sub-page .system-controls h2 {
    margin: 0 0 15px 0;
    color: white;
    font-size: 1.5em;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.sub-page .connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.sub-page .status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.sub-page .status-indicator.connected {
    background-color: #28a745;
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.6);
}

.sub-page .status-indicator.disconnected {
    background-color: #6c757d;
}

.sub-page .status-indicator.error {
    background-color: #dc3545;
    box-shadow: 0 0 6px rgba(220, 53, 69, 0.6);
}

.sub-page .status-text {
    color: rgba(255,255,255,0.9);
}

.sub-page .system-data {
    padding: 0;
    position: relative;
}

.sub-page .system-area {
    display: block;
    padding: 10px;
    animation: fadeIn 0.5s ease-in-out;
}

.sub-page .system-area h3 {
    margin: 0 0 20px 0;
    color: white;
    font-size: 1.3em;
    border-bottom: 2px solid rgba(255,255,255,0.2);
    padding-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.sub-page .data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.sub-page .data-item {
    background-color: rgba(255,255,255,0.1);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.sub-page .data-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    background-color: rgba(255,255,255,0.15);
}

.sub-page .data-item label {
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    font-size: 0.9em;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sub-page .data-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    margin: 5px 0;
    min-height: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.sub-page .data-value.updating {
    color: #28a745;
    transform: scale(1.05);
    text-shadow: 0 0 10px rgba(40, 167, 69, 0.6);
}

.sub-page .unit {
    font-size: 0.8em;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    margin-top: 2px;
}

.sub-page .data-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.sub-page .data-item:hover::before {
    transform: scaleX(1);
}

.sub-page .data-value.pulse {
    animation: pulse 0.3s ease-in-out;
}

.sub-page .last-update {
    margin-top: 10px;
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: 0.85em;
}

/* Video Section Styles */
.sub-page .video-section {
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 300px; /* Set container height to match max video height */
    margin-left: auto;
    margin-right: auto;
    position: relative;
}

.sub-page .stream-video {
    position: absolute;
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain; /* Maintain aspect ratio without cropping */
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none; /* Prevent user interaction */
    border-radius: 8px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.sub-page .stream-video.active {
    opacity: 1;
    z-index: 1;
}

/* System Areas Styles */
.main-page .systems-section {
    margin-top: 30px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #ffffff;
    overflow: hidden;
}

.main-page .system-controls {
    background-color: #f8f9fa;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
}

.main-page .system-controls h2 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1.5em;
}

.main-page .sub-window-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
}

.main-page .sub-window-status .status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.3s ease;
}

.main-page .sub-window-status .status-indicator.connected {
    background-color: #28a745;
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
    animation: pulse-green 2s infinite;
}

.main-page .sub-window-status .status-indicator.disconnected {
    background-color: #6c757d;
}

.main-page .sub-window-status .status-text {
    color: #495057;
    font-weight: 500;
}

.main-page .sub-window-status .connection-count {
    color: #6c757d;
    font-size: 12px;
    font-weight: 600;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
    }
    50% {
        box-shadow: 0 0 15px rgba(40, 167, 69, 0.9);
    }
    100% {
        box-shadow: 0 0 8px rgba(40, 167, 69, 0.6);
    }
}

.main-page .system-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.main-page .system-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.main-page .system-btn:hover {
    background-color: #5a6268;
    transform: translateY(-1px);
}

.main-page .system-btn.active {
    background-color: #28a745;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.main-page .system-btn.active:hover {
    background-color: #218838;
}

.main-page .stop-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.main-page .stop-btn:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}

.main-page .system-data {
    padding: 0;
    position: relative;
}

.main-page .system-area {
    display: none;
    padding: 25px;
    animation: fadeIn 0.5s ease-in-out;
}

.main-page .system-area.active {
    display: block;
}

.main-page .system-area h3 {
    margin: 0 0 20px 0;
    color: #495057;
    font-size: 1.3em;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

.main-page .data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.main-page .data-item {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.main-page .data-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.main-page .data-item label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.main-page .data-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #007bff;
    font-family: 'Courier New', monospace;
    margin: 5px 0;
    min-height: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.main-page .data-value.updating {
    color: #28a745;
    transform: scale(1.05);
}

.main-page .unit {
    font-size: 0.8em;
    color: #6c757d;
    font-weight: 500;
    margin-top: 2px;
}

.main-page .data-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #007bff, #28a745);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.main-page .data-item:hover::before {
    transform: scaleX(1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

.main-page .data-value.pulse {
    animation: pulse 0.3s ease-in-out;
}

/* Responsive design */
@media (max-width: 768px) {
    .main-page .container {
        margin: 10px;
        padding: 20px;
    }
    
    .sub-page .container {
        margin: 10px;
        padding: 20px;
    }
    
    .sub-page h1 {
        font-size: 2em;
    }
    
    .main-page .data-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .main-page .system-buttons {
        flex-direction: column;
    }
    
    .main-page .system-btn,
    .main-page .stop-btn {
        width: 100%;
    }
    
    .main-page .data-value {
        font-size: 1.5em;
    }
    
    .sub-page .data-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
    }
    
    .sub-page .data-value {
        font-size: 1.5em;
    }
}
