/* ============================================
   Jezt Highlight & Save - Styles
   Sitenin temasına otomatik uyum sağlar
   ============================================ */

:root {
    --jezt-hl-bg: color-mix(in srgb, Canvas 95%, CanvasText 5%);
    --jezt-hl-text: CanvasText;
    --jezt-hl-border: color-mix(in srgb, CanvasText 15%, Canvas 85%);
    --jezt-hl-accent: LinkText;
    --jezt-hl-accent-hover: color-mix(in srgb, LinkText 80%, CanvasText 20%);
    --jezt-hl-shadow: rgba(0, 0, 0, 0.12);
    --jezt-hl-radius: 8px;
    --jezt-hl-panel-width: 360px;
    --jezt-hl-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Seçim Popup ---- */
.jezt-hl-popup {
    position: absolute;
    z-index: 999999;
    background: var(--jezt-hl-bg);
    color: var(--jezt-hl-text);
    border: 1px solid var(--jezt-hl-border);
    border-radius: var(--jezt-hl-radius);
    padding: 6px 14px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--jezt-hl-shadow);
    user-select: none;
    transition: opacity var(--jezt-hl-transition), transform var(--jezt-hl-transition);
    opacity: 0;
    transform: translateY(4px);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.jezt-hl-popup.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.jezt-hl-popup:hover {
    background: var(--jezt-hl-accent);
    color: Canvas;
    border-color: var(--jezt-hl-accent);
}

.jezt-hl-popup.is-saved {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
    pointer-events: none;
}

/* ---- Sağ Kenar Toggle Buton (gece modu butonunun altında) ---- */
.jezt-hl-toggle {
    position: fixed;
    top: calc(50% + 60px);
    right: 0;
    transform: translateY(-50%);
    z-index: 999990;
    width: 36px;
    height: 72px;
    border-radius: var(--jezt-hl-radius) 0 0 var(--jezt-hl-radius);
    border: 1px solid var(--jezt-hl-border);
    border-right: none;
    background: var(--jezt-hl-bg);
    color: var(--jezt-hl-text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    box-shadow: -2px 0 12px var(--jezt-hl-shadow);
    transition: width var(--jezt-hl-transition), box-shadow var(--jezt-hl-transition);
    font-family: inherit;
    padding: 0;
    writing-mode: vertical-rl;
}

.jezt-hl-toggle:hover {
    width: 42px;
    box-shadow: -3px 0 16px var(--jezt-hl-shadow);
}

.jezt-hl-toggle svg {
    transform: rotate(0deg);
}

.jezt-hl-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 18px;
    height: 18px;
    background: var(--jezt-hl-accent);
    color: Canvas;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    writing-mode: horizontal-tb;
}

/* ---- Overlay ---- */
.jezt-hl-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999991;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--jezt-hl-transition), visibility var(--jezt-hl-transition);
}

.jezt-hl-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* ---- Yan Panel ---- */
.jezt-hl-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--jezt-hl-panel-width);
    max-width: 90vw;
    height: 100vh;
    height: 100dvh;
    z-index: 999992;
    background: var(--jezt-hl-bg);
    color: var(--jezt-hl-text);
    border-left: 1px solid var(--jezt-hl-border);
    box-shadow: -4px 0 24px var(--jezt-hl-shadow);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--jezt-hl-transition);
    font-family: inherit;
}

.jezt-hl-panel.is-open {
    transform: translateX(0);
}

.jezt-hl-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--jezt-hl-border);
    flex-shrink: 0;
}

.jezt-hl-panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--jezt-hl-text);
}

.jezt-hl-panel-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--jezt-hl-text);
    opacity: 0.6;
    transition: opacity 0.15s;
    padding: 0;
    line-height: 1;
}

.jezt-hl-panel-close:hover {
    opacity: 1;
}

/* ---- Panel Body ---- */
.jezt-hl-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.jezt-hl-empty {
    text-align: center;
    padding: 40px 20px;
    font-size: 14px;
}

.jezt-hl-empty-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.jezt-hl-empty p {
    margin: 0 0 10px 0;
    opacity: 0.5;
}

.jezt-hl-empty-guide {
    font-size: 12.5px;
    line-height: 1.6;
    opacity: 0.45 !important;
    background: color-mix(in srgb, CanvasText 5%, Canvas 95%);
    border-radius: var(--jezt-hl-radius);
    padding: 12px 14px;
    text-align: left;
}

/* ---- Highlight Kartları ---- */
.jezt-hl-card {
    background: color-mix(in srgb, Canvas 90%, CanvasText 10%);
    border: 1px solid var(--jezt-hl-border);
    border-left: 3px solid var(--jezt-hl-accent);
    border-radius: var(--jezt-hl-radius);
    padding: 12px 14px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.55;
    position: relative;
    animation: jezt-hl-fadein 0.2s ease;
}

@keyframes jezt-hl-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.jezt-hl-card-text {
    margin: 0 0 8px 0;
    word-break: break-word;
    color: var(--jezt-hl-text);
}

.jezt-hl-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    opacity: 0.55;
    gap: 8px;
}

.jezt-hl-card-meta a {
    color: var(--jezt-hl-accent);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.jezt-hl-card-meta a:hover {
    text-decoration: underline;
}

.jezt-hl-card-delete {
    background: none;
    border: none;
    color: var(--jezt-hl-text);
    cursor: pointer;
    opacity: 0.4;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: opacity 0.15s, background 0.15s;
    white-space: nowrap;
}

.jezt-hl-card-delete:hover {
    opacity: 1;
    background: color-mix(in srgb, CanvasText 10%, Canvas 90%);
}

/* Devamını gör/gizle butonu */
.jezt-hl-card-expand {
    background: none;
    border: none;
    color: var(--jezt-hl-accent);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    padding: 2px 0;
    margin-bottom: 6px;
    display: inline-block;
    transition: opacity 0.15s;
}

.jezt-hl-card-expand:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* ---- Panel Footer ---- */
.jezt-hl-panel-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--jezt-hl-border);
    flex-shrink: 0;
}

.jezt-hl-btn-clear {
    width: 100%;
    padding: 8px;
    background: none;
    border: 1px solid var(--jezt-hl-border);
    border-radius: var(--jezt-hl-radius);
    color: var(--jezt-hl-text);
    opacity: 0.6;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    transition: opacity 0.15s, border-color 0.15s;
}

.jezt-hl-btn-clear:hover {
    opacity: 1;
    border-color: #ef4444;
    color: #ef4444;
}

.jezt-hl-btn-clear.is-confirming {
    opacity: 1;
    border-color: #ef4444;
    color: #ef4444;
    animation: jezt-hl-pulse 0.3s ease;
}

@keyframes jezt-hl-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* ---- Sayfa içi highlight vurgusu ---- */
.jezt-hl-marked {
    background: color-mix(in srgb, LinkText 18%, transparent);
    border-radius: 2px;
    padding: 1px 0;
    cursor: pointer;
    transition: background 0.15s;
}

.jezt-hl-marked:hover {
    background: color-mix(in srgb, LinkText 30%, transparent);
}

/* ---- Mobil: Sağdan kayan popup ---- */
.jezt-hl-popup.is-mobile {
    position: fixed;
    right: 0;
    top: calc(50% - 20px);
    left: auto !important;
    transform: translateX(100%) translateY(-50%);
    border-radius: var(--jezt-hl-radius) 0 0 var(--jezt-hl-radius);
    border-right: none;
    box-shadow: -2px 0 12px var(--jezt-hl-shadow);
    padding: 12px 16px;
    font-size: 14px;
}

.jezt-hl-popup.is-mobile.is-visible {
    transform: translateX(0) translateY(-50%);
}

/* ---- Drag Handle (mobilde bottom sheet için) ---- */
.jezt-hl-panel-drag {
    display: none;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
    /* Bottom sheet */
    .jezt-hl-panel {
        width: 100vw;
        max-width: 100vw;
        top: auto;
        bottom: 0;
        right: 0;
        height: 70vh;
        height: 70dvh;
        border-radius: 16px 16px 0 0;
        border-left: none;
        border-top: 1px solid var(--jezt-hl-border);
        box-shadow: 0 -4px 24px var(--jezt-hl-shadow);
        transform: translateY(100%);
    }
    .jezt-hl-panel.is-open {
        transform: translateY(0);
    }
    .jezt-hl-panel-drag {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 12px 0 4px;
        cursor: grab;
        flex-shrink: 0;
    }
    .jezt-hl-panel-drag::after {
        content: '';
        width: 36px;
        height: 4px;
        background: var(--jezt-hl-border);
        border-radius: 2px;
    }
    .jezt-hl-toggle {
        width: 30px;
        height: 60px;
        font-size: 12px;
    }
    .jezt-hl-toggle svg {
        width: 16px;
        height: 16px;
    }
}
