/* App Shell Layout */
body {
    padding: 0;
    /* Override base.css padding for shell */
    overflow: hidden;
    /* Prevent body scroll */
}

.layout {
    display: flex;
    flex-direction: row;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

nav {
    width: 280px;
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100%;
    z-index: 10;
}

main {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Sidebar Components */
.topbar {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg);
}

.logo {
    height: 10vw;
    width: auto;
}

.row-select {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.row-select select {
    width: 140px;
}

.search {
    position: relative;
}

.search input {
    width: 100%;
    padding-left: 32px;
}

.search svg {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.nav-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.nav-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.nav-controls button.small {
    font-size: 11px;
    padding: 4px 8px;
}

.nav-cat {
    margin-bottom: 8px;
}

.nav-cat summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--muted);
    padding: 4px 0;
    user-select: none;
}

.nav-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 12px;
    margin-top: 4px;
}

.tool-link {
    display: block;
    padding: 6px 12px;
    text-decoration: none;
    color: var(--fg);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.tool-link:hover {
    background: var(--border);
}

.feedback-link {
    padding: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
    text-align: center;
    background: var(--bg);
}

.feedback-link:hover {
    color: var(--accent);
}

/* Main Content Area - Prevent Layout Shift */
#targetIframe {
    width: 100%;
    height: 100%;
    border: none;
    display: none;
}

#splash {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

#splash img {
    width: 80px;
    height: 80px;
    opacity: 0.5;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
    }
}

/* Responsive Sidebar */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }

    nav {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .nav-scroll {
        display: none;
        /* Hide full list on mobile, rely on dashboard */
    }
}

/* Dashboard Layout */
#dashboard {
    padding: 24px;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Search Section */
.dash-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.dash-search {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.dash-search input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    font-size: 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.dash-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-alpha, rgba(58, 134, 255, 0.2));
}

.dash-search svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--muted);
}

/* Category Tabs */
.dash-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    width: 100%;
    justify-content: center;
    scrollbar-width: none;
    /* Firefox */
}

.dash-tabs::-webkit-scrollbar {
    display: none;
}

/* Chrome/Safari */

.dash-tab {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.dash-tab:hover {
    background: color-mix(in srgb, var(--bg) 95%, var(--fg) 5%);
    color: var(--fg);
}

.dash-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    width: 100%;
}

/* Tool Card */
.tool-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    cursor: pointer;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border-color: var(--accent);
}

.tool-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.tool-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--fg);
    margin: 0;
}

.tool-desc {
    font-size: 13px;
    color: var(--muted);
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tool-footer {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

.tool-btn {
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    padding: 6px 12px;
    border-radius: 6px;
    transition: background 0.2s;
}

.tool-card:hover .tool-btn {
    background: var(--accent);
    color: white;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .dash-tabs {
        justify-content: flex-start;
        padding-left: 4px;
        padding-right: 4px;
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
        /* Single column on mobile if very narrow, or 2 if space permits */
    }
}

@media (min-width: 640px) {
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .tools-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .tools-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}