/**
 * Bookmark page and UI styling
 */

/* Bookmark Notice */
.bookmarks-notice {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background-color: var(--hover-color);
    border-radius: 6px;
    border-left: 3px solid var(--secondary-color);
}

.bookmarks-notice p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-color);
    opacity: 0.8;
    margin: 0;
}

/* Dark theme adjustments */
[data-theme="dark"] .bookmarks-notice {
    background-color: #2d3748;
    border-left-color: #4299e1;
}

[data-theme="dark"] .bookmarks-notice p {
    color: #e2e8f0;
}

/* Bookmark Indicator on Story Pages */
.bookmark-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 18px;
    display: none;
    z-index: 100;
    pointer-events: none;
}

.bookmark-indicator.visible {
    display: block;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.4);
    /* Create traditional ribbon bookmark with inverted V-notch using clip-path */
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% 80%, 0% 100%);
}

/* Fallback for browsers that don't support clip-path */
@supports not (clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 50% 80%, 0% 100%)) {
    .bookmark-indicator.visible {
        border-radius: 2px 2px 0 0;
    }
    
    .bookmark-indicator.visible::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 0;
        border-left: 8px solid transparent;
        border-right: 8px solid transparent;
        border-top: 5px solid #2980b9;
    }
}

/* Add subtle gradient highlight for depth */
.bookmark-indicator.visible::before {
    content: '';
    position: absolute;
    top: 0;
    left: 1px;
    right: 1px;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    border-radius: 1px 1px 0 0;
}

/* Bookmarked dialog block styling */
.dialog-block.bookmarked {
    border-left: 3px solid #3498db;
    background-color: rgba(52, 152, 219, 0.02);
}

/* Make dialog blocks clickable and positioned for absolute children */
.dialog-block {
    transition: border-left 0.3s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    position: relative !important;
    /* Ensure this element serves as positioned ancestor for bookmark indicator */
    z-index: 1;
}

.dialog-block:hover {
    background-color: var(--hover-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Dark mode styles */
[data-theme="dark"] .bookmark-indicator.visible {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    box-shadow: 0 2px 4px rgba(66, 153, 225, 0.4);
}

[data-theme="dark"] .bookmark-indicator.visible::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

/* Dark mode fallback for browsers that don't support clip-path */
@supports not (clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 50% 90%, 0% 75%)) {
    [data-theme="dark"] .bookmark-indicator.visible::after {
        border-top-color: #3182ce;
    }
}

[data-theme="dark"] .dialog-block.bookmarked {
    border-left: 3px solid #4299e1;
    background-color: rgba(66, 153, 225, 0.05);
}

/* Bookmark Notifications */
.bookmark-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-background);
    color: var(--text-color);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    font-size: 14px;
    max-width: 300px;
}

.bookmark-notification.show {
    transform: translateX(0);
}

/* Bookmarks Page */
.bookmarks-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.bookmarks-header {
    text-align: center;
    margin-bottom: 30px;
}

.bookmarks-header h1 {
    color: var(--text-color);
    margin-bottom: 10px;
}

.bookmarks-description {
    color: var(--text-color-secondary);
    font-size: 16px;
    max-width: 600px;
    margin: 0 auto;
}

/* Bookmarks Controls */
.bookmarks-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px 20px;
    background: var(--card-background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.bookmarks-stats {
    font-size: 16px;
    color: var(--text-color);
}

.bookmark-count strong {
    color: var(--accent-color);
}

.bookmarks-actions {
    display: flex;
    gap: 10px;
}

.btn-danger {
    background: #e53e3e;
    color: white;
    border: 1px solid #e53e3e;
}

.btn-danger:hover {
    background: #c53030;
    border-color: #c53030;
}

/* Search */
.bookmarks-search {
    margin-bottom: 30px;
}

#bookmark-search {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    background: var(--card-background);
    color: var(--text-color);
}

#bookmark-search:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Bookmarks List */
.bookmarks-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.bookmark-item {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bookmark-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bookmark-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.bookmark-date {
    font-size: 12px;
    color: var(--text-color-secondary);
}

.bookmark-delete {
    background: none;
    border: none;
    color: var(--text-color-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.bookmark-delete:hover {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
}

.bookmark-path {
    font-size: 14px;
    color: var(--accent-color);
    margin-bottom: 8px;
}

.bookmark-path a {
    color: var(--accent-color);
    text-decoration: none;
}

.bookmark-path a:hover {
    text-decoration: underline;
}

.bookmark-speaker {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.bookmark-content {
    color: var(--text-color);
    line-height: 1.6;
    font-size: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* No Bookmarks */
.no-bookmarks {
    display: none;
    text-align: center;
    padding: 60px 20px;
}

.no-bookmarks.visible {
    display: block;
}

.no-bookmarks-content {
    max-width: 400px;
    margin: 0 auto;
}

.no-bookmarks-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.no-bookmarks h3 {
    color: var(--text-color);
    margin-bottom: 10px;
}

.no-bookmarks p {
    color: var(--text-color-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Dialog */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.dialog {
    background: var(--card-background);
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.dialog-header {
    padding: 20px 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.dialog-header h3 {
    color: var(--text-color);
    margin: 0 0 20px 0;
}

.dialog-content {
    padding: 0 20px;
    color: var(--text-color);
    line-height: 1.6;
}

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .bookmarks-page {
        padding: 15px;
    }
    
    .bookmarks-controls {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .bookmarks-actions {
        justify-content: center;
    }
    
    .bookmarks-list {
        grid-template-columns: 1fr;
    }
    
    .bookmark-meta {
        flex-direction: column;
        gap: 5px;
    }
    
    .bookmark-delete {
        align-self: flex-end;
    }
    
    .dialog {
        margin: 20px;
    }
    
    .dialog-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-secondary,
    .btn-danger {
        width: 100%;
    }
}