/**
 * Theme Toggle Button Styles
 * Visible on all devices
 */

/* Container */
.theme-toggle-container {
    display: block;
    position: relative;
}

/* Mobile: position in grid layout */
@media (max-width: 768px) {
    /* Hamburger + language left, 4 icons right (offline, theme, bell, feedback) */
    .top {
        grid-template-columns: auto auto 1fr repeat(4, 32px) !important;
        gap: 0.15rem !important;
        padding-right: 0.5rem !important;
    }

    /* Shift right icons 20px to the left */
    .top #offline-indicator {
        transform: translateX(-20px);
    }
    .top .theme-toggle-container {
        transform: translateX(-20px);
    }
    .top .notification-bell-container {
        transform: translateX(-20px);
    }
    .top .feedback-top-btn {
        transform: translateX(-20px);
    }

    /* Hamburger column 1 */
    .top .hamburger {
        grid-column: 1 !important;
        justify-self: start;
    }

    /* Language selector column 2 (next to hamburger) */
    .top .language-selector {
        grid-column: 2;
        justify-self: start;
        margin: 0;
        margin-left: 0.25rem;
    }

    /* Offline indicator column 4 - only when visible */
    .top #offline-indicator {
        grid-column: 4 !important;
        justify-self: center;
        margin: 0 !important;
    }

    /* Keep hidden state working */
    .top #offline-indicator.hidden {
        display: none !important;
    }

    /* Theme toggle column 5 */
    .theme-toggle-container {
        grid-column: 5;
        justify-self: center;
        margin: 0;
    }

    /* Notification bell column 6 */
    .top .notification-bell-container {
        grid-column: 6 !important;
        justify-self: center;
        margin: 0;
    }

    /* Feedback button column 7 */
    .top .feedback-top-btn {
        grid-column: 7 !important;
        justify-self: center;
        margin: 0 !important;
        padding: 0 !important;
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
    }

    /* Hide feedback text on mobile */
    .top .feedback-top-btn .feedback-top-btn__text {
        display: none !important;
    }

    /* Consistent icon sizes for right-side icons */
    .top .theme-toggle-container,
    .top .notification-bell-container,
    .top .feedback-top-btn {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Offline indicator sizing when visible */
    .top #offline-indicator:not(.hidden) {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .top .language-selector__trigger {
        padding: 0.25rem !important;
        gap: 0 !important;
    }

    .top .language-selector__code,
    .top .language-selector__arrow {
        display: none !important;
    }

    .top .theme-toggle {
        width: 32px !important;
        height: 32px !important;
        margin: 0 !important;
    }

    .top .theme-toggle__label {
        display: none !important;
    }
}

/* Desktop: position in header flex order - after bell */
@media (min-width: 769px) {
    .theme-toggle-container {
        order: 4; /* After notification bell (3), before language selector */
        margin-left: 0;
    }

    /* Adjust language selector order to come after theme toggle */
    .top .language-selector {
        order: 5 !important;
    }

    /* Adjust feedback button order */
    .top .feedback-top-btn {
        order: 6 !important;
    }

    /* Adjust hamburger order */
    .top .hamburger {
        order: 7 !important;
    }
}

/* Toggle Button */
.theme-toggle {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 48px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: white;
    transition: background 0.2s ease, color 0.2s ease;
    margin-right: 0.5rem;
    gap: 2px;
}

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

/* Icons */
.theme-toggle__icon {
    width: 20px;
    height: 20px;
    display: none;
    transition: transform 0.3s ease;
}

/* Show appropriate icon based on theme */
.theme-toggle--light .theme-toggle__icon--sun {
    display: block;
}

.theme-toggle--dark .theme-toggle__icon--moon {
    display: block;
}

.theme-toggle--auto .theme-toggle__icon--auto {
    display: block;
}

/* Label below icon */
.theme-toggle__label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

/* Hover animation */
.theme-toggle:hover .theme-toggle__icon {
    transform: scale(1.1);
}

/* Active/pressed state */
.theme-toggle:active .theme-toggle__icon {
    transform: scale(0.95);
}

/* Light mode icon color (sun - yellow/orange) */
.theme-toggle--light .theme-toggle__icon--sun {
    color: #ffc107;
}

/* Dark mode icon color (moon - light blue) */
.theme-toggle--dark .theme-toggle__icon--moon {
    color: #a0d2db;
}

/* Auto mode icon color (half circle - white) */
.theme-toggle--auto .theme-toggle__icon--auto {
    color: white;
}

/* Pulse animation on theme change */
@keyframes theme-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.theme-toggle:focus {
    outline: none;
}

.theme-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .theme-toggle {
        width: 36px;
        height: 44px;
        margin-right: 0.25rem;
    }

    .theme-toggle__icon {
        width: 18px;
        height: 18px;
    }

    .theme-toggle__label {
        font-size: 8px;
    }
}
