/* WordPress Annotation Tool - Frontend Styles */

/* Full layout for shortcode usage */
.wat-shortcode.wat-annotation-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* Minimal layout for content filter usage */
.wat-annotation-container:not(.wat-shortcode) {
    position: relative;
}

.wat-annotation-container:not(.wat-shortcode) .wat-main-content {
    display: block;
}

.wat-annotation-container:not(.wat-shortcode) .wat-sidebar {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    z-index: 9998;
    display: none; /* Hidden by default, shown by JavaScript when needed */
}

.wat-main-content {
    min-width: 0; /* Prevents overflow in grid */
}

/* Only apply article styling when used with shortcode, not content filter */
.wat-shortcode .wat-article {
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

/* Only apply article header styling when used with shortcode */
.wat-shortcode .wat-article-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.wat-shortcode .wat-article-header h1 {
    margin: 0 0 15px 0;
    font-size: 2rem;
    line-height: 1.2;
    color: #1f2937;
}

.wat-shortcode .wat-article-meta {
    display: flex;
    gap: 15px;
    color: #6b7280;
    font-size: 14px;
}

.wat-article-content {
    /* Inherit theme typography - don't override */
}

/* Annotation Highlighting */
.wat-annotation {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 2px;
    padding: 1px 2px;
    text-decoration: none;
}

.wat-annotation:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.wat-annotation.active {
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}

/* Hover Card */
.wat-hover-card {
    position: fixed;
    background: var(--wat-hover-card-bg, #ffffff);
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 9999;
    max-width: 300px;
    transform: translateX(-50%);
    pointer-events: none;
}

.wat-hover-card-tag {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    margin-bottom: 8px;
}

.wat-hover-card-text {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.4;
}

/* Sidebar */
.wat-sidebar {
    background: var(--wat-sidebar-bg, #f9fafb);
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0;
    height: fit-content;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

/* Draggable Widget Styles */
.wat-draggable-widget {
    position: fixed !important;
    top: 20px;
    right: 20px;
    width: 320px;
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.2s ease;
}

.wat-draggable-widget.wat-dragging {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    z-index: 10000;
}

.wat-draggable-widget.wat-minimized {
    height: auto;
}

.wat-draggable-widget.wat-minimized .wat-sidebar-content {
    display: none;
}

/* Widget Header */
.wat-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    padding: 8px 12px;
    border-radius: 8px 8px 0 0;
    cursor: move;
}

.wat-drag-handle {
    display: flex;
    align-items: center;
    color: #6b7280;
    cursor: move;
    padding: 4px;
}

.wat-drag-icon {
    font-family: monospace;
    font-size: 16px;
    line-height: 1;
    letter-spacing: -2px;
}

.wat-widget-controls {
    display: flex;
    gap: 4px;
}

.wat-widget-controls button {
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    color: #6b7280;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.wat-widget-controls button:hover {
    background-color: #e5e7eb;
    color: #374151;
}

/* Dragging State */
body.wat-dragging-active {
    user-select: none;
    cursor: move;
}

body.wat-dragging-active * {
    pointer-events: none;
}

.wat-draggable-widget.wat-dragging * {
    pointer-events: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .wat-draggable-widget {
        width: 280px;
        max-width: calc(100vw - 20px);
    }

    .wat-annotation-container:not(.wat-shortcode) .wat-sidebar {
        position: relative !important;
        width: 100%;
        top: auto;
        right: auto;
        left: auto;
        margin-top: 20px;
    }

    .wat-widget-header {
        display: none; /* Hide drag controls on mobile */
    }
}

.wat-sidebar-header {
    margin-bottom: 0;
    padding: 15px 20px 15px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.wat-sidebar-content {
    padding: 0 20px 20px 20px;
}

.wat-sidebar-header h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #1f2937;
}

.wat-sidebar-description {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

/* Collapsible Sidebar Headers */
.wat-collapsible-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px 0;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.wat-collapsible-header:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.wat-chevron {
    font-size: 12px;
    transition: transform 0.2s ease;
    color: #6b7280;
    font-weight: normal;
}

.wat-collapsible-header.wat-collapsed .wat-chevron {
    transform: rotate(-90deg);
}

.wat-collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 1000px;
    opacity: 1;
}

.wat-collapsible-content.wat-collapsed {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

.wat-annotation-detail {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}

.wat-annotation-detail .wat-annotation-tag {
    margin-bottom: 12px;
}

.wat-annotation-detail .wat-annotation-tag-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    color: white;
}

.wat-annotation-detail .wat-annotation-text {
    font-weight: 600;
    margin-bottom: 8px;
    color: #1f2937;
}

.wat-annotation-detail .wat-annotation-explanation {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.4;
}

.wat-all-annotations h4,
.wat-tag-legend h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #1f2937;
}

.wat-annotations-list {
    margin-bottom: 25px;
}

.wat-annotation-item {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wat-annotation-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.wat-annotation-item.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

.wat-annotation-tag-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    color: white;
    margin-bottom: 6px;
}

.wat-annotation-preview {
    font-weight: 500;
    font-size: 13px;
    color: #1f2937;
    margin-bottom: 4px;
}

.wat-annotation-summary {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
}

/* Tag Legend */
.wat-tags-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wat-tag-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.wat-tag-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 2px;
}

.wat-tag-info {
    flex: 1;
    min-width: 0;
}

.wat-tag-name {
    font-weight: 500;
    font-size: 13px;
    color: #1f2937;
    margin-bottom: 2px;
}

.wat-tag-description {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.3;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .wat-annotation-container {
        grid-template-columns: 1fr 300px;
        gap: 20px;
    }
    
    .wat-article {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    .wat-annotation-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .wat-sidebar {
        position: static;
        max-height: none;
        order: -1;
    }
    
    .wat-article-header h1 {
        font-size: 1.5rem;
    }
    
    .wat-article-content {
        font-size: 15px;
    }
    
    .wat-hover-card {
        position: absolute;
        transform: none;
        left: 0;
        right: 0;
        margin: 0 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .wat-article {
        padding: 15px;
        margin: 0 10px;
    }
    
    .wat-sidebar {
        margin: 0 10px;
        padding: 15px;
    }
    
    .wat-article-meta {
        flex-direction: column;
        gap: 5px;
    }
}

/* Print Styles */
@media print {
    .wat-sidebar {
        display: none;
    }
    
    .wat-annotation-container {
        grid-template-columns: 1fr;
    }
    
    .wat-annotation {
        background: transparent !important;
        border-bottom: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .wat-annotation:after {
        content: " (" attr(data-tag-name) ")";
        font-size: 0.8em;
        font-style: italic;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .wat-article {
        background: #1f2937;
        color: #f9fafb;
        border-color: #374151;
    }
    
    .wat-article-header {
        border-color: #374151;
    }
    
    .wat-article-header h1 {
        color: #f9fafb;
    }
    
    .wat-article-content {
        color: #e5e7eb;
    }
    
    .wat-sidebar {
        background: #111827;
        color: #f9fafb;
        border-color: #374151;
    }
    
    .wat-annotation-detail,
    .wat-annotation-item,
    .wat-tag-item {
        background: #1f2937;
        color: #f9fafb;
        border-color: #374151;
    }
    
    .wat-hover-card {
        background: #1f2937;
        color: #f9fafb;
        border-color: #374151;
    }
}

/* Accessibility */
.wat-annotation:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.wat-annotation-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .wat-annotation {
        border-width: 2px;
    }
    
    .wat-annotation-item {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .wat-annotation,
    .wat-annotation-item,
    .wat-hover-card {
        transition: none;
    }
    
    .wat-annotation:hover {
        transform: none;
    }
}