/* ==========================================================
   UNIFIED TOOLS - Fixed Bottom Left (Always)
   ========================================================== */

.unified-tools {
    --tool-size: 56px;
    --expand-distance: 70px;
    
    position: fixed;
    bottom: 25px;
    left: 25px;
    z-index: 9999;
    
    display: grid;
    place-items: center;
    width: var(--tool-size);
    height: var(--tool-size);
}

/* Force left even in RTL */
html[dir="rtl"] .unified-tools {
    left: 25px;
    right: auto;
}

/* Base Button Style */
.tool-btn,
.tools-trigger {
    width: var(--tool-size);
    height: var(--tool-size);
    background: var(--bg-secondary);
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--shadow-md), 0 0 5px var(--accent-glow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    color: var(--accent);
    font-family: inherit;
    padding: 0;
    margin: 0;
    -webkit-tap-highlight-color: transparent;
}

.tool-btn:hover,
.tools-trigger:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

.tools-trigger {
    grid-area: 1 / 1;
    z-index: 10;
}

.tools-trigger .icon-settings {
    width: 24px;
    height: 24px;
    position: absolute;
    transition: transform 0.3s ease;
    color: var(--accent);
}

.unified-tools[data-state="expanded"] .tools-trigger .icon-settings {
    transform: rotate(90deg);
}

/* Tooltips */
.tool-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    padding: 6px 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 6px;
    border: 1px solid var(--accent);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    z-index: 100;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%) translateY(5px);
}

.tool-btn[data-tooltip]::before {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 101;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    border-left: none;
    border-bottom: none;
}

.tool-btn[data-tooltip]:hover::after,
.tool-btn[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Orbital Expansion */
.tool-orbital {
    grid-area: 1 / 1;
    width: var(--tool-size);
    height: var(--tool-size);
    position: absolute;
    opacity: 0;
    transform: scale(0.3);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
    z-index: 5;
}

/* UP (Theme) */
.tool-orbital[data-position="up"] {
    transform: translateY(0) scale(0.3);
}

.tool-orbital[data-position="up"].animate-in {
    opacity: 1;
    transform: translateY(calc(var(--expand-distance) * -1)) scale(1);
    pointer-events: auto;
}

/* RIGHT (Language) - Always expands right */
.tool-orbital[data-position="right"] {
    transform: translateX(0) scale(0.3);
}

.tool-orbital[data-position="right"].animate-in {
    opacity: 1;
    transform: translateX(var(--expand-distance)) scale(1);
    pointer-events: auto;
}

/* Icons */
.tool-btn svg,
.icon-lang {
    width: 22px;
    height: 22px;
    position: absolute;
    transition: all 0.3s ease;
    color: var(--accent);
}

.icon-lang {
    font-weight: 900;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: sans-serif;
}

/* Mode Icons */
.icon-sun {
    opacity: 0;
    transform: scale(0) rotate(-90deg);
    color: #fbbf24;
}

.icon-moon {
    opacity: 1;
    transform: scale(1) rotate(0);
    color: var(--accent);
}

.theme-dark .tool-mode-btn .icon-sun,
html.theme-dark .tool-mode-btn .icon-sun {
    opacity: 1;
    transform: scale(1) rotate(0);
}

.theme-dark .tool-mode-btn .icon-moon,
html.theme-dark .tool-mode-btn .icon-moon {
    opacity: 0;
    transform: scale(0) rotate(90deg);
}

/* Focus states */
.tool-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

/* Touch devices */
@media (pointer: coarse) {
    .tool-btn[data-tooltip]::after,
    .tool-btn[data-tooltip]::before {
        display: none;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .unified-tools {
        --tool-size: 50px;
        --expand-distance: 60px;
        bottom: 20px;
        left: 20px;
    }
    
    html[dir="rtl"] .unified-tools {
        left: 20px;
    }
    
    .tool-btn svg,
    .icon-lang {
        width: 20px;
        height: 20px;
        font-size: 14px;
    }
}

@media (max-width: 360px) {
    .unified-tools {
        --tool-size: 46px;
        --expand-distance: 55px;
        bottom: 15px;
        left: 15px;
    }
    
    html[dir="rtl"] .unified-tools {
        left: 15px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tool-btn,
    .tool-orbital,
    svg {
        transition: none !important;
    }
}