/* ==================================================================
   RICH TEXT EDITOR - MEDIA RESIZE CONTROLS
   ================================================================== */

.editor-image,
.video-embed,
.web-embed {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

/* Link card for non-embeddable sites */
.link-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin: 8px 0;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    transition: all var(--duration-normal) var(--ease-in-out);
    cursor: pointer;
}

.link-card:hover {
    border-color: var(--accent-blue);
    background: var(--bg-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-2);
}

.link-card-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 8px;
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    border-radius: var(--radius-md);
}

.link-card-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.link-card-domain {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.link-card-url {
    font-size: var(--font-size-12);
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-card-button {
    padding: 8px 16px;
    background: var(--accent-fill);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-in-out);
    text-decoration: none;
    white-space: nowrap;
    display: inline-block;
    user-select: none;
}

.link-card:hover .link-card-button {
    background: var(--accent-blue-dark);
}

/* Resizing state - show blue outline */
.editor-image.resizing,
.video-embed.resizing,
.web-embed.resizing {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

/* Resize handles - 4 corners */
.media-resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border: 2px solid var(--accent-blue);
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-in-out), transform var(--duration-fast) var(--ease-in-out);
    z-index: 10;
    box-shadow: var(--shadow-1);
}

/* Position handles at each corner. Sit them just inside the figure's edge
   rather than overhanging — when an inline-block figure aligns flush with
   the editor's left edge, negative offsets overflow into a clipping ancestor
   (note-modal-main has overflow-y: auto, which the spec promotes overflow-x
   to auto too) and the left handles get half-clipped. 2px keeps the visual
   "tab on the corner" feel without escaping the figure's box. */
.media-resize-handle-nw {
    top: 2px;
    left: 2px;
    cursor: nwse-resize;
}

.media-resize-handle-ne {
    top: 2px;
    right: 2px;
    cursor: nesw-resize;
}

.media-resize-handle-sw {
    bottom: 2px;
    left: 2px;
    cursor: nesw-resize;
}

.media-resize-handle-se {
    bottom: 2px;
    right: 2px;
    cursor: nwse-resize;
}

/* Show handles on hover */
.editor-image:hover .media-resize-handle,
.video-embed:hover .media-resize-handle,
.web-embed:hover .media-resize-handle,
.media-resize-handle:hover {
    opacity: 1;
}

/* Enlarge on hover for better feedback */
.media-resize-handle:hover {
    transform: scale(1.3);
    background: var(--accent-blue);
    border-color: white;
}

/* Video & Web Embeds */
.video-embed,
.web-embed {
    margin: var(--space-5) 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-light);
    background: var(--bg-primary);
    box-shadow: var(--shadow-1);
    transition: all var(--duration-fast) var(--ease-in-out);
}

.video-embed:hover,
.web-embed:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-2);
}

.video-embed iframe,
.web-embed iframe {
    width: 100%;
    height: 400px;
    border: none;
    display: block;
    background: var(--bg-secondary);
}

/* Click overlay for video/web embeds - captures right-click for context menu */
.media-click-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    cursor: pointer;
    background: transparent;
}

/* When activated (double-clicked), allow iframe interaction */
.video-embed.media-active .media-click-overlay,
.web-embed.media-active .media-click-overlay {
    pointer-events: none;
}

/* Column Layouts */
.columns-layout {
    display: grid;
    gap: 16px;
    margin: 16px 0;
}

.columns-2 {
    grid-template-columns: 1fr 1fr;
}

.columns-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.columns-layout .column {
    padding: 12px;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-md);
    min-height: 80px;
}

/* Tabs */
.tabs-block {
    margin: 16px 0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.tabs-header {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
}

.tab-button {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: var(--font-size-14);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.tab-button:last-child {
    border-right: none;
}

.tab-button:hover {
    background: var(--bg-hover);
}

.tab-button.active {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.tabs-content {
    position: relative;
}

.tab-pane {
    display: none;
    padding: 16px;
}

.tab-pane.active {
    display: block;
}

/* Table of Contents */
.toc-block {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 16px;
    margin: 16px 0;
}

.toc-block h3 {
    margin: 0 0 12px 0;
    font-size: var(--font-size-16);
    color: var(--text-primary);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin: 6px 0;
}

.toc-link {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: var(--font-size-14);
    transition: color var(--duration-fast) var(--ease-in-out);
}

.toc-link:hover {
    color: var(--accent-blue-dark);
    text-decoration: underline;
}

/* Math Equations */
.math-inline {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    color: var(--text-primary);
    background: rgba(var(--accent-blue-rgb, 59, 130, 246), 0.1);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.math-block {
    font-family: 'Times New Roman', Times, serif;
    font-style: italic;
    text-align: center;
    padding: 16px;
    margin: 16px 0;
    background: rgba(var(--accent-blue-rgb, 59, 130, 246), 0.05);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

/* Mentions */
.mention {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-in-out);
}

.mention-task {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.mention-project {
    background: rgba(139, 92, 246, 0.1);
    color: var(--color-purple-text);
}

.mention:hover {
    filter: brightness(0.95);
}
