/* style.css - CSS Utama dengan Layout Fixed */
:root {
    /* Primary Colors */
    --primary-color: #2c3e50;
    --primary-light: #3498db;
    --primary-dark: #1a252f;
    
    /* Secondary Colors */
    --secondary-color: #f72585;
    --success-color: #4cc9f0;
    --warning-color: #f8961e;
    --danger-color: #f94144;
    
    /* Background Colors */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e9ecef;
    
    /* Text Colors */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    
    /* Border & Shadow */
    --border-color: #dee2e6;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    
    /* Status Colors */
    --status-normal: #2ecc71;
    --status-warning: #f39c12;
    --status-critical: #e74c3c;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #7209b7;
    --primary-light: #9d4edd;
    --primary-dark: #3a0ca3;
    
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    
    --border-color: #404040;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.35);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--bg-secondary) !important;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    height: 32px;
    width: auto;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-system-info {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.system-info-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.system-info-item:last-child {
    margin-bottom: 0;
}

.system-info-item i {
    font-size: 1.25rem;
    color: var(--primary-color);
    width: 24px;
    text-align: center;
}

.system-info-content {
    flex: 1;
}

.system-info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.system-info-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Status Colors */
.status-normal {
    color: var(--status-normal);
}

.status-warning {
    color: var(--warning-color);
}

.status-critical {
    color: var(--status-critical);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.nav-link:hover {
    color: var(--primary-color);
    background: var(--bg-tertiary);
}

.nav-link.active {
    color: var(--primary-color);
    background: var(--bg-tertiary);
    border-right: 3px solid var(--primary-color);
}

.nav-badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    background: var(--primary-color);
    color: white;
    min-width: 20px;
    text-align: center;
}

.badge-danger {
    background: var(--danger-color);
}

.nav-section {
    padding: 1rem 1.5rem 0.5rem;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.emergency-controls {
    margin-bottom: 1rem;
}

.emergency-controls .btn {
    width: 100%;
}

.sidebar-version {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - 250px);
    position: relative;
    overflow: hidden;
}

/* Top Navigation */
.top-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 900;
    height: 70px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.breadcrumb {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.breadcrumb span:last-child {
    color: var(--text-primary);
    font-weight: 600;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.connection-status {
    display: flex;
    gap: 0.5rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-normal {
    background-color: rgba(46, 204, 113, 0.1);
    color: var(--status-normal);
    border: 1px solid var(--status-normal);
}

.status-warning {
    background-color: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
    border: 1px solid var(--warning-color);
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
}

.theme-switch {
    display: none;
}

.theme-label {
    display: flex;
    align-items: center;
    width: 60px;
    height: 30px;
    background: var(--bg-tertiary);
    border-radius: 50px;
    padding: 5px;
    cursor: pointer;
    position: relative;
}

.theme-label i {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    z-index: 1;
}

.theme-label .fa-sun {
    left: 10px;
    color: #f39c12;
}

.theme-label .fa-moon {
    right: 10px;
    color: #f1c40f;
}

.theme-ball {
    position: absolute;
    left: 5px;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.theme-switch:checked + .theme-label .theme-ball {
    transform: translateX(30px);
}

/* Notification Dropdown */
.notification-dropdown {
    position: relative;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    position: relative;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger-color);
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 1000;
    display: none;
    margin-top: 0.5rem;
}

.notification-dropdown:hover .notification-menu {
    display: block;
}

.notification-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.notification-item:hover {
    background-color: var(--bg-tertiary);
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.notification-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 0.5rem;
}

/* Content Wrapper */
.content-wrapper {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

/* Cards */
.card {
    background-color: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 1.5rem;
    width: 100%;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.card-header h3 {
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
}

.card-body {
    padding: 1rem 0;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #d32f2f;
    transform: translateY(-2px);
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Welcome Banner */
.welcome-banner {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    grid-column: 1 / -1;
}

.welcome-content h2 {
    color: white;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.welcome-content p {
    opacity: 0.9;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.welcome-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.stat-item i {
    opacity: 0.8;
}

.stat-item strong {
    font-weight: 600;
    margin-left: 0.25rem;
}

/*  ==================================
    POWER CONTROL PAGE SPECIFIC STYLES
    ================================== */

/* Control Grid Layout */
.control-grid {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 1.5rem;
     margin-bottom: 1.5rem;
}

/* Safety Status Card - FIXED VERSION */
.safety-status-card {
     margin-bottom: 1.5rem;
}

.card-header-top {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-bottom: 1rem;
     flex-wrap: wrap;
     gap: 1rem;
}

.card-header-top h3 {
     margin: 0;
     display: flex;
     align-items: center;
     gap: 0.5rem;
     font-size: 1.25rem;
}

.header-actions {
     display: flex;
     gap: 0.5rem;
}

/* Status Indicators - Horizontal Bar */
.status-indicators {
     background: var(--bg-tertiary);
     border-radius: 8px;
     padding: 1rem;
     margin-top: 0.5rem;
}

.status-indicator-row {
     display: flex;
     flex-wrap: wrap;
     gap: 1.5rem;
     justify-content: space-between;
}

.status-indicator-item {
     display: flex;
     align-items: center;
     gap: 0.5rem;
     min-width: 200px;
}

.indicator-dot {
     display: inline-block;
     width: 10px;
     height: 10px;
     border-radius: 50%;
     flex-shrink: 0;
}

.indicator-success {
     background-color: var(--status-normal);
     box-shadow: 0 0 0 2px rgba(46, 204, 113, 0.2);
}

.indicator-warning {
     background-color: var(--warning-color);
     box-shadow: 0 0 0 2px rgba(248, 150, 30, 0.2);
}

.indicator-danger {
     background-color: var(--danger-color);
     box-shadow: 0 0 0 2px rgba(249, 65, 68, 0.2);
}

.indicator-secondary {
     background-color: var(--text-muted);
     box-shadow: 0 0 0 2px rgba(108, 117, 125, 0.2);
}

.indicator-label {
     font-size: 0.85rem;
     color: var(--text-secondary);
     font-weight: 500;
}

.indicator-value {
     font-size: 0.9rem;
     font-weight: 600;
     padding: 0.25rem 0.75rem;
     border-radius: 4px;
     text-transform: uppercase;
     letter-spacing: 0.5px;
}

.indicator-value.indicator-success {
     background-color: rgba(46, 204, 113, 0.1);
     color: var(--status-normal);
}

.indicator-value.indicator-warning {
     background-color: rgba(248, 150, 30, 0.1);
     color: var(--warning-color);
}

.indicator-value.indicator-danger {
     background-color: rgba(249, 65, 68, 0.1);
     color: var(--danger-color);
}

.indicator-value.indicator-secondary {
     background-color: rgba(108, 117, 125, 0.1);
     color: var(--text-muted);
}

/* Safety Status Grid */
.safety-status-grid {
     display: grid;
     grid-template-columns: repeat(2, 1fr);
     gap: 1rem;
     margin-top: 1rem;
}

.status-item {
     display: flex;
     align-items: flex-start;
     gap: 1rem;
     padding: 1rem;
     background: var(--bg-tertiary);
     border-radius: 10px;
     transition: all 0.3s ease;
     min-height: 100px;
}

.status-item:hover {
     transform: translateY(-2px);
     background: var(--bg-secondary);
     box-shadow: var(--shadow-sm);
}

.status-icon {
     font-size: 1.5rem;
     width: 50px;
     height: 50px;
     display: flex;
     align-items: center;
     justify-content: center;
     background: var(--bg-secondary);
     border-radius: 50%;
     flex-shrink: 0;
}

.status-content {
     flex: 1;
     min-width: 0;
}

.status-label {
     font-size: 0.85rem;
     color: var(--text-secondary);
     margin-bottom: 0.25rem;
     font-weight: 600;
}

.status-value {
     font-weight: 700;
     font-size: 1rem;
     display: block;
     margin-bottom: 0.25rem;
}

.status-description {
     font-size: 0.8rem;
     color: var(--text-muted);
     line-height: 1.4;
}

/* Protocol Levels */
.protocol-levels {
     display: flex;
     flex-direction: column;
     gap: 1.5rem;
}

.protocol-level {
     padding: 1.5rem;
     border-radius: 10px;
     border-left: 4px solid;
     transition: all 0.3s ease;
}

.protocol-level:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-md);
}

.level-warning {
     border-left-color: var(--warning-color);
     background: rgba(248, 150, 30, 0.05);
}

.level-danger {
     border-left-color: var(--danger-color);
     background: rgba(249, 65, 68, 0.05);
}

.level-critical {
     border-left-color: #dc3545;
     background: rgba(220, 53, 69, 0.05);
}

.level-header {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-bottom: 1rem;
     flex-wrap: wrap;
     gap: 0.5rem;
}

.level-header h4 {
     margin: 0;
     font-size: 1rem;
     display: flex;
     align-items: center;
     gap: 0.5rem;
     flex: 1;
}

.level-actions {
     display: flex;
     flex-direction: column;
     gap: 0.75rem;
}

.action-item {
     display: flex;
     align-items: center;
     gap: 0.75rem;
     padding: 0.5rem;
     border-radius: 6px;
     transition: background-color 0.2s ease;
}

.action-item:hover {
     background: var(--bg-tertiary);
}

.action-item input[type="checkbox"] {
     width: 18px;
     height: 18px;
     cursor: pointer;
}

.action-item label {
     display: flex;
     align-items: center;
     gap: 0.5rem;
     cursor: pointer;
     font-size: 0.9rem;
     flex: 1;
}

/* Protocol Settings */
.protocol-settings {
     margin-top: 2rem;
     padding-top: 1.5rem;
     border-top: 1px solid var(--border-color);
}

.protocol-settings .form-group {
     margin-bottom: 1.5rem;
}

.range-value {
     margin-top: 0.5rem;
     font-weight: 600;
     color: var(--primary-color);
     font-size: 0.9rem;
     display: inline-block;
     padding: 0.25rem 0.75rem;
     background: var(--bg-tertiary);
     border-radius: 4px;
}

/* Device Controls */
.device-controls {
     display: flex;
     flex-direction: column;
     gap: 1.5rem;
}

.control-group {
     padding: 1.5rem;
     background: var(--bg-tertiary);
     border-radius: 10px;
     transition: all 0.3s ease;
}

.control-group:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-sm);
}

.control-group h4 {
     margin: 0 0 1rem 0;
     font-size: 1rem;
     display: flex;
     align-items: center;
     gap: 0.5rem;
}

.btn-group {
     display: flex;
     flex-wrap: wrap;
     gap: 0.5rem;
     margin-bottom: 1rem;
}

.relay-status {
     display: flex;
     align-items: center;
     gap: 0.5rem;
     margin-top: 1rem;
     padding-top: 1rem;
     border-top: 1px solid var(--border-color);
}

/* Advanced Settings */
.settings-grid {
     display: flex;
     flex-direction: column;
     gap: 1rem;
     margin-bottom: 1.5rem;
}

.setting-item {
     display: flex;
     align-items: center;
     gap: 1rem;
     padding: 1rem;
     background: var(--bg-tertiary);
     border-radius: 10px;
     transition: all 0.3s ease;
}

.setting-item:hover {
     transform: translateY(-2px);
     background: var(--bg-secondary);
     box-shadow: var(--shadow-sm);
}

.setting-icon {
     font-size: 1.25rem;
     color: var(--primary-color);
     width: 50px;
     height: 50px;
     display: flex;
     align-items: center;
     justify-content: center;
     background: var(--bg-secondary);
     border-radius: 50%;
     flex-shrink: 0;
}

.setting-content {
     flex: 1;
     min-width: 0;
}

.setting-label {
     font-weight: 600;
     font-size: 0.9rem;
     margin-bottom: 0.25rem;
}

.setting-description {
     font-size: 0.8rem;
     color: var(--text-muted);
     line-height: 1.4;
}

.setting-time {
     font-size: 0.85rem;
     color: var(--text-secondary);
     font-weight: 500;
     white-space: nowrap;
}

/* Toggle Switch */
.switch {
     position: relative;
     display: inline-block;
     width: 50px;
     height: 24px;
     flex-shrink: 0;
}

.switch input {
     opacity: 0;
     width: 0;
     height: 0;
}

.slider {
     position: absolute;
     cursor: pointer;
     top: 0;
     left: 0;
     right: 0;
     bottom: 0;
     background-color: var(--border-color);
     transition: .4s;
}

.slider:before {
     position: absolute;
     content: "";
     height: 16px;
     width: 16px;
     left: 4px;
     bottom: 4px;
     background-color: white;
     transition: .4s;
}

input:checked + .slider {
     background-color: var(--primary-color);
}

input:checked + .slider:before {
     transform: translateX(26px);
}

.slider.round {
     border-radius: 24px;
}

.slider.round:before {
     border-radius: 50%;
}

/* Setting Actions */
.setting-actions {
     display: flex;
     gap: 1rem;
     flex-wrap: wrap;
     padding-top: 1rem;
     border-top: 1px solid var(--border-color);
}

/* Simulation Card */
.simulation-controls {
     display: flex;
     flex-direction: column;
     gap: 1.5rem;
}

.simulation-scenarios {
     padding: 1.5rem;
     background: var(--bg-tertiary);
     border-radius: 10px;
     transition: all 0.3s ease;
}

.simulation-scenarios:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-sm);
}

.scenario-buttons {
     display: flex;
     flex-wrap: wrap;
     gap: 0.5rem;
     margin-top: 1rem;
}

.simulation-status {
     padding: 1.5rem;
     background: var(--bg-tertiary);
     border-radius: 10px;
     transition: all 0.3s ease;
}

.simulation-status:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-sm);
}

.simulation-progress {
     width: 100%;
     height: 8px;
     background: var(--border-color);
     border-radius: 4px;
     overflow: hidden;
     margin: 1rem 0;
}

.simulation-progress .progress-bar {
     height: 100%;
     background: var(--primary-color);
     width: 0%;
     transition: width 0.5s ease;
}

.simulation-log {
     max-height: 200px;
     overflow-y: auto;
     padding: 1rem;
     background: var(--bg-secondary);
     border-radius: 8px;
     font-family: 'Consolas', 'Monaco', monospace;
     font-size: 0.85rem;
     line-height: 1.5;
}

.log-entry {
     padding: 0.5rem 0;
     border-bottom: 1px solid var(--border-color);
     white-space: pre-wrap;
     word-break: break-word;
}

.log-entry:last-child {
     border-bottom: none;
}

/* Responsive Design for Control Page */
@media (max-width: 1200px) {
     .control-grid {
          grid-template-columns: 1fr;
     }
     
     .safety-status-grid {
          grid-template-columns: repeat(2, 1fr);
     }
     
     .status-indicator-row {
          gap: 1rem;
     }
     
     .status-indicator-item {
          min-width: 180px;
     }
}

@media (max-width: 768px) {
    /* Main content dengan swipe capability */
    .main-content {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
        position: relative;
        z-index: 1;
        background-color: var(--bg-primary);
        min-height: 100vh;
    }

    /* Sidebar style untuk swipe */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
        z-index: 1000;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.2);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Main content ketika sidebar terbuka */
    .main-content.sidebar-shifted {
        transform: translateX(250px);
    }
    
    /* Overlay untuk menutup sidebar */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .mobile-overlay.active {
        display: block;
        opacity: 1;
    }
    
    /* Visual feedback saat touch active */
    .main-content.touch-active {
        transition: none !important;
    }
    
    /* Hamburger menu button */
    .hamburger-menu {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 30px;
        height: 24px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-right: 1rem;
    }
    
    .hamburger-menu span {
        display: block;
        width: 100%;
        height: 3px;
        background-color: var(--text-primary);
        border-radius: 3px;
        transition: all 0.3s ease;
    }
    
    .hamburger-menu.active span:nth-child(1) {
        transform: rotate(45deg) translateY(8px);
    }
    
    .hamburger-menu.active span:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger-menu.active span:nth-child(3) {
        transform: rotate(-45deg) translateY(-8px);
    }
    
    /* Content wrapper untuk swipe area yang lebih luas */
    .content-wrapper {
        min-height: calc(100vh - 70px); /* Kurangi tinggi top-nav */
        touch-action: pan-y; /* Izinkan vertical scroll, handle horizontal dengan JS */
    }
    
    /* Prevent text selection selama swipe */
    .main-content,
    .content-wrapper,
    .card {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Swipe hint indicator */
    .swipe-hint {
        position: fixed;
        top: 50%;
        left: 15px;
        transform: translateY(-50%);
        width: 40px;
        height: 40px;
        background: rgba(var(--primary-color-rgb, 67, 97, 238), 0.1);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1001;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .swipe-hint.show {
        opacity: 0.7;
        animation: pulseHint 2s ease-in-out infinite;
    }
    
    @keyframes pulseHint {
        0%, 100% { 
            transform: translateY(-50%) scale(1);
            opacity: 0.7;
        }
        50% { 
            transform: translateY(-50%) scale(1.1);
            opacity: 0.9;
        }
    }
    
    .swipe-hint i {
        color: var(--primary-color);
        font-size: 1.2rem;
    }
    
    /* Adjust top-nav untuk mobile */
    .top-nav {
        position: sticky;
        top: 0;
        z-index: 1002;
        background: var(--bg-secondary);
        height: 60px;
        padding: 0.75rem 1rem;
    }
    
    .nav-left {
        display: flex;
        align-items: center;
    }

     .card-header-top {
          flex-direction: column;
          align-items: flex-start;
     }
     
     .header-actions {
          width: 100%;
     }
     
     .status-indicator-row {
          flex-direction: column;
          gap: 0.75rem;
     }
     
     .status-indicator-item {
          min-width: 100%;
          justify-content: space-between;
     }
     
     .safety-status-grid {
          grid-template-columns: 1fr;
     }
     
     .scenario-buttons {
          flex-direction: column;
     }
     
     .scenario-buttons button {
          width: 100%;
     }
     
     .setting-actions {
          flex-direction: column;
     }
     
     .setting-actions button {
          width: 100%;
     }
     
     .btn-group {
          flex-direction: column;
     }
     
     .btn-group button {
          width: 100%;
     }
     
     .level-header {
          flex-direction: column;
          align-items: flex-start;
          gap: 0.5rem;
     }
}

@media (max-width: 576px) {
     .status-item {
          flex-direction: column;
          text-align: center;
          gap: 0.75rem;
     }
     
     .status-icon {
          width: 40px;
          height: 40px;
          margin: 0 auto;
     }
     
     .setting-item {
          flex-direction: column;
          text-align: center;
          gap: 0.75rem;
     }
     
     .setting-icon {
          width: 40px;
          height: 40px;
          margin: 0 auto;
     }
     
     .status-indicator-item {
          flex-wrap: wrap;
     }
}

/* Desktop - nonaktifkan swipe */
@media (min-width: 769px) {
    .main-content {
        margin-left: 250px;
        transform: none !important;
    }
    
    .sidebar {
        transform: translateX(0) !important;
    }
    
    .hamburger-menu {
        display: none;
    }
    
    .mobile-overlay {
        display: none !important;
    }
}

/* Main Content Grid untuk PC */
.main-content-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    height: fit-content;
}

/* Left Column */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Right Column */
.right-column {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Power Metrics Card */
.power-metrics-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Chart Card */
.chart-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Watt Metrics Grid */
.watt-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
    flex: 1;
}

/* Metric Card */
.metric-card {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 1.25rem 1rem;
    border-left: 4px solid;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: center;
    min-height: 140px;
    position: relative;
}

.metric-card:hover {
    transform: translateY(-2px);
}

.metric-card.volt {
    border-left-color: #4361ee;
}

.metric-card.amp {
    border-left-color: #4cc9f0;
}

.metric-card.watt {
    border-left-color: #f72585;
}

.metric-card.energy {
    border-left-color: #7209b7;
}

.metric-icon {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    opacity: 0.8;
    color: inherit;
}

.metric-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.metric-unit {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-trend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    justify-content: center;
    margin-top: 0.5rem;
}

.trend-up {
    color: var(--status-normal);
}

.trend-down {
    color: #4cc9f0;
}

/* Text Colors */
.text-danger {
    color: var(--danger-color) !important;
}

.text-warning {
    color: var(--warning-color) !important;
}

.text-success {
    color: var(--status-normal) !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    flex: 1;
    margin-top: 1rem;
}

/* Live Indicator */
.time-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--status-normal);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}

.live-dot {
    color: var(--status-normal);
    animation: pulse 1.5s infinite;
    font-size: 0.75rem;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chart Controls */
.chart-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.chart-range-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.form-control {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 120px;
}

.form-control-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Bottom Section */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* Data Table Card */
.data-table-card {
    width: 100%;
}

.power-limit-card {
    width: 100%;
}

/* Table Styles */
.table-responsive {
    overflow-x: auto;
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    min-width: 600px;
}

.data-table thead {
    background: var(--primary-color);
    color: white;
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--primary-dark);
    font-size: 0.9rem;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background-color: var(--bg-tertiary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Power Limit Control */
.power-limit-control {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.limit-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 1rem;
}

.limit-current, .limit-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.limit-current strong {
    font-size: 1.25rem;
    color: var(--primary-color);
}

.limit-status strong {
    font-size: 1.25rem;
}

/* Form Group */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    width: 100%;
}

.input-group .form-control {
    flex: 1;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    min-width: 0;
}

.input-group-append {
    display: flex;
}

.input-group-append .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    white-space: nowrap;
}

.form-text {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Margin utilities */
.ml-2 {
    margin-left: 0.5rem;
}

/* Notification Toast */
.notification-toast {
    position: fixed;
    top: 90px;
    right: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 9999;
    max-width: 350px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-info .toast-icon {
    background: rgba(52, 152, 219, 0.1);
    color: #3498db;
}

.toast-warning .toast-icon {
    background: rgba(243, 156, 18, 0.1);
    color: #f39c12;
}

.toast-critical .toast-icon {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.toast-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    flex-shrink: 0;
    padding: 0.25rem;
    margin-left: 0.5rem;
}

/* Power Limit Slider */
.limit-range-info {
    margin-top: 1rem;
}

.limit-slider-container {
    margin-top: 1rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.limit-slider {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.limit-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.limit-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
    box-shadow: var(--shadow-sm);
}

.limit-slider::-webkit-slider-thumb:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.slider-labels span {
    font-weight: 500;
}

#slider-value {
    font-weight: 600;
    color: var(--primary-color);
}

#slider-value.text-danger {
    color: var(--danger-color);
}

#slider-value.text-success {
    color: var(--status-normal);
}

/* Form validation styles */
input:invalid {
    border-color: var(--danger-color) !important;
}

input:valid {
    border-color: var(--status-normal) !important;
}

/* ============================================
    TOAST NOTIFICATION & LOADING SPINNER
    ============================================ */

/* Loading Spinner */
.loading-spinner {
     display: none;
     position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background-color: rgba(0, 0, 0, 0.7);
     z-index: 9999;
     align-items: center;
     justify-content: center;
}

.loading-spinner.active {
     display: flex;
}

.spinner-content {
     background-color: var(--bg-secondary);
     border-radius: 12px;
     padding: 2rem;
     text-align: center;
     box-shadow: var(--shadow-lg);
     min-width: 200px;
}

.spinner {
     width: 50px;
     height: 50px;
     border: 4px solid var(--bg-tertiary);
     border-top: 4px solid var(--primary-color);
     border-radius: 50%;
     animation: spin 1s linear infinite;
     margin: 0 auto 1rem;
}

@keyframes spin {
     0% { transform: rotate(0deg); }
     100% { transform: rotate(360deg); }
}

.spinner-content p {
     margin: 0;
     font-weight: 600;
     color: var(--text-primary);
     font-size: 0.95rem;
}

/* Toast Notification */
.toast-notification {
     position: fixed;
     top: 90px;
     right: 20px;
     background-color: var(--bg-secondary);
     border-radius: 8px;
     padding: 1rem 1.5rem;
     box-shadow: var(--shadow-lg);
     border-left: 4px solid;
     z-index: 9998;
     display: flex;
     align-items: center;
     gap: 1rem;
     max-width: 400px;
     animation: toastSlideIn 0.3s ease;
     transform: translateX(0);
}

@keyframes toastSlideIn {
     from {
          opacity: 0;
          transform: translateX(100%);
     }
     to {
          opacity: 1;
          transform: translateX(0);
     }
}

@keyframes toastSlideOut {
     from {
          opacity: 1;
          transform: translateX(0);
     }
     to {
          opacity: 0;
          transform: translateX(100%);
     }
}

.toast-notification.toast-success {
     border-left-color: var(--status-normal);
}

.toast-notification.toast-error {
     border-left-color: var(--danger-color);
}

.toast-notification.toast-warning {
     border-left-color: var(--warning-color);
}

.toast-notification.toast-info {
     border-left-color: var(--primary-color);
}

.toast-notification.toast-critical {
     border-left-color: var(--danger-color);
     background-color: rgba(249, 65, 68, 0.1);
}

.toast-icon {
     font-size: 1.5rem;
     flex-shrink: 0;
}

.toast-success .toast-icon {
     color: var(--status-normal);
}

.toast-error .toast-icon {
     color: var(--danger-color);
}

.toast-warning .toast-icon {
     color: var(--warning-color);
}

.toast-info .toast-icon {
     color: var(--primary-color);
}

.toast-critical .toast-icon {
     color: var(--danger-color);
}

.toast-content {
     flex: 1;
     min-width: 0;
}

.toast-title {
     font-weight: 600;
     margin-bottom: 0.25rem;
     font-size: 0.95rem;
     color: var(--text-primary);
}

.toast-message {
     font-size: 0.9rem;
     color: var(--text-secondary);
     line-height: 1.4;
}

.toast-close {
     background: none;
     border: none;
     color: var(--text-muted);
     cursor: pointer;
     font-size: 1.25rem;
     padding: 0.25rem;
     width: 24px;
     height: 24px;
     display: flex;
     align-items: center;
     justify-content: center;
     border-radius: 50%;
     flex-shrink: 0;
     transition: background-color 0.2s;
}

.toast-close:hover {
     background-color: var(--bg-tertiary);
     color: var(--text-primary);
}

/* Watt Progress Bar */
.watt-progress {
     width: 100%;
     height: 6px;
     background-color: var(--bg-tertiary);
     border-radius: 3px;
     margin-top: 0.75rem;
     overflow: hidden;
}

.watt-progress .progress-bar {
     height: 100%;
     border-radius: 3px;
     transition: width 0.5s ease, background-color 0.5s ease;
}

/* Power Limit Status Badge */
.limit-status .badge-danger {
     display: none;
     font-size: 0.7rem;
     padding: 0.2rem 0.5rem;
     margin-left: 0.5rem;
     vertical-align: middle;
}

/*  ==============================
    POWER CONTROL PAGE - COMPLETE
    ============================= */

/* Control Grid Layout */
.control-grid {
     display: grid;
     grid-template-columns: 1fr 1fr;
     gap: 1.5rem;
     margin-bottom: 1.5rem;
     width: 100%;
}

.left-column, .right-column {
     display: flex;
     flex-direction: column;
     gap: 1.5rem;
}

/* Card Header Fixes */
.card-header {
     display: flex;
     flex-direction: column;
     gap: 1rem;
     margin-bottom: 1.5rem;
     padding-bottom: 1rem;
     border-bottom: 2px solid var(--border-color);
}

.card-header-main {
     display: flex;
     justify-content: space-between;
     align-items: center;
     width: 100%;
}

.card-header-main h3 {
     margin: 0;
     font-size: 1.25rem;
     display: flex;
     align-items: center;
     gap: 0.5rem;
}

/* Protocol Levels - Fixed */
.protocol-levels {
     display: flex;
     flex-direction: column;
     gap: 1rem;
}

.protocol-level {
     padding: 1.25rem;
     border-radius: 10px;
     border-left: 4px solid;
     background: var(--bg-tertiary);
     transition: all 0.3s ease;
}

.protocol-level:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-sm);
}

.level-warning {
     border-left-color: var(--warning-color);
}

.level-danger {
     border-left-color: var(--danger-color);
}

.level-critical {
     border-left-color: #dc3545;
}

.level-header {
     display: flex;
     justify-content: space-between;
     align-items: center;
     margin-bottom: 1rem;
     flex-wrap: wrap;
     gap: 0.5rem;
}

.level-title {
     display: flex;
     align-items: center;
     gap: 0.75rem;
     flex: 1;
}

.level-title h4 {
     margin: 0;
     font-size: 1rem;
     font-weight: 600;
     color: var(--text-primary);
}

.level-title i {
     font-size: 1.1rem;
     width: 24px;
     text-align: center;
}

.level-title i.fa-exclamation-circle {
     color: var(--warning-color);
}

.level-title i.fa-radiation {
     color: var(--danger-color);
}

.level-title i.fa-skull-crossbones {
     color: #dc3545;
}

.level-status {
     display: flex;
     align-items: center;
}

.status-tag {
     display: inline-block;
     padding: 0.35rem 0.75rem;
     font-size: 0.75rem;
     font-weight: 700;
     border-radius: 20px;
     text-transform: uppercase;
     letter-spacing: 0.5px;
     white-space: nowrap;
}

.status-warning {
     background-color: var(--warning-color);
     color: white;
}

.status-danger {
     background-color: var(--danger-color);
     color: white;
}

.status-critical {
     background-color: #dc3545;
     color: white;
}

.level-actions {
     display: flex;
     flex-direction: column;
     gap: 0.75rem;
}

.action-item {
     display: flex;
     align-items: center;
     gap: 0.75rem;
     padding: 0.5rem;
     border-radius: 6px;
     transition: background-color 0.2s ease;
}

.action-item:hover {
     background-color: rgba(255, 255, 255, 0.05);
}

.action-item input[type="checkbox"] {
     width: 18px;
     height: 18px;
     cursor: pointer;
     flex-shrink: 0;
}

.action-item label {
     display: flex;
     align-items: center;
     gap: 0.5rem;
     cursor: pointer;
     font-size: 0.9rem;
     flex: 1;
     color: var(--text-primary);
}

.action-item label i {
     width: 20px;
     color: var(--text-secondary);
}

/* Device Controls - Fixed */
.device-controls {
     display: flex;
     flex-direction: column;
     gap: 1.25rem;
}

.control-group {
     padding: 1.25rem;
     background: var(--bg-tertiary);
     border-radius: 10px;
     transition: all 0.3s ease;
}

.control-group:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-sm);
}

.control-header {
     display: flex;
     align-items: center;
     gap: 0.75rem;
     margin-bottom: 1rem;
}

.control-header h4 {
     margin: 0;
     font-size: 1rem;
     font-weight: 600;
     color: var(--text-primary);
}

.control-header i {
     font-size: 1.1rem;
     color: var(--primary-color);
     width: 24px;
     text-align: center;
}

.btn-group {
     display: flex;
     flex-wrap: wrap;
     gap: 0.5rem;
     margin-bottom: 0.75rem;
}

.relay-status {
     display: flex;
     align-items: center;
     gap: 0.5rem;
     margin-top: 0.75rem;
     padding-top: 0.75rem;
     border-top: 1px solid var(--border-color);
}

.status-label {
     font-size: 0.85rem;
     color: var(--text-secondary);
}

.status-value {
     font-size: 0.9rem;
     font-weight: 600;
     padding: 0.25rem 0.5rem;
     border-radius: 4px;
}

.status-connected {
     background-color: rgba(46, 204, 113, 0.1);
     color: var(--status-normal);
     border: 1px solid var(--status-normal);
}

.status-disconnected {
     background-color: rgba(249, 65, 68, 0.1);
     color: var(--danger-color);
     border: 1px solid var(--danger-color);
}

/* Advanced Settings - Fixed */
.settings-grid {
     display: flex;
     flex-direction: column;
     gap: 0.75rem;
     margin-bottom: 1.5rem;
}

.setting-item {
     display: flex;
     align-items: center;
     gap: 1rem;
     padding: 1rem;
     background: var(--bg-tertiary);
     border-radius: 10px;
     transition: all 0.3s ease;
}

.setting-item:hover {
     transform: translateY(-2px);
     background: var(--bg-secondary);
     box-shadow: var(--shadow-sm);
}

.setting-icon {
     font-size: 1.25rem;
     color: var(--primary-color);
     width: 40px;
     height: 40px;
     display: flex;
     align-items: center;
     justify-content: center;
     background: var(--bg-secondary);
     border-radius: 50%;
     flex-shrink: 0;
}

.setting-content {
     flex: 1;
     min-width: 0;
}

.setting-label {
     font-weight: 600;
     font-size: 0.9rem;
     margin-bottom: 0.25rem;
     color: var(--text-primary);
}

.setting-description {
     font-size: 0.8rem;
     color: var(--text-muted);
     line-height: 1.4;
}

.setting-time {
     font-size: 0.85rem;
     color: var(--text-secondary);
     font-weight: 500;
     white-space: nowrap;
     padding: 0.25rem 0.5rem;
     background: var(--bg-secondary);
     border-radius: 4px;
}

.setting-control {
     display: flex;
     align-items: center;
     gap: 0.5rem;
}

.setting-control .form-control-sm {
     min-width: 120px;
}

/* Toggle Switch */
.switch {
     position: relative;
     display: inline-block;
     width: 50px;
     height: 24px;
     flex-shrink: 0;
}

.switch input {
     opacity: 0;
     width: 0;
     height: 0;
}

.slider {
     position: absolute;
     cursor: pointer;
     top: 0;
     left: 0;
     right: 0;
     bottom: 0;
     background-color: var(--border-color);
     transition: .4s;
}

.slider:before {
     position: absolute;
     content: "";
     height: 16px;
     width: 16px;
     left: 4px;
     bottom: 4px;
     background-color: white;
     transition: .4s;
}

input:checked + .slider {
     background-color: var(--primary-color);
}

input:checked + .slider:before {
     transform: translateX(26px);
}

.slider.round {
     border-radius: 24px;
}

.slider.round:before {
     border-radius: 50%;
}

/* Setting Actions */
.setting-actions {
     display: flex;
     gap: 0.75rem;
     flex-wrap: wrap;
     padding-top: 1rem;
     border-top: 1px solid var(--border-color);
}

/* Protocol Settings */
.protocol-settings {
     margin-top: 1.5rem;
     padding-top: 1.5rem;
     border-top: 1px solid var(--border-color);
}

.protocol-settings .form-group {
     margin-bottom: 1.25rem;
}

.protocol-settings label {
     display: block;
     margin-bottom: 0.5rem;
     font-weight: 600;
     color: var(--text-primary);
     font-size: 0.9rem;
}

.range-value {
     margin-top: 0.5rem;
     font-weight: 600;
     color: var(--primary-color);
     font-size: 0.9rem;
     display: inline-block;
     padding: 0.25rem 0.75rem;
     background: var(--bg-tertiary);
     border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 1200px) {
     .control-grid {
          grid-template-columns: 1fr;
          gap: 1rem;
     }
     
     .left-column, .right-column {
          gap: 1rem;
     }
     
     .protocol-level {
          padding: 1rem;
     }
     
     .control-group {
          padding: 1rem;
     }
}

@media (max-width: 768px) {
     .level-header {
          flex-direction: column;
          align-items: flex-start;
          gap: 0.5rem;
     }
     
     .level-status {
          align-self: flex-start;
     }
     
     .btn-group {
          flex-direction: column;
     }
     
     .btn-group button {
          width: 100%;
     }
     
     .setting-item {
          flex-direction: column;
          text-align: center;
          gap: 0.75rem;
          padding: 0.875rem;
     }
     
     .setting-icon {
          width: 36px;
          height: 36px;
          font-size: 1.1rem;
     }
     
     .setting-actions {
          flex-direction: column;
     }
     
     .setting-actions button {
          width: 100%;
     }
     
     .status-indicator-row {
          flex-direction: column;
          gap: 0.75rem;
     }
     
     .status-indicator-item {
          justify-content: space-between;
     }
}

@media (max-width: 576px) {
     .card-header-main h3 {
          font-size: 1.1rem;
     }
     
     .level-title h4 {
          font-size: 0.95rem;
     }
     
     .status-tag {
          font-size: 0.7rem;
          padding: 0.3rem 0.6rem;
     }
     
     .action-item label {
          font-size: 0.85rem;
     }
     
     .control-header h4 {
          font-size: 0.95rem;
     }
     
     .setting-label {
          font-size: 0.85rem;
     }
}

/* ============================================
   MOBILE SIDEBAR & RESPONSIVE NAVIGATION
   ============================================ */

/* Mobile Menu Button (in sidebar for desktop) */
.mobile-menu-btn {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1001;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: var(--bg-tertiary);
}

/* Hamburger Menu (in top nav for mobile) */
.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1002;
}

.hamburger-menu span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: var(--text-primary);
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: left center;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translateY(-2px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
    width: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(2px);
}

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive Sidebar Behavior */
@media (max-width: 768px) {
    /* Show hamburger menu on mobile */
    .hamburger-menu {
        display: flex;
    }
    
    /* Hide mobile menu button in sidebar on desktop */
    .mobile-menu-btn {
        display: block;
    }
    
    /* Sidebar for mobile - hidden by default */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px;
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
        z-index: 1000;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Main content adjustment when sidebar is active */
    .main-content {
        margin-left: 0;
        width: 100%;
        transition: margin-left 0.4s ease;
    }
    
    .main-content.sidebar-active {
        margin-left: 280px;
    }
    
    /* Adjust top navigation when sidebar is open */
    .top-nav {
        position: relative;
        z-index: 1001;
        background: var(--bg-secondary);
    }
    
    /* Hide breadcrumb on very small screens */
    @media (max-width: 576px) {
        .breadcrumb {
            font-size: 0.8rem;
        }
    }
    
    /* Emergency controls adjustment */
    .emergency-controls .btn {
        font-size: 0.85rem;
        padding: 0.75rem;
    }
    
    /* Welcome banner adjustments */
    .welcome-banner {
        padding: 1rem;
    }
    
    .welcome-content h2 {
        font-size: 1.25rem;
    }
    
    .welcome-content p {
        font-size: 0.9rem;
    }
    
    /* Power metrics adjustments */
    .watt-metrics-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .metric-card {
        min-height: 110px;
        padding: 1rem;
    }
    
    /* Chart card adjustments */
    .chart-card {
        height: auto;
    }
    
    .chart-container {
        height: 250px;
    }
    
    /* Card header adjustments */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    /* Bottom section adjustments */
    .bottom-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Connection status adjustments */
    .connection-status {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .status-indicator {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
    
    /* Theme toggle adjustment */
    .theme-label {
        width: 55px;
        height: 28px;
    }
    
    .theme-ball {
        width: 18px;
        height: 18px;
    }
    
    .theme-switch:checked + .theme-label .theme-ball {
        transform: translateX(27px);
    }
}

/* Tablet specific adjustments */
@media (min-width: 577px) and (max-width: 768px) {
    .sidebar {
        width: 300px;
    }
    
    .main-content.sidebar-active {
        margin-left: 300px;
    }
    
    .watt-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .metric-card {
        min-height: 120px;
    }
}

/* Prevent body scroll when sidebar is open */
body.sidebar-open {
    overflow: hidden;
}

/* Smooth transition for main content */
.main-content {
    transition: transform 0.4s ease;
}

/* Sidebar close button inside sidebar for mobile */
.sidebar-close-btn {
    display: none;
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.sidebar-close-btn:hover {
    background: var(--bg-tertiary);
}

@media (max-width: 768px) {
    .sidebar-close-btn {
        display: block;
    }
    
    /* Adjust sidebar header for close button */
    .sidebar-header {
        padding-right: 3rem;
        position: relative;
    }
}

/* Sidebar backdrop effect for iOS */
@supports (-webkit-backdrop-filter: none) or (backdrop-filter: none) {
    .sidebar {
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        background-color: rgba(var(--bg-secondary-rgb, 255, 255, 255), 0.9);
    }
}

/* Animation for sidebar slide */
@keyframes slideInFromLeft {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.sidebar.active {
    animation: slideInFromLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Better touch targets for mobile */
@media (max-width: 768px) {
    .nav-link {
        padding: 1rem 1.5rem;
        min-height: 50px;
    }
    
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control {
        min-height: 44px;
    }
    
    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
}

/* Swipe to close gesture area */
@media (max-width: 768px) {
    .sidebar::before {
        content: '';
        position: absolute;
        top: 0;
        right: -20px;
        width: 20px;
        height: 100%;
        z-index: -1;
    }
}

/* Emergency cutoff button mobile optimization */
@media (max-width: 768px) {
    .emergency-controls .btn {
        position: relative;
        overflow: hidden;
    }
    
    .emergency-controls .btn::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 5px;
        height: 5px;
        background: rgba(255, 255, 255, 0.5);
        opacity: 0;
        border-radius: 100%;
        transform: scale(1, 1) translate(-50%);
        transform-origin: 50% 50%;
    }
    
    .emergency-controls .btn:focus:not(:active)::after {
        animation: ripple 1s ease-out;
    }
    
    @keyframes ripple {
        0% {
            transform: scale(0, 0);
            opacity: 0.5;
        }
        20% {
            transform: scale(25, 25);
            opacity: 0.3;
        }
        100% {
            opacity: 0;
            transform: scale(40, 40);
        }
    }
}

/* ============================================
   CLEANUP - Remove old problematic styles
   ============================================ */

/* Remove all old badge styles that cause problems */
.badge,
[class*="badge-"],
.badge-container,
.status-badges {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

/* Fix any floating elements */
.card-header > *:not(.card-header-top):not(.status-indicators):not(.card-header-main) {
    float: none !important;
    clear: both !important;
}

/* Ensure no element is positioned absolutely in the wrong place */
.protocol-level .badge,
.level-header .badge {
    display: none !important;
}

/* Clear any residual styles */
*[style*="position: absolute"],
*[style*="float: right"],
*[style*="right: 0"] {
    position: static !important;
    float: none !important;
    right: auto !important;
}