/* Multi-page navigation and management */

/* Page navigation bar */
.page-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-md);
    z-index: 1001;
}

.page-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: none;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    min-height: 50px;
}

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

/* Individual page tab */
.page-tab {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    cursor: grab;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 160px;
    max-width: 320px;
    box-shadow: none;
    user-select: none;
}

.page-tab:active {
    cursor: grabbing;
}

.page-tab.dragging {
    opacity: 0.8;
    transform: scale(1.05);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: var(--color-bg);
}

.page-tab:hover {
    background: var(--color-hover);
}

.page-tab.active {
    background: var(--color-bg);
    border-bottom-color: var(--color-bg);
    position: relative;
    z-index: 2;
}

.page-tab-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.page-tab-menu,
.page-tab-close {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0.6;
    transition: all 0.2s ease;
}

.page-tab-close {
    margin-left: var(--spacing-xs);
    margin-right: var(--spacing-xs);
}

.page-tab-menu:hover,
.page-tab-close:hover {
    opacity: 1;
    background: var(--color-hover);
}

.page-tab-close:hover {
    background: var(--color-error);
    color: white;
}

/* Add page button */
.add-page-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: transparent;
    color: #8b7070;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 300;
    transition: all 0.2s ease;
    margin-left: var(--spacing-xs);
}

.add-page-btn:hover {
    background: var(--color-blue-accent-light);
    color: var(--color-blue-accent);
    transform: none;
}

/* Page settings menu */
.page-menu {
    position: fixed;
    top: 50px;
    right: 0;
    width: 320px;
    height: calc(100vh - 50px);
    background: white;
    border-left: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.page-menu:not(.hidden) {
    transform: translateX(0);
}

.page-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    background: var(--color-bg-secondary);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
    font-weight: 600;
    color: var(--color-text);
}

.page-menu-content {
    padding: var(--spacing-lg);
}

/* Settings form */
.setting-group {
    margin-bottom: var(--spacing-lg);
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text);
}

.setting-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: white;
    transition: border-color 0.2s ease;
}

.setting-input:focus {
    outline: none;
    border-color: var(--color-blue-accent);
    box-shadow: 0 0 0 2px var(--color-blue-accent-light);
}

textarea.setting-input {
    resize: vertical;
    min-height: 80px;
}

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 400;
}

.setting-checkbox {
    width: 18px;
    height: 18px;
    margin-right: var(--spacing-sm);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label span {
    user-select: none;
}

/* Delete page button */
.delete-page-btn {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--color-error);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-page-btn:hover {
    background: #d4654c;
    transform: translateY(-1px);
}

/* Adjust main content for page nav */
.canvas {
    padding-top: calc(50px + var(--spacing-xl));
}

/* Adjust fixed elements for page nav */
.project-name-container {
    top: calc(50px + var(--spacing-md));
}

.export-btn,
.clear-btn {
    top: calc(50px + var(--spacing-md));
}

/* Tablet adjustments */
@media (max-width: 1024px) and (min-width: 769px) {
    .page-tab {
        min-width: 140px;
        max-width: 260px;
        padding: var(--spacing-sm) var(--spacing-md);
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .page-nav {
        padding: 0 var(--spacing-sm);
    }
    
    .page-tab {
        min-width: 120px;
        max-width: 180px;
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    .page-tab-title {
        font-size: 12px;
    }
    
    .page-menu {
        width: 100vw;
    }
    
    .add-page-btn {
        width: 20px;
        height: 20px;
        font-size: 16px;
    }
}