/*
   TAKO SIDEBAR — ported from TAK Studio V2 TAKSidebar.css
   Vanilla-CSS equivalent of the React/Framer Motion sidebar:
   collapse is a class toggle (.sidebar--collapsed) + width transition.
   Consumes tak-tokens.css (--sidebar-width: 220px / --sidebar-collapsed: 64px).
*/

/* ── Shell ─────────────────────────────────────────────────────────── */

.takeoff-wp-app .sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--surface-raised);
    border-right: 1px solid var(--surface-overlay);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    /* [ANTIGRAVITY FIX] Ensure sidebar is above all overlays */
    position: relative;
    z-index: 4000;
    transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: visible;
}

.takeoff-wp-app .sidebar--collapsed {
    width: var(--sidebar-collapsed);
}

/* Applied pre-paint when restoring a persisted collapsed state, removed on
   first rAF by tako-ui.js so the initial render never animates. */
.takeoff-wp-app .sidebar--no-anim,
.takeoff-wp-app .sidebar--no-anim * {
    transition: none !important;
}

/* ── Logo area ─────────────────────────────────────────────────────── */

.takeoff-wp-app .sidebar-logo-area {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-4);
    gap: var(--space-3);
    flex-shrink: 0;
}

.takeoff-wp-app .sidebar--collapsed .sidebar-logo-area {
    padding: 0;
}

/* i.ph selectors beat the global `.takeoff-wp-app i.ph { font-size: 20px }`
   compatibility rule in style.css */
.takeoff-wp-app i.ph.sidebar-logo-icon {
    font-size: 28px;
    color: var(--accent);
    flex-shrink: 0;
    transition: font-size 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.takeoff-wp-app .sidebar--collapsed i.ph.sidebar-logo-icon {
    font-size: 32px;
}

.takeoff-wp-app .sidebar-wordmark {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.takeoff-wp-app .sidebar-wordmark-title {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.takeoff-wp-app .sidebar-wordmark-sub {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
}

/* ── Scrollable content ────────────────────────────────────────────── */

.takeoff-wp-app .sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-3) 0;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-overlay) transparent;
}

.takeoff-wp-app .sidebar-section {
    margin-bottom: var(--space-4);
}

.takeoff-wp-app .sidebar-label {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 var(--space-4) var(--space-2);
}

.takeoff-wp-app .sidebar-divider {
    height: 1px;
    background: var(--surface-overlay);
    margin: var(--space-2) var(--space-4);
    flex-shrink: 0;
}

.takeoff-wp-app .sidebar--collapsed .sidebar-divider {
    margin: var(--space-2) var(--space-3);
}

/* ── Project select ────────────────────────────────────────────────── */

.takeoff-wp-app .sidebar-select-wrap {
    padding: 0 var(--space-4);
    margin-bottom: var(--space-2);
}

.takeoff-wp-app .sidebar-select {
    width: 100%;
    height: 36px;
    background: var(--surface-overlay);
    color: var(--text-primary);
    border: none;
    border-radius: 8px;
    padding: 0 var(--space-3);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: pointer;
}

/* ── Project action icon buttons ───────────────────────────────────── */

/* Five 36px buttons in a 220px sidebar: no fixed gap — space-between
   distributes the remaining ~15px so the last button never clips */
.takeoff-wp-app .project-action-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
}

.takeoff-wp-app .sidebar-icon-btn {
    width: 36px;
    min-width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--surface-overlay);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    /* [ANTIGRAVITY FIX] Force above sidebar */
    position: relative;
    z-index: 4001;
    transition:
        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        background-color var(--duration-fast),
        border-color var(--duration-fast),
        color var(--duration-fast);
}

.takeoff-wp-app .sidebar-icon-btn:hover:not(:disabled) {
    background: var(--surface-overlay);
    color: var(--text-primary);
    transform: scale(1.13);
}

.takeoff-wp-app .sidebar-icon-btn:active:not(:disabled) {
    transform: scale(0.88);
    transition-duration: 0.07s;
}

.takeoff-wp-app .sidebar-icon-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Delete button specific styling */
.takeoff-wp-app .sidebar-icon-btn#delete-project-btn {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.takeoff-wp-app .sidebar-icon-btn#delete-project-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
}

/* Sync button enabled state - has new changes */
.takeoff-wp-app .sidebar-icon-btn.has-changes {
    animation: pulse-sync 2s infinite;
    background: rgba(34, 197, 94, 0.2);
    border-color: rgba(34, 197, 94, 0.5);
    color: #22c55e;
}

@keyframes pulse-sync {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

/* ── Nav items ─────────────────────────────────────────────────────── */

.takeoff-wp-app .sidebar-item {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-3);
    margin: 0 var(--space-3) 4px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: var(--text-body-size, 14px);
    color: var(--text-secondary);
    overflow: hidden;
    /* [ANTIGRAVITY FIX] Force above sidebar */
    position: relative;
    z-index: 4001;
    transition: background-color var(--duration-fast), color var(--duration-fast);
}

.takeoff-wp-app .sidebar-item:hover:not(.active) {
    background: var(--surface-elevated);
    color: var(--text-primary);
}

/* Active state = full accent-dim pill (no left border bar) */
.takeoff-wp-app .sidebar-item.active {
    background: var(--accent-dim);
    color: var(--text-primary);
}

.takeoff-wp-app .sidebar-item.active .sidebar-item-label {
    font-weight: 500;
}

.takeoff-wp-app .sidebar-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transform-origin: center 60%;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
}

.takeoff-wp-app .sidebar-item-icon i.ph {
    font-size: 22px;
    color: inherit;
}

.takeoff-wp-app .sidebar-item:hover .sidebar-item-icon {
    transform: scale(1.18);
}

.takeoff-wp-app .sidebar-item:active .sidebar-item-icon {
    transform: scale(0.88);
    transition-duration: 0.07s;
}

.takeoff-wp-app .sidebar-item.active .sidebar-item-icon {
    animation: tak-icon-breathe 2.8s ease-in-out infinite;
}

.takeoff-wp-app .sidebar-item.active:hover .sidebar-item-icon {
    animation: none;
    transform: scale(1.18);
}

@keyframes tak-icon-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}

.takeoff-wp-app .sidebar-item-label {
    margin-left: var(--space-3);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

/* ── History list ──────────────────────────────────────────────────── */

.takeoff-wp-app .sidebar-history-list {
    padding: 0 var(--space-4);
    color: var(--text-tertiary);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 105px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-overlay) transparent;
}

.takeoff-wp-app .sidebar-history-empty {
    font-style: italic;
    opacity: 0.5;
}

.takeoff-wp-app .history-entry {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}

.takeoff-wp-app .history-entry--current {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border-left: 2px solid var(--accent);
}

.takeoff-wp-app .history-entry--undone {
    opacity: 0.4;
    text-decoration: line-through;
}

/* ── Footer: user card ─────────────────────────────────────────────── */

.takeoff-wp-app .sidebar-bottom {
    padding: var(--space-3) 0 0;
    flex-shrink: 0;
}

.takeoff-wp-app .tak-user-section {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-3) var(--space-2);
    min-width: 0;
    overflow: hidden;
}

.takeoff-wp-app .tak-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.takeoff-wp-app .tak-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.takeoff-wp-app .tak-avatar-initials {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--on-accent);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    user-select: none;
}

.takeoff-wp-app .tak-avatar-status-dot {
    position: absolute;
    bottom: 0;
    right: -2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--status-active);
    border: 2px solid var(--surface-card);
    z-index: 2;
}

.takeoff-wp-app .tak-user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    flex-grow: 1;
    min-width: 0;
}

.takeoff-wp-app .tak-user-name {
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-body-size, 14px);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.takeoff-wp-app .tak-user-title {
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

/* ── Footer: action bar ────────────────────────────────────────────── */

.takeoff-wp-app .tak-sidebar-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--surface-overlay);
}

.takeoff-wp-app .tak-sidebar-ghost-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    transition:
        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        background-color var(--duration-fast),
        color var(--duration-fast);
}

.takeoff-wp-app .tak-sidebar-ghost-btn:hover {
    background: var(--surface-overlay);
    color: var(--text-primary);
    transform: scale(1.13);
}

.takeoff-wp-app .tak-sidebar-ghost-btn:active {
    transform: scale(0.88);
    transition-duration: 0.07s;
}

.takeoff-wp-app .tak-sidebar-ghost-btn i.ph {
    font-size: 18px;
    color: inherit;
}

.takeoff-wp-app #sidebar-collapse-btn {
    margin-left: auto;
}

.takeoff-wp-app .tak-logout-btn {
    color: #ef4444;
}

.takeoff-wp-app .tak-logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* ── Collapsed state ───────────────────────────────────────────────── */

.takeoff-wp-app .sidebar--collapsed .sidebar-wordmark,
.takeoff-wp-app .sidebar--collapsed .sidebar-label,
.takeoff-wp-app .sidebar--collapsed .sidebar-item-label,
.takeoff-wp-app .sidebar--collapsed .sidebar-select-wrap,
.takeoff-wp-app .sidebar--collapsed .sidebar-history-section,
.takeoff-wp-app .sidebar--collapsed .sidebar-collapse-hide,
.takeoff-wp-app .sidebar--collapsed .tak-user-info,
.takeoff-wp-app .sidebar--collapsed .tak-logout-btn {
    display: none;
}

.takeoff-wp-app .sidebar--collapsed .sidebar-item {
    justify-content: center;
    padding: 0;
    margin: 0 var(--space-2) 4px;
}

.takeoff-wp-app .sidebar--collapsed .project-action-row {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2) 0;
}

.takeoff-wp-app .sidebar--collapsed .tak-user-section {
    justify-content: center;
    padding: 0 0 var(--space-2);
}

.takeoff-wp-app .sidebar--collapsed .tak-sidebar-actions {
    flex-direction: column;
    align-items: center;
    padding: var(--space-2);
}

.takeoff-wp-app .sidebar--collapsed #sidebar-collapse-btn {
    margin-left: 0;
}

/* ── Reduced motion ────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .takeoff-wp-app .sidebar {
        transition: none;
    }

    .takeoff-wp-app .sidebar-item-icon,
    .takeoff-wp-app .sidebar-item.active .sidebar-item-icon {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }

    .takeoff-wp-app .sidebar-icon-btn,
    .takeoff-wp-app .tak-sidebar-ghost-btn {
        transition:
            background-color var(--duration-fast),
            border-color var(--duration-fast),
            color var(--duration-fast);
    }

    .takeoff-wp-app .sidebar-icon-btn:hover,
    .takeoff-wp-app .sidebar-icon-btn:active,
    .takeoff-wp-app .tak-sidebar-ghost-btn:hover,
    .takeoff-wp-app .tak-sidebar-ghost-btn:active {
        transform: none !important;
    }
}
