/* Modern styles for Dan's Annotator plugin UI/UX */

:root {
    --annotate-primary: #4f46e5;
    --annotate-primary-light: #6366f1;
    --annotate-primary-dark: #3730a3;
    --annotate-accent: #f59e0b;
    --annotate-accent-light: #fbbf24;
    --annotate-success: #10b981;
    --annotate-danger: #ef4444;
    --annotate-surface: #ffffff;
    --annotate-surface-elevated: #f8fafc;
    --annotate-text: #0f172a;
    --annotate-text-secondary: #64748b;
    --annotate-border: #e2e8f0;
    --annotate-shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --annotate-shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --annotate-shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --annotate-shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --annotate-radius-sm: 6px;
    --annotate-radius-md: 10px;
    --annotate-radius-lg: 16px;
    --annotate-radius-xl: 24px;
    --annotate-transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --annotate-transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

.annotate-highlight,
.annotate-focus {
    position:relative !important;
    outline:none !important;
    transition:box-shadow var(--annotate-transition-fast), background var(--annotate-transition-fast);
}

.annotate-relative-target {
    position:relative !important;
}

.annotate-highlight::after,
.annotate-focus::after {
    content:'';
    position:absolute;
    inset:-6px;
    /* use the computed target radius if provided via --annotate-target-radius */
    border-radius:var(--annotate-target-radius, var(--annotate-radius-lg));
    box-shadow:0 0 0 2px rgba(79,70,229,0.3), 0 0 20px rgba(79,70,229,0.15);
    background:rgba(99,102,241,0.08);
    pointer-events:none;
    animation:annotate-pulse 2s ease-in-out infinite;
}

.annotate-focus::after {
    box-shadow:0 0 0 3px rgba(79,70,229,0.5), 0 0 30px rgba(79,70,229,0.25);
    background:rgba(99,102,241,0.12);
    animation:none;
}

@keyframes annotate-pulse {
    0%, 100% { opacity:1; }
    50% { opacity:0.7; }
}

body.annotate-creating {
    cursor:pointer;
}

body.annotate-selecting-existing-disabled .annotate-badge {
    opacity:0.65;
    transition:opacity 120ms ease;
}

body.annotate-selecting-existing-disabled .annotate-badge:hover {
    opacity:0.4;
    transform:translate(-50%, -50%);
}

body.annotate-selecting-existing-disabled.annotate-selecting-child-mode .annotate-has-annotation {
    position:relative !important;
    transition:filter 140ms ease, opacity 140ms ease;
}

body.annotate-selecting-existing-disabled.annotate-selecting-child-mode .annotate-has-annotation:hover {
    filter:grayscale(0.6);
    opacity:0.75;
}

body.annotate-selecting-existing-disabled.annotate-selecting-child-mode .annotate-has-annotation:hover::after {
    content:'';
    position:absolute;
    inset:0;
    background:rgba(255,255,255,0.3);
    pointer-events:none;
    border-radius:inherit;
}

body:not(.annotate-enabled) .annotate-badge,
body:not(.annotate-enabled) .annotate-floating-controls,
body:not(.annotate-enabled) #annotate-panel {
    display:none !important;
}

.annotate-btn-icon-hidden {
    opacity:0;
    pointer-events:none;
    visibility:hidden;
}

.annotate-btn-icon {
    transition:color 120ms ease, opacity 180ms ease;
}

.annotate-btn-icon.annotate-copy-success {
    color:#22c55e;
    opacity:0.3;
}


/* Badge: absolutely positioned centered on the target element */
.annotate-badge {
    position:absolute;
    top:50%;
    left:50%;
    transform:translate(-50%, -50%);
    display:inline-flex;
    align-items:center;
    gap:4px;
    background:linear-gradient(135deg, var(--annotate-primary), var(--annotate-primary-light));
    color:#fff;
    padding:6px 12px;
    border-radius:999px;
    font-size:11px;
    line-height:1;
    box-shadow:var(--annotate-shadow-lg), 0 0 20px rgba(79,70,229,0.3);
    cursor:pointer;
    font-weight:700;
    transition:transform var(--annotate-transition-fast), box-shadow var(--annotate-transition-fast);
    white-space:nowrap;
    letter-spacing:0.5px;
    text-transform:uppercase;
    backdrop-filter:blur(4px);
}

.annotate-badge::before {
    content:'💬';
    font-size:10px;
}

.annotate-badge:hover {
    transform:translate(-50%, -50%) scale(1.08);
    box-shadow:var(--annotate-shadow-xl), 0 0 30px rgba(79,70,229,0.4);
}


.annotate-floating-controls {
    position:fixed;
    bottom:24px;
    right:24px;
    display:none;
    flex-direction:column;
    gap:8px;
    z-index:999998;
}

.annotate-floating-controls.annotate-floating-visible {
    display:flex;
}

.annotate-floating-btn {
    border:0;
    border-radius:var(--annotate-radius-xl);
    padding:12px 20px;
    font-size:13px;
    font-weight:600;
    cursor:pointer;
    box-shadow:var(--annotate-shadow-lg);
    transition:transform var(--annotate-transition-fast), box-shadow var(--annotate-transition-fast), background var(--annotate-transition-fast);
    backdrop-filter:blur(8px);
}

.annotate-floating-btn:hover {
    transform:translateY(-2px);
    box-shadow:var(--annotate-shadow-xl);
}

.annotate-floating-btn:active {
    transform:scale(0.97);
}

.annotate-floating-view {
    background:rgba(255,255,255,0.95);
    color:var(--annotate-primary);
    border:1px solid var(--annotate-border);
}

.annotate-floating-view:hover {
    background:var(--annotate-surface);
    border-color:var(--annotate-primary-light);
}

.annotate-floating-create {
    background:linear-gradient(135deg, var(--annotate-primary), var(--annotate-primary-light));
    color:#fff;
}

.annotate-floating-create:hover {
    background:linear-gradient(135deg, var(--annotate-primary-light), var(--annotate-primary));
}

.annotate-floating-cancel {
    background:rgba(255,255,255,0.95);
    color:var(--annotate-text-secondary);
    border:1px solid var(--annotate-border);
}

.annotate-floating-disconnect {
    background:rgba(239,68,68,0.1);
    color:var(--annotate-danger);
    border:1px solid rgba(239,68,68,0.2);
}

.annotate-floating-btn.active {
    box-shadow:0 0 0 3px rgba(79,70,229,0.3), var(--annotate-shadow-xl);
}


.annotate-panel {
    position:fixed;
    right:18px;
    top:72px;
    width:420px;
    max-width:calc(100% - 36px);
    max-height:82vh;
    background:rgba(255,255,255,0.98);
    border-radius:var(--annotate-radius-xl);
    border:1px solid rgba(255,255,255,0.2);
    box-shadow:var(--annotate-shadow-xl), 0 0 80px rgba(15,23,42,0.15);
    z-index:999999;
    overflow:hidden;
    padding:0;
    transform:translateY(10px) scale(0.97);
    opacity:0;
    transition:all var(--annotate-transition-normal);
    backdrop-filter:blur(20px);
    display:none;
    flex-direction:column;
}

.annotate-panel-visible {
    display:flex;
    flex-direction:column;
}

.annotate-panel-reserve-confirm {
    margin-bottom:0;
    padding-bottom:0;
}

.annotate-panel.open {
    transform:translateY(0) scale(1);
    opacity:1;
}


.annotate-header {
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:16px 20px;
    min-height:60px;
    border-bottom:1px solid rgba(255,255,255,0.1);
    background:linear-gradient(135deg, var(--annotate-primary-dark), var(--annotate-primary));
    color:#fff;
}

.annotate-header strong {
    font-size:16px;
    font-weight:700;
    color:#fff;
    letter-spacing:-0.02em;
}

.annotate-header-info {
    display:flex;
    flex-direction:column;
    gap:4px;
    color:#fff;
}

.annotate-header-info-thread .annotate-subtitle {
    color:rgba(255,255,255,0.8);
}

.annotate-subtitle {
    font-size:12px;
    color:rgba(255,255,255,0.7);
}

.annotate-missing-pill {
    display:inline-flex;
    align-items:center;
    padding:4px 12px;
    border-radius:999px;
    font-size:11px;
    font-weight:600;
    background:rgba(239,68,68,0.2);
    color:#fff;
    margin-top:4px;
}

.annotate-controls {
    display:flex;
    gap:4px;
    align-items:center;
}

.annotate-btn-icon {
    background:rgba(255,255,255,0.1);
    border:0;
    padding:8px 10px;
    border-radius:var(--annotate-radius-sm);
    cursor:pointer;
    font-size:16px;
    line-height:1;
    transition:background var(--annotate-transition-fast), transform var(--annotate-transition-fast);
    color:#fff;
}

.annotate-btn-icon:hover {
    background:rgba(255,255,255,0.2);
    transform:scale(1.05);
}


.annotate-selector {
    font-size:12px;
    color:var(--annotate-text-secondary);
    padding:12px 20px;
    border-bottom:1px solid var(--annotate-border);
    background:var(--annotate-surface-elevated);
}

.annotate-selector code {
    display:block;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    max-width:100%;
    background:rgba(79,70,229,0.08);
    padding:8px 12px;
    border-radius:var(--annotate-radius-sm);
    margin-top:6px;
    font-size:11px;
    color:var(--annotate-primary-dark);
    letter-spacing:0.2px;
    font-family:'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}


.annotate-comments {
    flex:1 1 auto;
    overflow:auto;
    padding:16px 20px;
    background:var(--annotate-surface);
    min-height:0;
}

.annotate-comment {
    border:1px solid var(--annotate-border);
    border-radius:var(--annotate-radius-md);
    padding:14px 16px;
    margin-bottom:12px;
    background:var(--annotate-surface);
    box-shadow:var(--annotate-shadow-sm);
    transition:box-shadow var(--annotate-transition-fast), transform var(--annotate-transition-fast);
}

.annotate-comment:hover {
    box-shadow:var(--annotate-shadow-md);
    transform:translateY(-1px);
}

.annotate-comment .annotate-comment-meta {
    color:var(--annotate-text-secondary);
    font-size:12px;
    margin-bottom:8px;
    display:flex;
    justify-content:space-between;
    align-items:center;
}

.annotate-comment .annotate-comment-body {
    font-size:14px;
    color:var(--annotate-text);
    line-height:1.6;
}

.annotate-comment .annotate-comment-body a {
    color:var(--annotate-primary);
    text-decoration:underline;
    text-underline-offset:2px;
}

.annotate-comment .annotate-comment-body .annotate-mention {
    font-weight:600;
    color:var(--annotate-primary);
    background:rgba(79,70,229,0.1);
    padding:2px 6px;
    border-radius:4px;
}


.annotate-form {
    padding:16px 20px;
    border-top:1px solid var(--annotate-border);
    background:linear-gradient(180deg, var(--annotate-surface), var(--annotate-surface-elevated));
    flex-shrink:0;
}

.annotate-form textarea {
    width:100%;
    box-sizing:border-box;
    padding:12px 14px;
    border:1px solid var(--annotate-border);
    border-radius:var(--annotate-radius-md);
    font-size:14px;
    resize:vertical;
    min-height:60px;
    font-family:inherit;
    background:var(--annotate-surface);
    color:var(--annotate-text);
    transition:border-color var(--annotate-transition-fast), box-shadow var(--annotate-transition-fast);
}

.annotate-form textarea:focus {
    outline:none;
    border-color:var(--annotate-primary-light);
    box-shadow:0 0 0 3px rgba(79,70,229,0.15);
}

.annotate-form textarea::placeholder {
    color:var(--annotate-text-secondary);
}

.annotate-actions {
    margin-top:12px;
}

.annotate-actions-split {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    flex-wrap:wrap;
}

.annotate-actions-left, .annotate-actions-right {
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    align-items:center;
}

.annotate-actions-left {
    flex:1;
}

.annotate-btn {
    border:1px solid transparent;
    border-radius:var(--annotate-radius-sm);
    padding:10px 16px;
    font-size:13px;
    font-weight:600;
    cursor:pointer;
    transition:all var(--annotate-transition-fast);
}

.annotate-btn-primary {
    background:linear-gradient(135deg, var(--annotate-primary), var(--annotate-primary-light));
    color:#fff;
    border-color:transparent;
    box-shadow:0 4px 12px rgba(79,70,229,0.3);
}

.annotate-btn-primary:hover {
    background:linear-gradient(135deg, var(--annotate-primary-light), var(--annotate-primary));
    transform:translateY(-1px);
    box-shadow:0 6px 16px rgba(79,70,229,0.4);
}

.annotate-btn-secondary {
    background:var(--annotate-surface-elevated);
    color:var(--annotate-text);
    border-color:var(--annotate-border);
}

.annotate-btn-secondary:hover {
    background:var(--annotate-border);
    border-color:var(--annotate-text-secondary);
}

.annotate-btn-danger {
    background:rgba(239,68,68,0.1);
    color:var(--annotate-danger);
    border-color:rgba(239,68,68,0.3);
}

.annotate-btn-danger:hover {
    background:rgba(239,68,68,0.2);
    border-color:rgba(239,68,68,0.5);
}

.annotate-confirm-panel {
    padding:14px 18px;
    border-top:1px solid var(--annotate-border);
    background:rgba(239,68,68,0.05);
    margin:16px 20px 0;
    box-shadow:var(--annotate-shadow-md);
    border-radius:var(--annotate-radius-md);
    position:relative;
    flex-shrink:0;
    border:1px solid rgba(239,68,68,0.2);
}

.annotate-confirm-hidden {
    display:none;
}

.annotate-confirm-panel p {
    margin:0 0 12px 0;
    font-size:13px;
    color:var(--annotate-danger);
    font-weight:500;
}

.annotate-confirm-actions {
    display:flex;
    gap:10px;
    flex-wrap:wrap;
}


/* Autocomplete dropdown positioned near the textarea */
.annotate-autocomplete {
    position:absolute;
    background:var(--annotate-surface);
    border:1px solid var(--annotate-border);
    z-index:1000000;
    border-radius:var(--annotate-radius-md);
    box-shadow:var(--annotate-shadow-xl);
    overflow:hidden;
    display:none;
    max-width:320px;
    min-width:220px;
    backdrop-filter:blur(8px);
}

.annotate-autocomplete.annotate-autocomplete-visible {
    display:block;
    animation:annotate-slide-up 150ms ease-out;
}

@keyframes annotate-slide-up {
    from {
        opacity:0;
        transform:translateY(8px);
    }
    to {
        opacity:1;
        transform:translateY(0);
    }
}

.annotate-ac-item {
    padding:10px 14px;
    cursor:pointer;
    font-size:13px;
    color:var(--annotate-text);
    display:flex;
    align-items:center;
    gap:10px;
    transition:background var(--annotate-transition-fast);
}

.annotate-ac-item:hover, .annotate-ac-item.active {
    background:rgba(79,70,229,0.08);
}

.annotate-ac-item.active {
    background:rgba(79,70,229,0.12);
}


/* View All list */
.annotate-all-list {
    padding:16px 20px;
}

.annotate-empty-state {
    text-align:center;
    padding:48px 20px;
    color:var(--annotate-text-secondary);
}

.annotate-empty-state p {
    margin:8px 0;
}

.annotate-empty-state p:first-child {
    font-size:15px;
    font-weight:600;
    color:var(--annotate-text);
}

.annotate-empty-hint {
    font-size:13px;
    color:var(--annotate-text-secondary);
}


/* Thread sections */
.annotate-section {
    margin-bottom:20px;
}

.annotate-section-title {
    font-size:11px;
    font-weight:700;
    color:var(--annotate-text-secondary);
    margin:0 0 12px 0;
    display:flex;
    align-items:center;
    gap:8px;
    text-transform:uppercase;
    letter-spacing:0.08em;
}

.annotate-section-dot {
    font-size:12px;
    line-height:1;
}

.annotate-section-dot-missing {
    color:var(--annotate-danger);
}

.annotate-section-dot-open {
    color:var(--annotate-success);
}

.annotate-section-dot-closed {
    color:var(--annotate-text-secondary);
}


/* Thread card */
.annotate-thread-card {
    background:var(--annotate-surface);
    border:1px solid var(--annotate-border);
    border-radius:var(--annotate-radius-md);
    padding:14px 16px;
    margin-bottom:10px;
    box-shadow:var(--annotate-shadow-sm);
    transition:transform var(--annotate-transition-fast), box-shadow var(--annotate-transition-fast), border-color var(--annotate-transition-fast);
    cursor:pointer;
}

.annotate-thread-card:hover {
    transform:translateY(-2px);
    box-shadow:var(--annotate-shadow-md);
    border-color:var(--annotate-primary-light);
}

.annotate-thread-card.annotate-thread-missing {
    border-left:3px solid var(--annotate-danger);
}

.annotate-thread-header {
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:12px;
    margin-bottom:10px;
}

.annotate-thread-selector {
    background:rgba(79,70,229,0.06);
    padding:6px 10px;
    border-radius:var(--annotate-radius-sm);
    font-size:11px;
    color:var(--annotate-primary-dark);
    max-width:240px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
    flex:1;
    font-family:'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
}

.annotate-thread-time {
    font-size:11px;
    color:var(--annotate-text-secondary);
    white-space:nowrap;
}

.annotate-thread-snippet {
    font-size:13px;
    color:var(--annotate-text-secondary);
    margin-top:6px;
    line-height:1.5;
    max-height:3.2em;
    overflow:hidden;
}

.annotate-thread-author {
    font-weight:600;
    color:var(--annotate-text);
    margin-right:4px;
}


#annotate-panel[data-panel-mode="view-all"] .annotate-header {
    background:linear-gradient(135deg, var(--annotate-primary-dark), var(--annotate-primary));
    color:#fff;
}

#annotate-panel[data-panel-mode="view-all"] .annotate-header strong {
    color:#fff;
}

#annotate-panel[data-panel-mode="view-all"] .annotate-subtitle {
    color:rgba(255,255,255,0.7);
}

#annotate-panel[data-panel-mode="view-all"] .annotate-missing-pill {
    background:rgba(255,255,255,0.2);
    color:#fff;
}

#annotate-panel[data-panel-mode="view-all"] .annotate-controls .annotate-btn-icon {
    color:#fff;
}

#annotate-panel[data-panel-mode="view-all"] {
    display:flex;
    flex-direction:column;
}

#annotate-panel[data-panel-mode="view-all"] .annotate-all-list {
    background:var(--annotate-surface-elevated);
    border-top:1px solid rgba(255,255,255,0.08);
    padding:20px;
    flex:1 1 auto;
    overflow:auto;
    min-height:0;
}

#annotate-panel[data-panel-mode="view-all"] .annotate-section-title {
    text-transform:uppercase;
    font-size:11px;
    letter-spacing:0.08em;
    color:var(--annotate-text-secondary);
}

#annotate-panel[data-panel-mode="thread"] .annotate-header {
    background:linear-gradient(135deg, var(--annotate-primary-dark), var(--annotate-primary));
    color:#fff;
}

#annotate-panel[data-panel-mode="thread"] .annotate-header strong {
    color:#fff;
}

#annotate-panel[data-panel-mode="thread"] .annotate-subtitle {
    color:rgba(255,255,255,0.75);
}

#annotate-panel[data-panel-mode="thread"] .annotate-controls .annotate-btn-icon {
    color:#fff;
}


@media (max-width: 560px) {
.annotate-panel {
    right:12px;
    left:12px;
    top:60px;
    width:auto;
}

}

/* Panel position: left side */
body.annotate-panel-left .annotate-panel {
    right:auto;
    left:18px;
}

body.annotate-panel-left .annotate-floating-controls {
    right:auto;
    left:24px;
}

@media (max-width: 560px) {
    body.annotate-panel-left .annotate-panel {
        left:12px;
        right:12px;
    }
}

/* Closed thread highlight - stays while panel is open */
.annotate-closed-highlight {
    position:relative !important;
}

.annotate-closed-highlight::before {
    content:'';
    position:absolute;
    inset:-8px;
    border-radius:var(--annotate-radius-lg);
    background:linear-gradient(135deg, rgba(100,116,139,0.12), rgba(100,116,139,0.06));
    box-shadow:0 0 0 2px rgba(100,116,139,0.35), 0 0 20px rgba(100,116,139,0.15);
    pointer-events:none;
    animation:annotate-closed-fade-in 0.3s ease-out;
    z-index:99999;
}

.annotate-closed-highlight::after {
    content:'Closed';
    position:absolute;
    top:-32px;
    left:50%;
    transform:translateX(-50%);
    background:linear-gradient(135deg, #64748b, #475569);
    color:#fff;
    padding:6px 14px;
    border-radius:999px;
    font-size:11px;
    font-weight:700;
    letter-spacing:0.5px;
    text-transform:uppercase;
    box-shadow:0 4px 12px rgba(100,116,139,0.4);
    pointer-events:none;
    z-index:100000;
    animation:annotate-closed-label-bounce 0.4s ease-out;
}

@keyframes annotate-closed-fade-in {
    from {
        opacity:0;
        box-shadow:0 0 0 0 rgba(100,116,139,0), 0 0 0 rgba(100,116,139,0);
    }
    to {
        opacity:1;
        box-shadow:0 0 0 2px rgba(100,116,139,0.35), 0 0 20px rgba(100,116,139,0.15);
    }
}

@keyframes annotate-closed-label-bounce {
    0% {
        opacity:0;
        transform:translateX(-50%) translateY(10px);
    }
    50% {
        transform:translateX(-50%) translateY(-3px);
    }
    100% {
        opacity:1;
        transform:translateX(-50%) translateY(0);
    }
}

#annotate-thread-view {
    display:flex;
    flex-direction:column;
    flex:1 1 auto;
    min-height:0;
}

#annotate-viewall-view {
    display:flex;
    flex-direction:column;
    flex:1 1 auto;
    height:100%;
    min-height:0;
}

#annotate-panel[data-panel-mode="view-all"] #annotate-thread-view {
    display:none !important;
}

#annotate-panel[data-panel-mode="thread"] #annotate-viewall-view {
    display:none !important;
}

/* Token collaborator mention indicator */
.annotate-mention-token .annotate-mention-icon {
    font-size: 11px;
    vertical-align: middle;
    opacity: 0.75;
}

.annotate-mention-copied .annotate-mention-icon {
    color: #22c55e;
}

/* Admin bar dropdown toggles */
#wp-admin-bar-annotate-toggle .ab-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

#wp-admin-bar-annotate-toggle .ab-item .annotate-toggle-label {
    font-weight: 600;
}

#wp-admin-bar-annotate-toggle .ab-item .screen-reader-text {
    position: absolute;
    left: -9999px;
}

#wp-admin-bar-annotate-toggle .ab-submenu {
    padding: 6px 12px;
}

.annotate-adminbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 240px;
}

.annotate-adminbar-row-label {
    font-weight: 600;
    color: #f8fafc;
}

.annotate-adminbar-status {
    font-weight: 700;
    color: #f8fafc;
}

.annotate-adminbar-status-on {
    color: #22c55e;
}

.annotate-adminbar-status-off {
    color: #f87171;
}
