/* Popover Annotation CSS - Inspired by Gwern's link popup annotization */

/* Styles for the popover container */
.popover-annotation {
    position: absolute;
    z-index: 1000;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.popover-annotation:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* When being dragged */
.popover-dragging {
    opacity: 0.8;
    cursor: move;
}

/* When being resized */
.popover-resizing {
    transition: none;
}

/* Popover header styling */
.popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--dark-bg);
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 12px;
    cursor: move;
    user-select: none;
    height: 40px; /* Fixed height for more consistent grabbing */
    background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.05));
}

.popover-annotation:hover .popover-header {
    background-color: var(--code-border);
}

.popover-title {
    flex-grow: 1;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
}

.popover-controls {
    display: flex;
    gap: 5px;
}

.popover-controls button {
    background: none;
    border: none;
    color: var(--light-text);
    width: 26px;
    height: 26px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    margin-left: 2px;
}

.popover-controls button:hover {
    background-color: var(--code-border);
    color: var(--text-color);
}

.popover-minimize:hover {
    color: var(--warning-color) !important;
}

.popover-maximize:hover {
    color: var(--success-color) !important;
}

.popover-close:hover {
    color: var(--danger-color) !important;
}

/* Popover body styling */
.popover-body {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    background-color: white;
}

/* Loading indicator */
.popover-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px;
    text-align: center;
    background-color: var(--card-bg);
    color: var(--light-text);
    z-index: 1;
}

/* Iframe styling */
.popover-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background-color: white;
}

/* External content styling */
.popover-external-content {
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background-color: var(--card-bg);
    color: var(--text-color);
    overflow: auto;
}

.popover-external-warning {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.popover-external-warning i {
    font-size: 48px;
    color: var(--warning-color);
    margin-bottom: 15px;
}

.popover-external-warning p {
    margin-bottom: 0;
    max-width: 300px;
    color: var(--light-text);
}

.popover-external-url {
    margin-top: 15px;
    padding: 10px;
    background-color: var(--dark-bg);
    border-radius: 4px;
    word-break: break-all;
    max-width: 100%;
}

.popover-external-url a {
    color: var(--primary-color);
}

/* Resize handles for all directions */
.popover-resize-handle {
    position: absolute;
    background-color: transparent;
    z-index: 2000;
}

/* Corner handles */
.popover-resize-se,
.popover-resize-sw,
.popover-resize-ne,
.popover-resize-nw {
    width: 12px;
    height: 12px;
}

.popover-resize-se {
    bottom: 0;
    right: 0;
    cursor: se-resize;
}

.popover-resize-sw {
    bottom: 0;
    left: 0;
    cursor: sw-resize;
}

.popover-resize-ne {
    top: 0;
    right: 0;
    cursor: ne-resize;
}

.popover-resize-nw {
    top: 0;
    left: 0;
    cursor: nw-resize;
}

/* Edge handles */
.popover-resize-n,
.popover-resize-s {
    height: 6px;
    left: 12px;
    right: 12px;
}

.popover-resize-e,
.popover-resize-w {
    width: 6px;
    top: 12px;
    bottom: 12px;
}

.popover-resize-n {
    top: 0;
    cursor: n-resize;
}

.popover-resize-s {
    bottom: 0;
    cursor: s-resize;
}

.popover-resize-e {
    right: 0;
    cursor: e-resize;
}

.popover-resize-w {
    left: 0;
    cursor: w-resize;
}

/* Visual indicators for hover states */
.popover-annotation:hover .popover-resize-se {
    background: linear-gradient(135deg, transparent 50%, var(--primary-color) 50%, var(--primary-color) 100%);
}

.popover-annotation:hover .popover-resize-sw {
    background: linear-gradient(225deg, transparent 50%, var(--primary-color) 50%, var(--primary-color) 100%);
}

.popover-annotation:hover .popover-resize-ne {
    background: linear-gradient(45deg, transparent 50%, var(--primary-color) 50%, var(--primary-color) 100%);
}

.popover-annotation:hover .popover-resize-nw {
    background: linear-gradient(315deg, transparent 50%, var(--primary-color) 50%, var(--primary-color) 100%);
}

.popover-annotation:hover .popover-resize-n,
.popover-annotation:hover .popover-resize-s {
    background-color: rgba(78, 156, 245, 0.2);
}

.popover-annotation:hover .popover-resize-e,
.popover-annotation:hover .popover-resize-w {
    background-color: rgba(78, 156, 245, 0.2);
}

/* Maximized state */
.popover-maximized {
    border-radius: 0;
    border-width: 0;
}

.popover-maximized .popover-header {
    border-radius: 0;
}

/* Minimized state */
.popover-minimized {
    min-height: 0;
}

/* Visual styles for links with popover capability */
.post-content a:not([href^="#"]) {
    border-bottom: 1px dashed var(--primary-color);
    text-decoration: none;
    transition: background-color 0.2s;
    position: relative;
}

.post-content a:not([href^="#"]):hover {
    background-color: rgba(78, 156, 245, 0.1);
}

.post-content a:not([href^="#"]):hover::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--primary-color);
}

/* Link preview states */
.post-content a.has-preview {
    border-bottom: 1px dashed var(--primary-color);
    cursor: pointer;
    position: relative;
}

.post-content a.no-preview {
    border-bottom: 1px solid var(--primary-color);
    text-decoration: none;
} 