/* ============================================
   CONTAINER STYLES
   ============================================ */
.power-toggle-container {
    display: flex;
    align-items: center;
    margin-left: 8px;
    flex-shrink: 0;
    width: 137px;
    height: 38px;
    /* Ensure container maintains width to prevent layout shifts */
    min-width: 137px;
    @media (max-width: 768px) {
        width: 61px;
        min-width: 61px;
    }
}

/* ============================================
   HEADER SPECIFIC STYLES
   ============================================ */
.header-power-toggle {
    /* Reserve space to prevent layout shift during component loading */
    min-width: 137px;
    width: 137px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.header-power-toggle .power-toggle-container {
    margin-left: 0;
}

/* Mobile header spacing fix */
@media (max-width: 768px) {
    .header-power-toggle {
        /* Reserve mobile space to prevent layout shift */
        min-width: 61px;
        width: 61px;
        height: 28px;
        display: flex;
        align-items: center;
        flex-shrink: 0;
    }
    
    .header-power-toggle .power-toggle-container {
        margin-left: 0;
        margin-right: 15px;
        flex-shrink: 0;
        margin: 0;
    }
}

/* ============================================
   BUTTON BASE STYLES
   ============================================ */
.power-toggle-btn {
    background: #ececec;
    border: none;
    border-radius: 50px;
    width: 137px;
    height: 38px;
    padding: 0;
    cursor: pointer;
    position: relative;
    outline: none;
    transition: background-color 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    box-sizing: border-box;
}

.power-toggle-btn:focus {
    outline: none;
    box-shadow: none;
}

.power-toggle-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.power-toggle-btn:hover {
    background: #e0e0e0;
}

.toggle-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ============================================
   TEXT AND ICON STYLES
   ============================================ */
.toggle-text {
    font-family: 'SF Pro Text', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    font-size: 13px;
    color: #4d4d4d;
    letter-spacing: -0.56px;
    white-space: nowrap;
    line-height: 1;
    position: relative;
    z-index: 10;
    transition: color 0.3s ease;
}

.toggle-icon {
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 10;
}

.toggle-icon svg,
.toggle-icon img {
    width: 14px;
    height: 14px;
    display: block;
}

/* ============================================
   STATE MANAGEMENT
   ============================================ */
.toggle-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* ============================================
   SLIDING BACKGROUND ANIMATION
   ============================================ */
.power-toggle-btn::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 2px;
    width: 70px;
    height: 28px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 30px;
    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 1;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
}

/* Smooth slide animation */
.power-toggle-btn[data-state="hibernate"]::before {
    transform: translateX(60px);
}

/* Fixed icon positions */
.active-state .toggle-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.hibernate-state .toggle-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    transition: opacity 0.3s ease, color 0.3s ease;
}

/* Text positioning */
.active-state .toggle-text {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #374151;
    font-weight: 600;
    z-index: 2;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.hibernate-state .toggle-text {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #374151;
    font-weight: 600;
    z-index: 2;
    transition: opacity 0.3s ease, color 0.3s ease;
}

/* State-based visibility - only show content for active state */
.power-toggle-btn[data-state="active"] .active-state {
    opacity: 1;
    z-index: 3;
}

.power-toggle-btn[data-state="active"] .hibernate-state {
    opacity: 0;
    z-index: 1;
}

.power-toggle-btn[data-state="hibernate"] .hibernate-state {
    opacity: 1;
    z-index: 3;
}

.power-toggle-btn[data-state="hibernate"] .active-state {
    opacity: 0;
    z-index: 1;
}

.dropdown-arrow {
    font-size: 10px;
    color: #666;
}

/* ============================================
   POWER MODE COLORS
   ============================================ */
.power-toggle-btn[data-value="active"] .toggle-icon {
    color: #ff9500;
}

.power-toggle-btn[data-value="shutdown"] .toggle-icon {
    color: #ff3b30;
}

/* ============================================
   DARK MODE STYLES
   ============================================ */
[data-theme="dark"] .power-toggle-btn {
    background: #2a2a2a;
    border-color: #404040;
    color: #ffffff;
}

[data-theme="dark"] .power-toggle-btn:hover {
    background: #404040;
}

[data-theme="dark"] .toggle-text {
    color: #ffffff;
}

[data-theme="dark"] .power-toggle-btn[data-state="active"] .active-state::before,
[data-theme="dark"] .power-toggle-btn[data-state="hibernate"] .hibernate-state::before {
    background: linear-gradient(to bottom, #404040, #353535);
    border-color: #404040;
}

[data-theme="dark"] .dropdown-arrow {
    color: #ccc;
}

[data-theme="dark"] .power-toggle-btn[data-value="active"] .toggle-icon {
    color: #ff9f0a;
}

[data-theme="dark"] .power-toggle-btn[data-value="shutdown"] .toggle-icon {
    color: #ff8a8a;
}

/* ============================================
   LOADING STATE STYLES
   ============================================ */
.power-toggle-btn.loading .toggle-state {
    opacity: 0;
    visibility: hidden;
}

.power-toggle-btn.loading::before {
    opacity: 0;
    visibility: hidden;
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */
@media (max-width: 768px) {
    .power-toggle-container {
        margin-left: 6px;
    }
    
    .power-toggle-btn {
        width: 61px;
        height: 28px;
        position: relative;
    }
    
    /* Hide text on mobile */
    .toggle-text {
        display: none !important;
    }
    
    .toggle-icon {
        width: 10px;
        height: 10px;
    }
    
    .toggle-icon svg,
    .toggle-icon img {
        width: 10px;
        height: 10px;
    }
    
    /* Mobile: Ensure both states are visible with proper opacity */
    .power-toggle-btn .active-state,
    .power-toggle-btn .hibernate-state {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Mobile opacity states - only show active state */
    .power-toggle-btn[data-state="active"] .active-state {
        opacity: 1 !important;
        z-index: 3 !important;
    }
    
    .power-toggle-btn[data-state="active"] .hibernate-state {
        opacity: 0 !important;
        z-index: 1 !important;
    }
    
    .power-toggle-btn[data-state="hibernate"] .hibernate-state {
        opacity: 1 !important;
        z-index: 3 !important;
    }
    
    .power-toggle-btn[data-state="hibernate"] .active-state {
        opacity: 0 !important;
        z-index: 1 !important;
    }
    
    /* Mobile: Always show both icons */
    .power-toggle-btn .active-state .toggle-icon,
    .power-toggle-btn .hibernate-state .toggle-icon {
        position: absolute !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        z-index: 10;
    }
    
    /* Position moon icon on the left */
    .power-toggle-btn .active-state .toggle-icon {
        left: 8px !important;
        right: auto !important;
    }
    
    /* Position bolt icon on the right */
    .power-toggle-btn .hibernate-state .toggle-icon {
        right: 8px !important;
        left: auto !important;
    }
    
    /* Mobile slider - override desktop slider */
    .power-toggle-btn::before {
        width: 20px !important;
        height: 20px !important;
        border-radius: 50% !important;
        top: 3px !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    
    /* Mobile slide positions */
    .power-toggle-btn[data-state="active"]::before {
        transform: translateX(2px) !important;
    }
    
    .power-toggle-btn[data-state="hibernate"]::before {
        transform: translateX(37px) !important;
    }
    
    /* Loading state styles are inherited from main section above */

}