/*
╔═══════════════════════════════════════════════════════════════════╗
║ TOOLS PANEL — Right-side, always visible                          ║
║ Mini (60px) ↔ Expanded (280px)                                    ║
╚═══════════════════════════════════════════════════════════════════╝
*/

/* ====================================================================
   PANEL — always visible, mini by default
   ==================================================================== */

.tools-panel {
    width: 60px;
    height: 100%;
    background: var(--io-surface-raised);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    transition: width 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.tools-panel.expanded {
    width: 280px;
}

/* left accent fade border */
.tools-panel::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(var(--io-border-accent-fade-base), 0.3) 15%,
        rgba(var(--io-border-accent-fade-base), 1.0) 50%,
        rgba(var(--io-border-accent-fade-base), 0.3) 85%,
        transparent 100%
    );
    pointer-events: none;
}

/* ====================================================================
   TOGGLE BUTTON — top of panel
   ==================================================================== */

.tp-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--io-space-lg) 0;
    cursor: pointer;
    color: var(--io-text-tertiary);
    transition: var(--io-transition-base);
    flex-shrink: 0;
}

.tp-toggle:hover {
    color: var(--io-accent);
    background: var(--io-surface-hover);
}

.tp-toggle-icon {
    font-size: var(--io-text-base);
    transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.tools-panel.expanded .tp-toggle-icon {
    transform: rotate(180deg);
}

/* ====================================================================
   DIVIDER
   ==================================================================== */

.tp-divider {
    height: 1px;
    margin: 0 var(--io-space-sm);
    background: linear-gradient(to right, transparent 0%, var(--io-border) 50%, transparent 100%);
    flex-shrink: 0;
    transition: margin 300ms ease;
}

.tools-panel.expanded .tp-divider {
    margin: 0 var(--io-space-lg);
}

/* ====================================================================
   TOOL LIST
   ==================================================================== */

.tp-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--io-space-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tp-list::-webkit-scrollbar { width: 4px; }
.tp-list::-webkit-scrollbar-track { background: transparent; }
.tp-list::-webkit-scrollbar-thumb { background: var(--io-accent-subtle); border-radius: 2px; }

/* ====================================================================
   TOOL ITEM — mini: icon centered, expanded: icon + text
   ==================================================================== */

.tp-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: var(--io-space-md) 0;
    justify-content: center;
    cursor: pointer;
    transition: var(--io-transition-base);
    position: relative;
    overflow: hidden;
    border-radius: var(--io-radius-sm);
}

.tp-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--io-accent);
    transform: scaleY(0);
    transition: transform var(--io-transition-base);
}

.tp-item:hover {
    background: var(--io-surface-hover);
}

.tp-item:hover::before {
    transform: scaleY(1);
}

.tp-item:active {
    background: var(--io-accent-subtle);
}

.tp-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--io-accent);
    font-size: var(--io-text-sm);
    flex-shrink: 0;
    transition: var(--io-transition-base);
}

.tp-item:hover .tp-item-icon {
    transform: scale(1.1);
}

.tp-item-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity 200ms ease, width 200ms ease;
}

.tp-item-label {
    font-family: var(--io-font-mono);
    font-size: var(--io-text-sm);
    font-weight: 600;
    color: var(--io-text-primary);
    white-space: nowrap;
}

.tp-item-desc {
    font-family: var(--io-font-mono);
    font-size: 11px;
    color: var(--io-text-tertiary);
    white-space: nowrap;
}

/* EXPANDED: show text */
.tools-panel.expanded .tp-item {
    padding: var(--io-space-md);
    justify-content: flex-start;
    gap: var(--io-space-md);
}

.tools-panel.expanded .tp-item-text {
    opacity: 1;
    width: auto;
}

/* ====================================================================
   STATS — bottom of panel
   ==================================================================== */

.tp-stats {
    padding: var(--io-space-md) var(--io-space-sm);
    display: flex;
    flex-direction: column;
    gap: var(--io-space-md);
    flex-shrink: 0;
}

.tp-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--io-space-xs);
}

/* icon — always visible */
.tp-stat-icon {
    font-size: 11px;
    color: var(--io-accent);
    flex-shrink: 0;
}

/* mini number — shown in mini mode */
.tp-stat-mini {
    font-family: var(--io-font-mono);
    font-size: 10px;
    font-weight: 700;
    color: var(--io-text-secondary);
    text-align: center;
    transition: opacity 200ms ease;
}

/* full detail — hidden in mini */
.tp-stat-detail {
    width: 100%;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 200ms ease, max-height 200ms ease;
}

.tp-stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.tp-stat-label {
    font-family: var(--io-font-mono);
    font-size: 10px;
    color: var(--io-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tp-stat-value {
    font-family: var(--io-font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--io-text-secondary);
}

.tp-stat-track {
    height: 4px;
    background: var(--io-surface-sunken);
    overflow: hidden;
    margin-top: var(--io-space-xs);
}

.tp-stat-fill {
    height: 100%;
    width: 0;
    background: var(--io-accent);
    transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* EXPANDED: show bars, hide mini numbers */
.tools-panel.expanded .tp-stats {
    padding: var(--io-space-md) var(--io-space-lg);
}

.tools-panel.expanded .tp-stat {
    flex-direction: column;
    align-items: stretch;
}

.tools-panel.expanded .tp-stat-icon {
    display: none;
}

.tools-panel.expanded .tp-stat-mini {
    display: none;
}

.tools-panel.expanded .tp-stat-detail {
    opacity: 1;
    max-height: 40px;
}

/* ====================================================================
   TOOLTIP — appears left of panel, instant
   ==================================================================== */

.tp-tip {
    position: fixed;
    z-index: 9999;
    padding: var(--io-space-sm) var(--io-space-md);
    background: var(--io-surface-overlay);
    border: 1px solid var(--io-border);
    font-family: var(--io-font-mono);
    font-size: 13px;
    color: var(--io-text-primary);
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transform: translateX(4px);
    transition: opacity 80ms ease, transform 80ms ease;
    white-space: nowrap;
    max-width: 240px;
}

.tp-tip.visible {
    opacity: 1;
    transform: translateX(0);
}

.tp-tip strong {
    font-weight: 700;
    color: var(--io-accent);
}

.tp-tip-desc {
    font-size: 13px;
    color: var(--io-text-tertiary);
}

/* ====================================================================
   RESPONSIVE — mobile overlay
   ==================================================================== */

@media (max-width: 768px) {
    .tools-panel {
        position: absolute;
        right: 0;
        top: 0;
        z-index: 1000;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
    }
}