/**
 * Advanced Control Sidebar CSS
 * Full-screen expandable sidebar with sophisticated controls
 */

.advanced-sidebar {
    position: fixed;
    top: 80px; /* Start from bottom of corner logo */
    right: 0;
    height: calc(100vh - 80px);
    z-index: 9999; /* Lower than header and corner */
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    font-family: 'Roboto Mono', 'SF Mono', monospace;
    user-select: none;
}

/* Collapsed State */
.advanced-sidebar.collapsed {
    width: 80px; /* Match corner logo width */
    background: transparent;
}

.advanced-sidebar.collapsed .sidebar-content {
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
}

.advanced-sidebar.collapsed .sidebar-collapsed-controls {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
}

/* Expanded State */
.advanced-sidebar.expanded {
    width: 500px;
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.98) 0%, 
        rgba(30, 41, 59, 0.98) 50%, 
        rgba(51, 65, 85, 0.98) 100%);
    backdrop-filter: blur(20px);
    border: none; /* Remove border for seamless connection */
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
}

.advanced-sidebar.expanded .sidebar-content {
    opacity: 1;
    pointer-events: all;
    transform: translateX(0);
}

.advanced-sidebar.expanded .sidebar-collapsed-controls {
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
}

/* Collapsed Controls */
.sidebar-collapsed-controls {
    position: absolute;
    right: 0;
    top: 0;
    width: 80px; /* Match corner logo width */
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.95) 0%, 
        rgba(30, 41, 59, 0.95) 100%);
    backdrop-filter: blur(15px);
    border-left: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.3);
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-collapsed-controls::-webkit-scrollbar {
    width: 3px;
}

.sidebar-collapsed-controls::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-collapsed-controls::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 2px;
}

.collapsed-btn {
    width: 44px;
    height: 44px;
    background: rgba(51, 65, 85, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 8px;
    color: rgba(148, 163, 184, 0.9);
    font-size: 16px;
    position: relative;
    overflow: hidden;
}

.collapsed-btn:hover {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.3) 0%, 
        rgba(147, 51, 234, 0.3) 100%);
    border-color: rgba(59, 130, 246, 0.5);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    color: #ffffff;
}

.collapsed-btn.expand-btn {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.3) 0%, 
        rgba(147, 51, 234, 0.3) 100%);
    border-color: rgba(59, 130, 246, 0.5);
    margin-bottom: 16px;
    color: #ffffff;
    font-weight: bold;
}

.collapsed-btn.expand-btn:hover {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.5) 0%, 
        rgba(147, 51, 234, 0.5) 100%);
    transform: scale(1.1) translateX(-2px);
}

.collapsed-btn.emergency {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.2);
    animation: emergencyPulse 3s infinite;
}

@keyframes emergencyPulse {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.3); 
    }
    50% { 
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.6); 
    }
}

.collapsed-btn.quick-action-feedback {
    animation: quickActionFeedback 0.3s ease;
}

@keyframes quickActionFeedback {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background: rgba(34, 197, 94, 0.4); }
    100% { transform: scale(1); }
}

.collapsed-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0 8px;
}

.collapsed-status {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 8px;
}

.collapsed-bottom {
    margin-top: 16px;
    padding: 0 8px;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    padding-top: 16px;
}

.collapsed-btn.settings-btn {
    background: linear-gradient(135deg, 
        rgba(71, 85, 105, 0.8) 0%, 
        rgba(51, 65, 85, 0.8) 100%);
    border-color: rgba(148, 163, 184, 0.4);
    animation: settingsPulse 4s infinite;
}

@keyframes settingsPulse {
    0%, 100% { 
        box-shadow: 0 0 8px rgba(148, 163, 184, 0.2); 
    }
    50% { 
        box-shadow: 0 0 16px rgba(148, 163, 184, 0.4); 
    }
}

.status-indicator {
    width: 44px;
    height: 40px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.3s ease;
}

.status-indicator.alert-none {
    border-color: rgba(34, 197, 94, 0.5);
    background: rgba(34, 197, 94, 0.1);
}

.status-indicator.alert-medium {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.1);
    animation: alertMedium 2s infinite;
}

.status-indicator.alert-high {
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.1);
    animation: alertHigh 1s infinite;
}

@keyframes alertMedium {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes alertHigh {
    0%, 100% { 
        opacity: 1; 
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.3); 
    }
    50% { 
        opacity: 0.8; 
        box-shadow: 0 0 16px rgba(239, 68, 68, 0.6); 
    }
}

.status-icon {
    font-size: 12px;
    margin-bottom: 2px;
}

.status-value {
    font-size: 10px;
    font-weight: 600;
    color: #ffffff;
}

/* Sidebar Content */
.sidebar-content {
    height: calc(100vh - 80px); /* Account for header height */
    padding-top: 0; /* Remove extra padding since sidebar starts below header */
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    overflow: hidden;
}

/* Sidebar Header */
.sidebar-header {
    padding: 24px;
    background: linear-gradient(135deg, 
        rgba(15, 23, 42, 0.9) 0%, 
        rgba(30, 41, 59, 0.9) 100%);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    position: relative;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.sidebar-subtitle {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.8);
    font-weight: 400;
    letter-spacing: 1px;
}

.sidebar-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(71, 85, 105, 0.3);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    color: rgba(148, 163, 184, 0.8);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: rgba(59, 130, 246, 0.5);
    color: #ffffff;
    transform: scale(1.05);
}

/* Navigation Tabs */
.sidebar-nav {
    padding: 16px 24px;
    display: flex;
    gap: 8px;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.nav-tab {
    flex: 1;
    padding: 12px 8px;
    background: rgba(51, 65, 85, 0.3);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    color: rgba(148, 163, 184, 0.7);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    letter-spacing: 1px;
}

.nav-tab:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
    color: rgba(59, 130, 246, 0.9);
}

.nav-tab.active {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.3) 0%, 
        rgba(147, 51, 234, 0.3) 100%);
    border-color: rgba(59, 130, 246, 0.5);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

/* Sidebar Body */
.sidebar-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    position: relative;
}

.sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.3);
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 3px;
}

.sidebar-body::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

/* View Panels */
.view-panel {
    display: none;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.view-panel.active {
    display: block;
}

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

/* Control Sections */
.control-section {
    margin-bottom: 32px;
}

.control-section.emergency {
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 20px;
    background: rgba(239, 68, 68, 0.05);
    margin-bottom: 24px;
}

.section-title {
    font-size: 14px;
    font-weight: 700;
    color: rgba(148, 163, 184, 0.9);
    letter-spacing: 2px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    padding-bottom: 8px;
}

/* Control Grids */
.control-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

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

.control-grid.medium-grid {
    grid-template-columns: repeat(3, 1fr);
}

/* Control Buttons */
.control-btn {
    background: linear-gradient(135deg, 
        rgba(51, 65, 85, 0.8) 0%, 
        rgba(71, 85, 105, 0.8) 100%);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    padding: 16px;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.control-btn:hover {
    background: linear-gradient(135deg, 
        rgba(59, 130, 246, 0.3) 0%, 
        rgba(147, 51, 234, 0.3) 100%);
    border-color: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

.control-btn.large {
    padding: 20px;
    grid-column: span 1;
}

.control-btn.medium {
    padding: 16px 12px;
}

.control-btn.small {
    padding: 12px 8px;
}

/* Emergency Buttons */
.control-btn.emergency-btn {
    position: relative;
    overflow: hidden;
}

.control-btn.emergency-btn.critical {
    background: linear-gradient(135deg, 
        rgba(239, 68, 68, 0.3) 0%, 
        rgba(220, 38, 38, 0.3) 100%);
    border-color: rgba(239, 68, 68, 0.5);
    animation: criticalPulse 2s infinite;
}

.control-btn.emergency-btn.warning {
    background: linear-gradient(135deg, 
        rgba(245, 158, 11, 0.3) 0%, 
        rgba(217, 119, 6, 0.3) 100%);
    border-color: rgba(245, 158, 11, 0.5);
}

@keyframes criticalPulse {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(239, 68, 68, 0.3); 
    }
    50% { 
        box-shadow: 0 0 40px rgba(239, 68, 68, 0.6); 
    }
}

/* Button Content */
.btn-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.btn-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}

.btn-sublabel {
    font-size: 10px;
    color: rgba(148, 163, 184, 0.7);
    font-weight: 400;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-widget {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-widget:hover {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.stat-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 10px;
    color: rgba(148, 163, 184, 0.7);
    letter-spacing: 1px;
}

/* Emergency Warning */
.emergency-warning {
    background: linear-gradient(135deg, 
        rgba(239, 68, 68, 0.2) 0%, 
        rgba(220, 38, 38, 0.2) 100%);
    border: 2px solid rgba(239, 68, 68, 0.4);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    margin-bottom: 24px;
    animation: warningPulse 3s infinite;
}

@keyframes warningPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.warning-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.warning-text {
    font-size: 16px;
    font-weight: 700;
    color: #ef4444;
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.warning-subtitle {
    font-size: 12px;
    color: rgba(239, 68, 68, 0.7);
}

/* Emergency Contacts */
.emergency-contacts {
    margin-top: 24px;
}

.contact-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    padding: 12px;
}

.contact-icon {
    font-size: 20px;
    width: 32px;
    text-align: center;
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
}

.contact-number {
    font-size: 11px;
    color: rgba(148, 163, 184, 0.7);
}

.contact-btn {
    background: rgba(34, 197, 94, 0.3);
    border: 1px solid rgba(34, 197, 94, 0.5);
    border-radius: 6px;
    padding: 8px 16px;
    color: #22c55e;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.contact-btn:hover {
    background: rgba(34, 197, 94, 0.5);
    transform: scale(1.05);
}

/* Analytics Widgets */
.analytics-widgets {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.widget-container {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 16px;
}

.widget-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.9);
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.mini-chart {
    height: 80px;
    background: rgba(51, 65, 85, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(148, 163, 184, 0.5);
    font-size: 10px;
}

/* Settings */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
}

.setting-label {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.9);
    font-weight: 500;
}

.setting-select {
    background: rgba(51, 65, 85, 0.8);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 6px;
    padding: 6px 10px;
    color: #ffffff;
    font-size: 11px;
    min-width: 120px;
}

.setting-slider {
    width: 80px;
    margin-right: 8px;
}

.setting-value {
    font-size: 11px;
    color: rgba(59, 130, 246, 0.9);
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

/* Toggle Switch */
.setting-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(71, 85, 105, 0.8);
    transition: 0.2s;
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: #ffffff;
    transition: 0.2s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
    background-color: rgba(59, 130, 246, 0.8);
    border-color: rgba(59, 130, 246, 0.5);
}

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

/* Sidebar Footer */
.sidebar-footer {
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.8);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.system-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-label {
    font-size: 10px;
    color: rgba(148, 163, 184, 0.7);
    letter-spacing: 1px;
}

.info-value {
    font-size: 10px;
    color: #ffffff;
    font-weight: 600;
}

.status-active {
    color: #22c55e !important;
    text-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .advanced-sidebar.expanded {
        width: 400px;
    }
    
    .control-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .advanced-sidebar.expanded {
        width: 100vw;
    }
    
    .sidebar-toggle {
        left: -50px;
        width: 50px;
        height: 100px;
    }
}
