/* Header and navigation styles */

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-color);
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    transition: background-color 300ms, transform 300ms ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header.hide-header {
    transform: translateY(-100%);
}

.dark .app-header {
    box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

.header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-container {
    position: relative;
    display: flex;
    align-items: left;
    gap: 0.5rem;
}

/* Button base styles are provided by /styles/components.css */
/* Ensure icon-only buttons match the standard 40px button height */
.settings-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 8px; /* smaller padding for icon */
}
.bookmark-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 8px;
}

/* Ensure icons inside the small square buttons are readable */
.settings-button .icon,
.bookmark-button .icon {
    width: 1.25rem;
    height: 1.25rem;
    display: block; /* avoid inline baseline alignment quirks */
}

.toc-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.bookmark-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    min-width: 150px;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.menu-item {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    transition: background-color 300ms;
    text-align: left;
}

.menu-item:hover {
    background-color: rgba(128, 128, 128, 0.1);
}

.menu-item:last-child {
    border-bottom: none;
}

.settings-window {
    position: fixed;
    top: 4rem;
    left: 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1002;
    padding: 1rem;
    min-width: 200px;
    display: none;
}

.bookmark-window {
    position: fixed;
    top: 4rem;
    left: 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1002;
    padding: 1rem;
    min-width: 260px;
    max-width: 80vw;
    display: none;
}

.toc-floating-window {
    position: fixed;
    top: 4rem;
    left: 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--text-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1002;
    padding: 1rem;
    min-width: 200px;
    display: none;
}

.settings-window.show, .toc-floating-window.show, .bookmark-window.show {
    display: block;
}

.settings-window h3, .toc-floating-window h3, .bookmark-window h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.bookmark-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.bookmark-list-container {
    max-height: 60vh;
    overflow-y: auto;
}

.bookmark-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bookmark-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}

.bookmark-item:last-child {
    border-bottom: none;
}

.bookmark-jump {
    font-size: 1rem; /* override any global button font-size rules */
    line-height: 1.3;
    flex: 1 1 auto;
    text-align: left;
    color: var(--text-color);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background-color 300ms;
}

.bookmark-jump:hover {
    background-color: rgba(128, 128, 128, 0.1);
}

.bookmark-delete {
    background: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    border-radius: 4px;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    aspect-ratio: 1 / 1; /* keep width equal to height */
}
.bookmark-delete .icon {
    width: 16px;
    height: 16px;
}

.theme-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Install app button row */
.install-app-row {
    margin-bottom: 0.75rem;
}
.install-app-button {
    width: 100%;
}

/* .theme-button base and hover styles provided by components.css */

/* Ensure all buttons inside windows render at 1rem */
.settings-window button,
.toc-floating-window button,
.bookmark-window button {
    font-size: 1rem;
}
/* Settings rows */
.settings-item {
    margin-top: 0.5rem;
}
.settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    user-select: none;
    cursor: pointer;
}
.settings-toggle input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
}

.toc-content {
    max-height: 60vh;
    overflow-y: auto;
}

.toc-content ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.toc-content li {
    margin: 0.25rem 0;
}

.toc-content a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 0.25rem 0;
    border-radius: 2px;
    transition: background-color 300ms;
}

.toc-content a:hover {
    background-color: rgba(128, 128, 128, 0.1);
}

@media (max-width: 768px) {
    .header-left {
        gap: 0.5rem;
    }
    
    .menu-button, .toc-button, .settings-button, .bookmark-button {
        padding: 0.4rem 0.8rem;
        font-size: 1rem;
    }
    .settings-button {
        width: 40px;
        height: 40px;
        padding: 0.4rem;
    }
    .bookmark-button {
        width: 40px;
        height: 40px;
        padding: 0.4rem;
    }
    /* Keep icons comfortably sized on small screens */
    .settings-button .icon,
    .bookmark-button .icon {
        width: 1.25rem;
        height: 1.25rem;
    }
}
