﻿/* NOTES */
.note {
    position: absolute;
    min-width: 150px;
    min-height: 50px;
    background: var(--note-bg);
    border-radius: 8px;
    /* Restored rounded corners */
    box-shadow: var(--shadow);
    /* Restored shadow */
    display: flex;
    flex-direction: column;
    z-index: 10;
    --note-border-width: 1px;
    --note-border-style: solid;
    --note-border-color: var(--grid-color);
    border: var(--note-border-width) var(--note-border-style) var(--note-border-color);
    overflow: visible;
    /* transition: box-shadow 0.2s; - Removed unused transition */
    transition: background-color 0.2s ease;
    box-sizing: border-box;
    transform-origin: center center;
    /* Perf: Optimize rendering */
    text-rendering: optimizeSpeed;
}

/* Optimization: Image notes are often numerous, so keep them simple (square, no shadow) */
.note[data-type="image"] {
    border-radius: 0 !important;
    box-shadow: none !important;
    border: 1px solid var(--grid-color);
    /* Ensure visible border */
}

/* Ensure header matches note style */
.note[data-type="image"] .note-header {
    border-radius: 0 !important;
}

/* Ensure body (which clips content) also has no radius for images */
.note[data-type="image"] .note-body {
    border-radius: 0 !important;
}

.note.selected {
    border: 2px solid var(--accent-color);
    /* Perf: Simplified selection to single solid outline instead of glow */
    outline: 1px solid rgba(0, 122, 204, 0.3);
    box-shadow: none;
}

/* Selected image needs simpler outline/border */
.note[data-type="image"].selected {
    outline: 2px solid var(--accent-color);
    border: none;
    box-shadow: none;
}

.note.clean-mode {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.note.clean-mode .note-header {
    display: none;
}

.note.clean-mode .note-body {
    background: transparent !important;
}

.note-header {
    height: 32px;
    background: rgba(0, 0, 0, 0.05);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    cursor: grab;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 8px 8px 0 0;
    /* Restored header radius */
    transition: background-color 0.2s ease;
}

.note-header:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.note-header:active {
    cursor: grabbing;
    background-color: rgba(0, 0, 0, 0.15);
}

.note-header .note-title {
    user-select: none;
    outline: none;
    min-width: 20px;
}

.note-header .note-title[contenteditable="true"] {
    user-select: text;
    cursor: text;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    padding: 2px 4px;
}

.note-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--note-bg);
    border-radius: 0 0 8px 8px;
    transition: background-color 0.2s ease;
}

.text-editor {
    width: 100%;
    height: 100%;
    outline: none;
    cursor: text;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    user-select: text;
    padding: 10px;
}

.code-container {
    display: flex;
    height: 100%;
    width: 100%;
    font-family: 'Consolas', monospace;
    background: var(--code-bg);
    color: var(--code-text);
    border-radius: 0 0 8px 0;
    /* Restored rounded corners */
}

.line-numbers {
    width: 40px;
    background: color-mix(in srgb, var(--code-line-bg) 60%, transparent);
    color: var(--code-line-num);
    text-align: right;
    padding: 10px 5px;
    font-size: 13px;
    line-height: 20px;
    border-right: 1px solid var(--grid-color);
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
    border-radius: 0 0 0 8px;
}

/* When the note has a custom background, make line numbers blend with it */
.note[style*="background"] .line-numbers {
    background: rgba(0, 0, 0, 0.06);
}

.code-editor {
    flex: 1;
    padding: 10px;
    font-size: 13px;
    line-height: 20px;
    overflow: auto;
    white-space: pre;
    outline: none;
    cursor: text;
}

.code-editor::-webkit-scrollbar {
    cursor: default;
}

.code-editor::-webkit-scrollbar-corner {
    background: var(--sb-track);
}

.kw {
    color: var(--kw-color);
    font-weight: bold;
}

.str {
    color: var(--str-color);
}

.def {
    color: var(--def-color);
}

.cmt {
    color: var(--comment-color);
    font-style: italic;
}

.img-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}

/* Checklist Styles */
.checklist-container {
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.chk-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: var(--radius-sm, 6px);
    background: transparent;
    transition: background var(--ui-motion-fast, 0.12s) ease;
    position: relative;
}

.chk-item:hover {
    background: var(--surface-1, rgba(0, 0, 0, 0.03));
}

.chk-checkbox {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color-strong, rgba(24, 24, 27, 0.28));
    border-radius: 5px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all var(--ui-motion-medium, 0.2s) cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: transparent;
}

.chk-checkbox:hover {
    border-color: var(--accent-color);
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.06);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb, 99, 102, 241), 0.08);
}

.chk-checkbox:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 1px 3px rgba(var(--accent-rgb, 99, 102, 241), 0.3);
}

.chk-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 10px;
    border: solid var(--on-accent-color, white);
    border-width: 0 2px 2px 0;
    border-radius: 0 0 1px 0;
    transform: rotate(45deg);
    animation: chk-pop var(--ui-motion-fast, 0.12s) cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chk-pop {
    0% { transform: rotate(45deg) scale(0); opacity: 0; }
    60% { transform: rotate(45deg) scale(1.2); }
    100% { transform: rotate(45deg) scale(1); opacity: 1; }
}

.chk-text {
    flex: 1;
    outline: none;
    cursor: text;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all var(--ui-motion-fast, 0.12s) ease;
    min-width: 50px;
    font-size: var(--text-sm, 0.82rem);
    line-height: 1.5;
}

.chk-text:focus {
    background: var(--surface-2, rgba(0, 0, 0, 0.05));
}

.chk-item.completed .chk-text {
    text-decoration: line-through;
    text-decoration-color: var(--text-secondary, #71717a);
    color: var(--text-secondary, #71717a);
    opacity: 0.55;
    transition: all var(--ui-motion-medium, 0.2s) ease;
}

/* Image Note Styling */
.img-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 0 !important;
    /* Perf: Removed rounded corners */
}

.img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    /* or cover, depending on preference */
    border-radius: 0 !important;
    /* Perf: Ensure no radius on image */
    display: block;
    /* Eliminate font metrics spacing */
}

.chk-delete-btn {
    opacity: 0;
    background: transparent;
    border: none;
    width: 22px;
    height: 22px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-secondary, #71717a);
    border-radius: 50%;
    transition: all var(--ui-motion-fast, 0.12s) ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.chk-item:hover .chk-delete-btn {
    opacity: 0.5;
}

.chk-delete-btn:hover {
    opacity: 1 !important;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.chk-add-btn {
    background: transparent;
    border: 1.5px dashed var(--border-color, rgba(24, 24, 27, 0.12));
    padding: 6px 12px;
    margin: 4px 6px 6px;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    color: var(--text-secondary, #71717a);
    font-size: var(--text-sm, 0.82rem);
    font-weight: 500;
    transition: all var(--ui-motion-fast, 0.12s) ease;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chk-add-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.04);
}

/* Voice Note Styles */
/* Voice Note Styles */
.note[data-type="voice"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 999px !important;
    min-height: 48px !important;
    /* Enforce min height for touch targets */
}

/* Ensure selected state for voice note follows the pill shape */
.note[data-type="voice"].selected {
    outline: 2px solid var(--accent-color);
    border-radius: 999px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.note[data-type="voice"] .note-header {
    display: none;
    /* No header for voice notes */
}

.note[data-type="voice"] .note-body {
    background: transparent !important;
    border-radius: 999px !important;
    overflow: visible !important;
    /* Allow shadow/outline */
}

.voice-note-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 16px 6px 8px;
    /* Tighter padding on left */
    background: var(--voice-bg, var(--accent-color));
    border-radius: 999px !important;
    /* Force pill */
    min-width: 0;
    /* Allow shrinking */
    height: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    /* Clip waveform */
    /* Add subtle gradient/shadow for depth */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.voice-play-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.15);
    color: var(--voice-text, white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    z-index: 2;
    /* Ensure clickable */
}

.voice-play-btn:hover {
    background: rgba(0, 0, 0, 0.25);
    transform: scale(1.05);
}

.voice-waveform {
    flex: 1;
    height: 32px;
    min-width: 0;
    /* Allow it to shrink to 0 */
}

.voice-duration {
    font-size: 0.85rem;
    color: var(--voice-text, rgba(255, 255, 255, 0.9));
    font-weight: 500;
    flex-shrink: 0;
    font-family: 'Inter', sans-serif;
    margin-left: auto;
    /* Push to right if waveform is hidden */
    z-index: 2;
}

/* Hide waveform when note is too small (width or height) via container queries or just css logic */
/* Since we don't have container queries universally yet, we rely on flex behavior */
/* If width is small, waveform (flex: 1) shrinks. We can hide it if min-width isn't met? */

/* Logic: If note width < 120px, hide waveform */
/* We can't do this easily with CSS alone without container queries. */
/* But we can ensure it collapses gracefully. */

/* Video Note Styling */
.note[data-type="video"] {
    border-radius: 0 !important;
    box-shadow: none !important;
    border: 1px solid var(--grid-color);
    min-height: 200px;
    /* Ensure minimum height for proper gizmo resizing */
}

.note[data-type="video"] .note-header {
    display: none;
}

.note[data-type="video"] .note-body {
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    width: 100% !important;
    box-sizing: border-box;
    border-radius: 0 !important;
    overflow: hidden !important;
}

.note[data-type="video"].selected {
    outline: 2px solid var(--accent-color);
    border: none;
    box-shadow: none;
}

.video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000;
}

.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}

/* GIF Note Styling */
.note[data-type="gif"] {
    border-radius: 8px !important;
    box-shadow: var(--shadow) !important;
    border: 1px solid var(--grid-color);
}

.note[data-type="gif"] .note-header {
    display: none;
}

.note[data-type="gif"].selected {
    outline: 2px solid var(--accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.gif-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.gif-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
}

/* ============================================================================
   STICKY NOTES - Shape-themed notes with centered text
   ============================================================================ */
.sticky-note {
    --sticky-fill-color: #fff176;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12),
        0 1px 3px rgba(0, 0, 0, 0.08);
    background: transparent !important;
    border: none;
    min-width: 100px;
    min-height: 100px;
    overflow: visible;
}

.sticky-note .note-body {
    position: relative;
    z-index: 1; /* Above .sticky-shape-border (z-index:0) so content covers inner stroke half */
    background: var(--sticky-fill-color) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    overflow: hidden;
}

.sticky-note .sticky-drag-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    cursor: move;
    z-index: 2;
    background: transparent;
}

.sticky-note .sticky-content {
    width: 100%;
    height: 100%;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: text;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: #333;
    position: relative;
    z-index: 3;
}

.sticky-note .sticky-content[data-align="left"] {
    justify-content: flex-start;
    text-align: left;
}

.sticky-note .sticky-content[data-align="right"] {
    justify-content: flex-end;
    text-align: right;
}

.sticky-note .sticky-content[data-align="justify"] {
    justify-content: stretch;
    text-align: justify;
}

/* Shape variants - Simple shapes */
.sticky-square {
    border-radius: 0 !important;
}

.sticky-square .note-body {
    border-radius: 0 !important;
}

.sticky-rounded {
    border-radius: 12px !important;
}

.sticky-rounded .note-body {
    border-radius: 12px !important;
}

.sticky-circle {
    border-radius: 50% !important;
    aspect-ratio: 1;
}

.sticky-circle .note-body {
    border-radius: 50% !important;
}

/* Shape variants - Complex shapes with smooth SVG clip-paths */
.sticky-diamond {
    --sticky-shape-clip: url(#clip-diamond);
    border-radius: 0 !important;
}

.sticky-heart {
    --sticky-shape-clip: url(#clip-heart);
    border-radius: 0 !important;
}

.sticky-hexagon {
    --sticky-shape-clip: url(#clip-hexagon);
    border-radius: 0 !important;
}

.sticky-speech-bubble {
    --sticky-shape-clip: url(#clip-speech-bubble);
    border-radius: 0 !important;
}

.sticky-note.sticky-diamond,
.sticky-note.sticky-heart,
.sticky-note.sticky-hexagon,
.sticky-note.sticky-speech-bubble {
    box-shadow: none;
    /* No CSS background - SVG provides the shape fill */
    background: transparent !important;
}

.sticky-note.sticky-diamond .note-body,
.sticky-note.sticky-heart .note-body,
.sticky-note.sticky-hexagon .note-body,
.sticky-note.sticky-speech-bubble .note-body {
    -webkit-clip-path: var(--sticky-shape-clip);
    clip-path: var(--sticky-shape-clip);
    border-radius: 0 !important;
    /* Background is transparent - the SVG behind provides the visual fill.
       This eliminates the coordinate mismatch between clip-path (objectBoundingBox)
       and SVG border positioning that caused fill/border divergence. */
    background: transparent !important;
    filter: none !important;
    will-change: auto;
}

.sticky-note.sticky-diamond .note-body {
    padding: 20%;
}

.sticky-note.sticky-heart .note-body {
    padding: 20% 18% 22%;
}

.sticky-note.sticky-hexagon .note-body {
    padding: 14% 20%;
}

.sticky-note.sticky-speech-bubble .note-body {
    padding: 14% 10% 30% 10%;
}

.sticky-note .sticky-shape-border {
    position: absolute;
    /* SVG is 120% of note size, centered - provides 10% padding on each side
       so the stroke stays within SVG bounds without clipping.
       The viewBox "-10 -10 120 120" maps path coords 0-100 to the note's area. */
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    pointer-events: none;
    display: none;
    /* Behind .note-body so content appears above the fill */
    z-index: 0;
    overflow: visible;
    /* Drop-shadow for the shape - applied here because note-body is transparent */
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15)) drop-shadow(0 0 1px rgba(0, 0, 0, 0.08));
}

.sticky-note .sticky-shape-border-path {
    /* Fill provides the shape background - unified with stroke in one coordinate system.
       paint-order: stroke fill draws stroke first, then fill on top, hiding the inner
       half of the stroke so only the outer half (= desired border width) is visible. */
    fill: var(--sticky-fill-color, transparent);
    stroke: var(--note-border-color, transparent);
    stroke-width: calc(2 * var(--note-border-width, 0px));
    stroke-dasharray: var(--sticky-border-dash, none);
    vector-effect: non-scaling-stroke;
    paint-order: stroke fill;
    /* Default: round joins - safe for all shapes, prevents miter spikes */
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* Geometric shapes: sharp miter joins for crisp solid corners */
.sticky-diamond .sticky-shape-border-path,
.sticky-hexagon .sticky-shape-border-path {
    stroke-linejoin: miter;
    stroke-linecap: square;
    stroke-miterlimit: 4;
}

/* Dashed geometric shapes: use round joins so dashes don't get miter-extended at
   corners (miter + square cap makes corner dashes look longer than mid-edge dashes) */
.sticky-note[data-border-style="dashed"].sticky-diamond .sticky-shape-border-path,
.sticky-note[data-border-style="dashed"].sticky-hexagon .sticky-shape-border-path {
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* Always show SVG for complex shapes - it provides the fill (background) AND border.
   The SVG path renders both via paint-order: stroke fill, so fill and border share
   one coordinate system and can never diverge at non-square aspect ratios. */
.sticky-note.sticky-diamond .sticky-shape-border,
.sticky-note.sticky-heart .sticky-shape-border,
.sticky-note.sticky-hexagon .sticky-shape-border,
.sticky-note.sticky-speech-bubble .sticky-shape-border {
    display: block;
}

/* Complex shapes never use CSS border - SVG handles both fill and border */
.sticky-note.sticky-diamond,
.sticky-note.sticky-heart,
.sticky-note.sticky-hexagon,
.sticky-note.sticky-speech-bubble {
    border: none !important;
}

/* Sticky note color variations */
.sticky-note[style*="background-color: #ff8a80"] {
    color: #4a0000 !important;
}

.sticky-note[style*="background-color: #82b1ff"] {
    color: #002f6c !important;
}

.sticky-note[style*="background-color: #b9f6ca"] {
    color: #004d25 !important;
}

.sticky-note[style*="background-color: #ffff8d"] {
    color: #333300 !important;
}

.sticky-note[style*="background-color: #ea80fc"] {
    color: #4a004d !important;
}

.sticky-note.selected {
    border: none;
    outline: 2px solid var(--accent-color);
    box-shadow: none;
}

.sticky-note.sticky-diamond.selected,
.sticky-note.sticky-heart.selected,
.sticky-note.sticky-hexagon.selected,
.sticky-note.sticky-speech-bubble.selected {
    box-shadow: none;
    outline: none;
}

/* ============================================================================
   OUTWARD-EXPANDING BORDERS - Uses ::after pseudo-element to expand outside
   ============================================================================ */
.note.has-custom-border {
    border: none !important;
    /* Note: .note already has position: absolute - do NOT override with relative */
}

.note.has-custom-border::after {
    content: '';
    position: absolute;
    top: calc(-1 * var(--note-border-width, 0px));
    left: calc(-1 * var(--note-border-width, 0px));
    width: calc(100% + 2 * var(--note-border-width, 0px));
    height: calc(100% + 2 * var(--note-border-width, 0px));
    border-width: var(--note-border-width);
    border-style: var(--note-border-style);
    border-color: var(--note-border-color);
    /* radius + border-width so the ::after inner curve matches the note background exactly.
       Plain inherit copies the note's radius, making inner radius = (radius - bw) which
       diverges from the note bg at corners, creating a visible gap. */
    border-radius: calc(8px + var(--note-border-width, 0px));
    pointer-events: none;
    box-sizing: border-box;
    z-index: 0;
}

.note.has-custom-border.selected {
    outline: none !important;
}

.note.has-custom-border.selected::after {
    outline: 2px solid var(--accent-color);
    outline-offset: 0;
}

.sticky-note.has-custom-border {
    border: none !important;
}

.sticky-note.has-custom-border::after {
    content: '';
    position: absolute;
    top: calc(-1 * var(--note-border-width, 0px));
    left: calc(-1 * var(--note-border-width, 0px));
    width: calc(100% + 2 * var(--note-border-width, 0px));
    height: calc(100% + 2 * var(--note-border-width, 0px));
    border-width: var(--note-border-width);
    border-style: var(--note-border-style);
    border-color: var(--note-border-color);
    /* Default sticky radius (8px) + border-width for correct inner curve alignment */
    border-radius: calc(8px + var(--note-border-width, 0px));
    pointer-events: none;
    box-sizing: border-box;
    z-index: 0;
}

/* Shape-specific ::after radius overrides */
.sticky-note.has-custom-border.sticky-square::after {
    border-radius: 0 !important;
}

.sticky-note.has-custom-border.sticky-rounded::after {
    border-radius: calc(12px + var(--note-border-width, 0px)) !important;
}

/* 50% on the larger ::after naturally produces inner radius = 50% of note = correct circle */
.sticky-note.has-custom-border.sticky-circle::after {
    border-radius: 50% !important;
}

/* Complex shapes use SVG borders, so disable ::after for them */
.sticky-note.has-custom-border.sticky-diamond::after,
.sticky-note.has-custom-border.sticky-heart::after,
.sticky-note.has-custom-border.sticky-hexagon::after,
.sticky-note.has-custom-border.sticky-speech-bubble::after {
    display: none;
}

.sticky-note.has-custom-border.selected {
    outline: none;
}

.sticky-note.has-custom-border.selected::after {
    outline: 2px solid var(--accent-color);
    outline-offset: 0;
}

.sticky-note.has-custom-border.sticky-diamond.selected,
.sticky-note.has-custom-border.sticky-heart.selected,
.sticky-note.has-custom-border.sticky-hexagon.selected,
.sticky-note.has-custom-border.sticky-speech-bubble.selected {
    box-shadow: none;
}

/* LOD compatibility: disable outward border pseudo at simplified zoom levels */
.lod-low .note.has-custom-border::after,
.lod-minimal .note.has-custom-border::after {
    display: none !important;
}
