/* ==========================================================================
   Dynamic Island Floating Bottom Dock & Vertical Morphing Stack
   Matches Apple Dynamic Island + Spring Physics Specification
   ========================================================================== */

/* Outer Dock Container (Fixed Floating Island) */
.dock-container {
    position: fixed;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 440px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Backdrop for closing dropdown on outside tap - Transparent so no dark tint shows */
.dock-backdrop {
    position: fixed;
    inset: 0;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    z-index: 4990;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s;
}

.dock-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Dock Bar: 2 Floating Capsules */
.dock-bar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    position: relative;
    z-index: 5005;
}

/* Island 1: Main 3 Navigation Tabs */
.dock-island-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid rgba(220, 230, 245, 0.95);
    border-radius: 100px;
    box-shadow: 
        0 16px 40px -6px rgba(14, 27, 51, 0.22),
        0 4px 14px rgba(0, 0, 0, 0.08),
        inset 0 1px 1.5px rgba(255, 255, 255, 1),
        inset 0 -1px 1px rgba(0, 0, 0, 0.03);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.dark-theme .dock-island-main {
    background: rgba(14, 15, 22, 0.94);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 
        0 18px 45px -6px rgba(0, 0, 0, 0.85),
        0 4px 16px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.12);
}

/* Dynamic Island Spring Physics & Breathing Tab Icon */
@keyframes dockTabSpring {
    0% {
        transform: scale(0.90);
    }
    55% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes dockIconBreathe {
    0% {
        transform: scale(0.85);
    }
    55% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

.dock-tab {
    flex: 1;
    height: 44px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), 
                color 0.2s ease, 
                transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), 
                box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
}

.dock-tab svg {
    stroke-width: 2.2px;
}

.dark-theme .dock-tab {
    color: #CBD5E1;
}

.dock-tab:hover {
    color: var(--primary, #2451C4);
    transform: scale(1.05);
}

.dock-tab:active {
    transform: scale(0.92);
}

.dock-tab.active {
    background: var(--primary, #2451C4);
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(36, 81, 196, 0.35);
    animation: dockTabSpring 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dark-theme .dock-tab.active {
    background: #3B82F6;
    color: #ffffff !important;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.45);
    animation: dockTabSpring 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dock-tab.active svg {
    animation: dockIconBreathe 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Island 2: Standalone Action Split Button */
.dock-island-action {
    display: flex;
    align-items: center;
    padding: 6px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid rgba(220, 230, 245, 0.95);
    border-radius: 100px;
    box-shadow: 
        0 16px 40px -6px rgba(14, 27, 51, 0.22),
        0 4px 14px rgba(0, 0, 0, 0.08),
        inset 0 1px 1.5px rgba(255, 255, 255, 1),
        inset 0 -1px 1px rgba(0, 0, 0, 0.03);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.dark-theme .dock-island-action {
    background: rgba(14, 15, 22, 0.94);
    backdrop-filter: blur(28px) saturate(200%);
    -webkit-backdrop-filter: blur(28px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 
        0 18px 45px -6px rgba(0, 0, 0, 0.85),
        0 4px 16px rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.12);
}

.dock-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 100px;
    border: 1px solid rgba(14, 27, 51, 0.1);
    background: rgba(14, 27, 51, 0.06);
    color: #1E293B;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    transition: all 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

.dark-theme .dock-action-btn {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.16);
    color: #F8FAFC;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

.dock-action-btn:hover {
    transform: scale(1.06);
    background: rgba(36, 81, 196, 0.12);
    color: var(--primary, #2451C4);
    border-color: rgba(36, 81, 196, 0.25);
}

.dock-action-btn:active {
    transform: scale(0.92);
}

/* Icon Morph Wrap */
.dock-action-icon-wrap {
    width: 20px;
    height: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dock-icon-apps,
.dock-icon-close {
    position: absolute;
    inset: 0;
    transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dock-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

/* When Action Button is OPEN (Active Morph State) */
.dock-action-btn.open {
    background: #EF4444 !important;
    color: #ffffff !important;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.45);
    transform: scale(1.05);
}

.dock-action-btn.open .dock-action-icon-wrap {
    transform: rotate(90deg);
}

.dock-action-btn.open .dock-icon-apps {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.dock-action-btn.open .dock-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ==========================================================================
   Vertical Morphing Stack (Framer Motion Inspired Spring Animation)
   ========================================================================== */
.dock-apps-stack {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    width: min(290px, calc(100vw - 28px));
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5010;
    pointer-events: none;
    transform-origin: bottom right;

    /* Initial Collapsed State */
    opacity: 0;
    transform: scale(0.65) translateY(24px);
    filter: blur(10px);
    transition:
        opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        filter 0.3s ease;
}

/* Open State */
.dock-apps-stack.open {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0px);
    pointer-events: auto;
}

/* Individual App Card - Solid crisp background */
.dock-app-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 20px;
    background: #ffffff !important;
    border: 1px solid rgba(14, 27, 51, 0.09);
    box-shadow: 
        0 14px 34px -4px rgba(20, 40, 90, 0.16),
        0 2px 8px rgba(0, 0, 0, 0.04);
    text-decoration: none;
    color: var(--ink, #0E1B33);
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.dark-theme .dock-app-card {
    background: #0E0E12 !important;
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 
        0 18px 40px -4px rgba(0, 0, 0, 0.8),
        0 2px 8px rgba(0, 0, 0, 0.6);
}

.dock-app-card:hover {
    transform: scale(1.03) translateY(-2px);
    background: #f8faff !important;
    border-color: rgba(36, 81, 196, 0.35);
    box-shadow: 0 18px 40px -4px rgba(36, 81, 196, 0.22);
}

.dark-theme .dock-app-card:hover {
    background: #16161C !important;
    border-color: rgba(59, 130, 246, 0.4);
}

.dock-app-card:active {
    transform: scale(0.97);
}

/* App Icon Box */
.dock-app-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.dock-app-card:hover .dock-app-icon {
    transform: scale(1.1);
}

.dock-app-icon.calc {
    background: linear-gradient(135deg, #10B981, #059669);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.dock-app-icon.cover {
    background: linear-gradient(135deg, #2563EB, #1D4ED8);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.dock-app-icon.portfolio {
    background: linear-gradient(135deg, #8B5CF6, #6D28D9);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

/* App Info */
.dock-app-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.dock-app-title {
    font-size: 13.5px;
    font-weight: 750;
    color: var(--ink, #0E1B33);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}

.dark-theme .dock-app-title {
    color: #F3F6FC;
}

.dock-app-sub {
    font-size: 11px;
    color: var(--ink-soft, #5C6B8A);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.dark-theme .dock-app-sub {
    color: #93A2C2;
}

.dock-app-arrow {
    color: var(--ink-faint, #93A2C2);
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.dock-app-card:hover .dock-app-arrow {
    color: var(--primary, #2451C4);
    transform: translateX(3px);
}

/* Completely suppress and remove old flat bottom nav */
.bottom-nav,
.has-dock-nav .bottom-nav {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    pointer-events: none !important;
}

/* Responsive Hide on Desktop */
@media (min-width: 769px) {
    .dock-container,
    .dock-backdrop {
        display: none !important;
    }
}

/* Natural Mobile Flow: Content flows behind floating dock without solid white block */
@media (max-width: 768px) {
    body.has-dock-nav:not(:has(#map)):not(:has(#historyMap)) {
        height: auto !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding-bottom: 0 !important;
    }

    .has-dock-nav .dash-content:not(:has(#map)):not(:has(#historyMap)),
    .has-dock-nav .container,
    .has-dock-nav .lost-found-container,
    .has-dock-nav .profile-container {
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 10px)) !important;
    }
    .has-dock-nav .main-wrapper {
        padding-bottom: 0 !important;
    }
}

/* ==========================================================================
   Defensive Nav Items Suppression (Prevent Ghost/Orphaned Nav Items)
   ========================================================================== */
body > .nav-item,
.has-dock-nav > .nav-item,
.dash-content > .nav-item,
.main-wrapper > .nav-item,
.container > .nav-item,
[onclick*="schedule.html"]:not(.dock-tab):not(.nav-btn):not(.dock-app-card):not(.menu-item),
[onclick*="profile.html"]:not(.dock-tab):not(.nav-btn):not(.dock-app-card):not(.menu-item) {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    position: absolute !important;
    z-index: -9999 !important;
}
