/**
 * Dashboard Switcher Styles
 * Fixed position navigation bar for switching between dashboard views
 */

.dashboard-switcher {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    background-color: #2c3e50;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    gap: 10px;
}

/* Spacer to push controls to the right */
.switcher-spacer {
    flex: 1;
}

/* Environment selector wrapper */
.environment-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* Custom Select Dropdown */
.custom-select {
    position: relative;
    display: inline-block;
    user-select: none;
}

.select-selected {
    background-color: #34495e;
    color: #ecf0f1;
    padding: 4px 30px 4px 10px;
    border: 1px solid #4a6278;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.select-selected:hover {
    background-color: #3d566e;
    border-color: #5a7a9a;
}

/* Arrow indicator */
.select-selected::after {
    content: '▼';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #ecf0f1;
    transition: transform 0.3s ease;
}

.select-selected.select-arrow-active::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Dropdown items container */
.select-items {
    position: absolute;
    background-color: #2c3e50;
    border: 1px solid #4a6278;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    top: 100%;
    left: 0;
    z-index: 99;
    max-height: 400px;
    overflow-y: auto;
    margin-top: -1px;
    min-width: 100%;
    width: max-content;
}

.select-items.select-hide {
    display: none;
}

/* Individual dropdown item */
.select-item {
    padding: 8px 10px;
    cursor: pointer;
    font-size: 12px;
    color: #ecf0f1;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
}

.select-item:hover {
    background-color: #34495e;
}

.select-item.same-as-selected {
    background-color: #3d566e;
    font-weight: 500;
}

/* Access precondition for a live-plane page — Howard directive info 8c6e defect (2)
   clause (d). Non-interactive: it is a statement, not a selectable entry, so it must
   not pick up .select-item's hover/cursor affordances. Wrapped rather than
   `width: max-content`-stretched so a paragraph cannot widen the whole dropdown. */
.select-access-note {
    padding: 8px 10px;
    border-top: 1px solid #4a6278;
    font-size: 11px;
    line-height: 1.4;
    color: #bdc3c7;
    max-width: 34em;
    white-space: normal;
    cursor: default;
}

/* Environment name */
.env-name {
    white-space: nowrap;
    font-weight: 600;
}

/* Badge styling */
.env-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.badge-cdn {
    background-color: #27ae60;
    color: white;
}

.badge-vpn {
    background-color: #f39c12;
    color: white;
}

.badge-local {
    background-color: #3498db;
    color: white;
}

.badge-nginx {
    background-color: #20c997;
    color: white;
}

.badge-adserver {
    background-color: #5b7daa;
    color: white;
}

.badge-cdnproxy {
    background-color: #17a2b8;
    color: white;
}

.badge-encoder {
    background-color: #9b59b6;
    color: white;
}

.badge-hlsloadtest {
    background-color: #e67e22;
    color: white;
}

.badge-unknown {
    background-color: #95a5a6;
    color: white;
}

/* Live detected state (server-state-client): NOT RUNNING + capability chips.
   --capability-green is the single source for the enabled-capability colour,
   shared with the Channel Health panel's .capability-chip.enabled (inline
   <style> in ChannelHealthDashboard.html, which loads this stylesheet). */
:root {
    --capability-green: #1f7a3d;
}
.badge-not-running {
    background-color: #dc3545;
    color: white;
}

.badge-capability {
    background-color: var(--capability-green);
    color: white;
}

/* An optional plane switched on and REFUSED at bring-up (capabilities
   state:"refused"): an operator must see it, not read it as "off". */
.badge-capability-refused {
    background-color: #dc3545;
    color: white;
}

/* Scrollbar styling for dropdown */
.select-items::-webkit-scrollbar {
    width: 8px;
}

.select-items::-webkit-scrollbar-track {
    background: #1a2530;
}

.select-items::-webkit-scrollbar-thumb {
    background: #4a6278;
    border-radius: 4px;
}

.select-items::-webkit-scrollbar-thumb:hover {
    background: #5a7a9a;
}

/* Theme toggle button */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #ecf0f1;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-family: Arial, sans-serif;
    white-space: nowrap;
    margin-left: 8px;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.theme-toggle-icon {
    font-size: 16px;
    line-height: 1;
}

.theme-toggle-label {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.9;
}

/* Settings button */
.settings-button {
    margin-left: 5px;
    margin-right: -15px;
}

/* Adjust body padding to account for fixed header */
body.has-switcher {
    padding-top: 32px;  /* Match the height of the switcher */
}

.switcher-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 12px;
    background-color: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #ecf0f1;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-family: Arial, sans-serif;
    position: relative;
}

.switcher-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.switcher-button.active {
    background-color: #3498db;
    border-color: #2980b9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switcher-button.active:hover {
    background-color: #2980b9;
}

.switcher-icon {
    font-size: 20px;
    line-height: 1;
}

.switcher-label {
    font-weight: 500;
    white-space: nowrap;
}

/* Tooltip styling */
.switcher-button::after {
    content: attr(title);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1001;
}

.switcher-button:hover::after {
    opacity: 1;
}

/* Responsive design */
@media (max-width: 768px) {
    .dashboard-switcher {
        padding: 0 10px;
        gap: 5px;
    }

    .switcher-button {
        padding: 8px 10px;
    }

    .switcher-label {
        display: none;
    }

    .switcher-icon {
        font-size: 24px;
    }

    .theme-toggle-label {
        display: none;
    }

    .switcher-split-arrow {
        width: 14px;
    }
}

/* Split button group (button + dropdown arrow) */
.switcher-button-group {
    display: flex;
    align-items: center;
    position: relative;
}

.switcher-button.split-main {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    padding-right: 8px;
}

/* Remove tooltip from split-main since the group handles positioning */
.switcher-button.split-main::after {
    left: calc(50% - 8px);
}

.switcher-split-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    padding: 3px 0;
    background-color: transparent;
    border: 1px solid transparent;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    color: #95a5a6;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    transition: all 0.3s ease;
    font-family: Arial, sans-serif;
}

.switcher-split-arrow:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ecf0f1;
}

.switcher-split-arrow.split-arrow-active {
    background-color: rgba(255, 255, 255, 0.2);
    color: #ecf0f1;
}

/* Inherit active state styling from main button to arrow */
.switcher-button-group .switcher-button.active + .switcher-launch-menu + .switcher-split-arrow,
.switcher-button-group .switcher-button.active ~ .switcher-split-arrow {
    border-left-color: rgba(255, 255, 255, 0.25);
}

/* Hover effect on group */
.switcher-button-group:hover .switcher-button.split-main {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    border-right-color: transparent;
}

.switcher-button-group:hover .switcher-split-arrow {
    border-color: rgba(255, 255, 255, 0.2);
    border-left-color: rgba(255, 255, 255, 0.15);
}

/* Active state for group */
.switcher-button-group .switcher-button.active {
    border-right-color: transparent;
}

.switcher-button-group .switcher-button.active ~ .switcher-split-arrow {
    background-color: #3498db;
    border-color: #2980b9;
    border-left-color: rgba(255, 255, 255, 0.25);
    color: #ecf0f1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Launch options dropdown menu */
.switcher-launch-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background-color: #2c3e50;
    border: 1px solid #4a6278;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1003;
    min-width: 140px;
    overflow: hidden;
}

.switcher-launch-menu.launch-menu-hide {
    display: none;
}

.switcher-launch-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #ecf0f1;
    font-size: 13px;
    font-family: Arial, sans-serif;
    cursor: pointer;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}

.switcher-launch-item:hover {
    background-color: #34495e;
}

.switcher-launch-item:first-child {
    border-radius: 5px 5px 0 0;
}

.switcher-launch-item:last-child {
    border-radius: 0 0 5px 5px;
}

.launch-item-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

/* Button checking availability state */
.switcher-button.checking {
    opacity: 0.6;
    cursor: wait;
}

/* Unavailable dashboard notification toast */
.switcher-notification {
    position: fixed;
    top: 42px;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    background-color: #34495e;
    border: 1px solid #e67e22;
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    font-family: Arial, sans-serif;
}

.switcher-notification.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.notification-icon {
    font-size: 20px;
    line-height: 1;
}

.notification-text {
    color: #ecf0f1;
    font-size: 14px;
}

.notification-text strong {
    color: #e67e22;
}

.notification-close {
    background: none;
    border: none;
    color: #95a5a6;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.notification-close:hover {
    color: #ecf0f1;
}

/* Animation for view transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dashboard-switcher {
    animation: fadeIn 0.3s ease;
}

/* Ensure switcher stays on top of other elements */
#environment-selector,
#dashboard,
h1 {
    position: relative;
    z-index: 1;
}

/* Adjust main content to not be hidden under switcher */
body > h1:first-of-type,
body > div:first-of-type:not(.dashboard-switcher) {
    margin-top: 10px;
}
