/* ==========================================================================
   Highlights UI - Toolbar and menus for text highlighting
   ========================================================================== */

/* ==============================================================================
   Highlight Toolbar (shown on text selection)
   ============================================================================== */

.highlight-toolbar {
    position: fixed;
    z-index: 10000;
    display: flex;
    gap: 4px;
    padding: 8px;
    background: #2a2a3e;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transition: opacity 0.15s ease;
}

.highlight-toolbar.hidden {
    display: none;
}

.highlight-toolbar-colors {
    display: flex;
    gap: 6px;
}

.highlight-color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.1s ease;
}

.highlight-color-btn:hover {
    transform: scale(1.15);
}

.highlight-color-btn:active {
    transform: scale(0.95);
}

.highlight-color-btn.selected {
    border-color: #fff;
}


/* ==============================================================================
   Highlight Options Menu (shown when clicking existing highlight)
   ============================================================================== */

.highlight-options-menu {
    position: fixed;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: #2a2a3e;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    min-width: 180px;
}

.highlight-menu-colors {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.highlight-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.highlight-action-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-align: left;
}

.highlight-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.highlight-delete-btn {
    color: #ff6b6b;
}

.highlight-delete-btn:hover {
    background: rgba(255, 107, 107, 0.2);
}


/* ==============================================================================
   Toast Notification
   ============================================================================== */

.highlight-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10002;
    padding: 12px 24px;
    background: #333;
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: toast-in 0.3s ease;
}

.highlight-toast.fade-out {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}


/* ==============================================================================
   Mobile Optimizations
   ============================================================================== */

@media (max-width: 600px) {
    .highlight-toolbar {
        padding: 10px;
    }

    .highlight-color-btn {
        width: 40px;
        height: 40px;
    }

    .highlight-options-menu {
        min-width: 200px;
    }

    .highlight-action-btn {
        padding: 12px 16px;
        font-size: 16px;
    }
}


/* ==============================================================================
   Sepia and Light theme adjustments
   ============================================================================== */

body.theme-sepia .highlight-toolbar,
body.theme-sepia .highlight-options-menu {
    background: #5c4b3a;
}

body.theme-light .highlight-toolbar,
body.theme-light .highlight-options-menu {
    background: #f5f5f5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.theme-light .highlight-action-btn {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

body.theme-light .highlight-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}


/* ==============================================================================
   Highlights Library View
   ============================================================================== */

.highlights-library {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

.highlights-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.highlights-library-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.highlights-library-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
}

.highlights-library-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.highlights-library-loading,
.highlights-library-empty,
.highlights-library-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.highlights-library-empty-hint,
.highlights-library-error-hint {
    margin-top: 8px;
    font-size: 14px;
    opacity: 0.7;
}

.highlights-library-section {
    margin-bottom: 32px;
}

.highlights-library-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 16px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.highlights-library-book-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.highlights-library-book-author {
    font-size: 14px;
    color: var(--text-secondary);
}

.highlights-library-count {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-left: auto;
}

.highlights-library-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.highlights-library-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 16px;
    border-left: 4px solid #fdd835;
    transition: background 0.15s ease;
}

.highlights-library-card:hover {
    background: var(--bg-hover);
}

.highlights-library-text {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.highlights-library-note {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 8px;
    padding-left: 12px;
    border-left: 2px solid var(--border-color);
}

.highlights-library-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.highlights-library-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.highlights-library-btn {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.highlights-library-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.highlights-library-delete-btn {
    color: #ff6b6b;
}

.highlights-library-delete-btn:hover {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}


/* ==============================================================================
   Highlights Library - Theme adjustments
   ============================================================================== */

body.theme-light .highlights-library-card {
    background: #f8f8f8;
}

body.theme-light .highlights-library-card:hover {
    background: #f0f0f0;
}

body.theme-light .highlights-library-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

body.theme-light .highlights-library-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #333;
}

body.theme-sepia .highlights-library-card {
    background: #e8dcc8;
}

body.theme-sepia .highlights-library-card:hover {
    background: #dfd3bf;
}


/* ==============================================================================
   Highlights Library - Mobile
   ============================================================================== */

@media (max-width: 600px) {
    .highlights-library-content {
        padding: 16px;
    }

    .highlights-library-card {
        padding: 14px;
    }

    .highlights-library-text {
        font-size: 14px;
    }

    .highlights-library-btn {
        padding: 8px 14px;
        font-size: 14px;
    }
}
