/* Framework7 Overrides & Customizations */
:root {
    --f7-theme-color: #007aff;
    --f7-theme-color-rgb: 0, 122, 255;
    --f7-theme-color-shade: #0066d6;
    --f7-theme-color-tint: #298dff;

    /* iOS standard background */
    --f7-page-bg-color: #f2f2f7;
    --f7-bars-bg-color: rgba(249, 249, 249, 0.9);
}

.dark,
:root.dark {
    --f7-page-bg-color: #000000;
    --f7-bars-bg-color: #1c1c1e;
    --f7-list-bg-color: #1c1c1e;
}

body {
    -webkit-font-smoothing: antialiased;
    font-family: 'SF Pro Display', 'SF Pro Text', -apple-system, system-ui, sans-serif;
}

/* Matrix Background - Placed behind everything */
#matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.15;
    pointer-events: none;
}

.dark #matrix-bg,
:root.dark #matrix-bg {
    opacity: 0.2;
}

/* Transparent Navbar - Remove background */
.navbar {
    --f7-navbar-bg-color: transparent;
    --f7-navbar-border-color: transparent;
}

.navbar-bg {
    display: none !important;
}

/* Custom Shortcut Card Styling to look native */
.shortcut-container {
    display: flex;
    flex-direction: column;
}

/* Ensure icons in list views look good */
.item-media .f7-icons {
    font-size: 28px;
}

/* Shortcut Card styling for Tools page */
.shortcut-card {
    background-color: var(--f7-list-bg-color, #ffffff);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    margin-bottom: 8px;
}

.dark .shortcut-card {
    background-color: #1c1c1e;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.shortcut-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: #f2f2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
}

.dark .shortcut-icon-wrapper {
    background-color: #2c2c2e;
}

.shortcut-body {
    font-size: 15px;
    font-weight: 600;
    color: var(--f7-text-color);
}

.variable-pill {
    background-color: rgba(0, 122, 255, 0.15);
    color: #007aff;
    padding: 2px 8px;
    border-radius: 6px;
    margin: 0 4px;
    font-weight: 500;
    font-size: 14px;
}

/* Grid for the icon */
.mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    width: 20px;
    height: 20px;
    gap: 2px;
}

.grid-dot {
    border-radius: 2px;
    width: 100%;
    height: 100%;
}

.c1 {
    background: #ff3b30
}

.c2 {
    background: #ff9500
}

.c3 {
    background: #ffcc00
}

.c4 {
    background: #34c759
}

.c5 {
    background: #5ac8fa
}

.c6 {
    background: #007aff
}

.c7 {
    background: #5856d6
}

.c8 {
    background: #af52de
}

.c9 {
    background: #ff2d55
}

/* Connector Lines for the visualization */
.indent-line {
    position: absolute;
    left: 29px;
    top: 30px;
    bottom: 0;
    width: 4px;
    background-color: #e5e5ea;
    z-index: 1;
}

.dark .indent-line {
    background-color: #38383a;
}

.shortcut-indent-wrapper {
    position: relative;
    padding-bottom: 10px;
}

.nested-row {
    margin-left: 46px;
    margin-top: 10px;
    margin-bottom: 10px;
    position: relative;
}

.nested-connector {
    position: absolute;
    left: -17px;
    top: 50%;
    width: 17px;
    height: 4px;
    background-color: #e5e5ea;
    transform: translateY(-50%);
    border-bottom-right-radius: 4px;
}

.dark .nested-connector {
    background-color: #38383a;
}

/* IOS 26 Tab Bar Style (Floating Glass Pill) */
.toolbar.tabbar-icons.toolbar-bottom,
.toolbar.tabbar-labels.toolbar-bottom {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    margin: 0 auto;

    z-index: 5000;

    /* Remove default toolbar background */
    --f7-toolbar-bg-color: transparent;
    --f7-toolbar-border-color: transparent;
    background: transparent !important;

    border-top: none;
    box-shadow: none;

    display: flex;
    justify-content: center;
    align-items: center;

    --f7-toolbar-inner-padding-left: 0;
    --f7-toolbar-inner-padding-right: 0;

    /* Smooth hide/show transition */
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hide the default toolbar background element */
.toolbar.tabbar-icons.toolbar-bottom::before,
.toolbar.tabbar-labels.toolbar-bottom::before {
    display: none !important;
}

/* The floating pill styling applied to toolbar-pane */
.toolbar-pane {
    background: rgba(28, 28, 30, 0.85);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    border-radius: 28px;
    padding: 6px 10px;
    display: flex;
    gap: 6px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

:root:not(.dark) .toolbar-pane {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Hidden state when scrolling down */
.toolbar.toolbar-hidden {
    transform: translateY(120px);
    opacity: 0;
    pointer-events: none;
}

.toolbar.tabbar-icons.toolbar-bottom .toolbar-inner,
.toolbar.tabbar-labels.toolbar-bottom .toolbar-inner {
    justify-content: space-evenly;
    width: 100%;
    padding: 6px;
    gap: 8px;
}

:root:not(.dark) .toolbar.tabbar-icons.toolbar-bottom,
:root:not(.dark) .toolbar.tabbar-labels.toolbar-bottom {
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.tab-link {
    color: #8E8E93;
    background: transparent;
    height: 100%;
    max-height: 52px;
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

/* Active State - The 'Grey Pill' Background */
.tab-link-active {
    color: #007aff;
    background: rgba(255, 255, 255, 0.15);
}

/* Light mode active background */
:root:not(.dark) .tab-link-active {
    background: rgba(0, 0, 0, 0.05);
}

/* Remove safe-area padding since we are floating above it */
.toolbar-bottom .toolbar-inner {
    padding-bottom: 0;
}

/* Gear Spin Animation */
@keyframes gearSpin {
    0% {
        transform: rotate(0deg);
    }

    60% {
        transform: rotate(360deg);
    }

    75% {
        transform: rotate(340deg);
    }

    85% {
        transform: rotate(365deg);
    }

    92% {
        transform: rotate(355deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.gear-spin {
    animation: gearSpin 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Main Persistent Popup Styling */
.popup-main {
    /* Mobile: Fullscreen Opaque */
    width: 100%;
    height: 100%;
    border-radius: 0;
    margin: 0;

    left: 0 !important;
    top: 0 !important;
    transform: none !important;

    /* Solid Background - Default F7 or Black */
    background: var(--f7-popup-bg-color, #000) !important;
    box-shadow: none;

    /* Optimization */
    will-change: transform, opacity;
}

/* Force inner views/pages to be solid/default */
.popup-main .view,
.popup-main .page {
    background: var(--f7-page-bg-color, #000) !important;
}

/* Remove transparency overlap fix since we are solid now */
/* .popup-main .page-previous { visibility: hidden !important; } - Removed */

.popup-main .view {
    border-radius: 0;
    width: 100%;
    height: 100%;
}

/* Tablet/Desktop: Floating Layout */
@media (min-width: 768px) {
    .popup-main.popup-tablet-fullscreen {
        width: 600px;
        height: 80vh;
        max-height: 800px;
        border-radius: 20px;

        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;

        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    }

    .popup-main .view {
        border-radius: 20px;
        overflow: hidden;
    }
}

/* Global Background & Transparency */
html,
#app,
.view-main {
    background: transparent !important;
    background-color: transparent !important;
}

/* Background Image with Blur & Tint */
body {
    background: #000;
    min-height: 100vh;
    overflow: hidden;
    /* Prevent body scroll */
    margin: 0;
}

body::before {
    content: "";
    position: fixed;
    top: -50px;
    left: -50px;
    right: -50px;
    bottom: -50px;
    /* Oversize for blur edges */
    background: url('tahoe.jpeg') no-repeat center center;
    background-size: cover;
    filter: blur(40px) brightness(0.4);
    /* Heavy blur + Dark tint (Darker per request) */
    z-index: -10;
}

/* Animations: "Everything Loading" */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-content,
.navbar .title,
.navbar .right,
.block,
.list {
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}