/**
 * RE::SPARKS Styles
 * =================
 * Gold-Orange theme (Adobe Illustrator inspired)
 * Compatible with RE::DACT and RE::AI FLOW design system
 */

/* =============================================================================
   SPARKS COLOR VARIABLES
   ============================================================================= */

:root {
    /* Sparks uses theme accent color - adapts to current color mode */
    --spark-gold: var(--color-accent, #1a1a1a);
    --spark-orange: var(--color-accent-hover, #000000);
    --spark-amber: var(--color-accent, #1a1a1a);
    --spark-light: var(--color-border-medium, #ccc);
    --spark-dark: var(--color-text-primary, #1a1a1a);

    /* Gradient - uses accent color */
    --spark-gradient: var(--color-accent, #1a1a1a);
    --spark-gradient-subtle: linear-gradient(135deg, rgba(var(--color-overlay-dark), 0.08) 0%, rgba(var(--color-overlay-dark), 0.03) 100%);

    /* Glow - subtle for non-orange themes */
    --spark-glow: 0 0 8px rgba(var(--color-overlay-dark), 0.15);
    --spark-glow-intense: 0 0 12px rgba(var(--color-overlay-dark), 0.25);
}

/* Orange theme - restore gold-orange Sparks look */
body.theme-orange {
    --spark-gold: #FF9A00;
    --spark-orange: #FF6D00;
    --spark-amber: #FFAB00;
    --spark-light: #FFD180;
    --spark-dark: #E65100;
    --spark-gradient: linear-gradient(135deg, #FF9A00 0%, #FF6D00 100%);
    --spark-gradient-subtle: linear-gradient(135deg, rgba(255,154,0,0.15) 0%, rgba(255,109,0,0.05) 100%);
    --spark-glow: 0 0 12px rgba(255,154,0,0.4);
    --spark-glow-intense: 0 0 20px rgba(255,154,0,0.6);
}

body.theme-orange .idea-label {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
    color: var(--spark-orange);
    border-color: rgba(255,154,0,0.3);
}

body.theme-orange .idea-input {
    color: var(--spark-gold);
}

/* Dark Sparks theme - orange accent */
body.theme-dark-sparks {
    --spark-gold: #FF9A00;
    --spark-orange: #FF6D00;
    --spark-amber: #FFAB00;
    --spark-light: #FFD180;
    --spark-dark: #E65100;
    --spark-gradient: linear-gradient(135deg, #FF9A00 0%, #FF6D00 100%);
    --spark-gradient-subtle: linear-gradient(135deg, rgba(255,154,0,0.15) 0%, rgba(255,109,0,0.05) 100%);
    --spark-glow: 0 0 12px rgba(255,154,0,0.4);
    --spark-glow-intense: 0 0 20px rgba(255,154,0,0.6);
}

body.theme-dark-sparks .idea-label {
    background: linear-gradient(135deg, #3d2a1a 0%, #2a1f14 100%);
    color: var(--spark-gold);
    border-color: rgba(255,154,0,0.3);
}

body.theme-dark-sparks .idea-input {
    color: var(--spark-gold);
}

/* Blue theme - idea box */
body.theme-blue .idea-label {
    background: linear-gradient(135deg, #e8f4fc 0%, #d4e8f7 100%) !important;
    color: #1e3a5f !important;
    border-color: rgba(30, 58, 95, 0.3) !important;
}

body.theme-blue .idea-input {
    color: #1e3a5f !important;
}

/* Red theme - idea box */
body.theme-red .idea-label {
    background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%) !important;
    color: #b91c1c !important;
    border-color: rgba(185, 28, 28, 0.3) !important;
}

body.theme-red .idea-input {
    color: #b91c1c !important;
}

/* Orange themes - restore gold-orange spark boxes */
body.theme-orange .spark-box {
    background: rgba(255, 154, 0, 0.08) !important;
    border: 1px solid rgba(255, 154, 0, 0.25) !important;
}

body.theme-orange .spark-box.active {
    border-left: 3px solid #FF9A00 !important;
}

body.theme-orange .spark-box-icon {
    background: rgba(255, 154, 0, 0.15) !important;
    color: #FF9A00 !important;
}

body.theme-orange .spark-box-icon svg {
    stroke: #FF9A00 !important;
}

body.theme-dark-sparks .spark-box {
    background: rgba(255, 154, 0, 0.1) !important;
    border: 1px solid rgba(255, 154, 0, 0.25) !important;
}

body.theme-dark-sparks .spark-box.active {
    border-left: 3px solid #FF9A00 !important;
}

body.theme-dark-sparks .spark-box-icon {
    background: rgba(255, 154, 0, 0.2) !important;
    color: #FF9A00 !important;
}

body.theme-dark-sparks .spark-box-icon svg {
    stroke: #FF9A00 !important;
}

/* Blue theme - spark boxes use blue accent */
body.theme-blue .spark-box {
    background: rgba(30, 58, 95, 0.08) !important;
    border: 1px solid rgba(30, 58, 95, 0.2) !important;
}

body.theme-blue .spark-box.active {
    border-left: 3px solid #1e3a5f !important;
}

body.theme-blue .spark-box-icon {
    background: rgba(30, 58, 95, 0.15) !important;
    color: #1e3a5f !important;
}

body.theme-blue .spark-box-icon svg {
    stroke: #1e3a5f !important;
}

/* Red theme - spark boxes use red accent */
body.theme-red .spark-box {
    background: rgba(185, 28, 28, 0.08) !important;
    border: 1px solid rgba(185, 28, 28, 0.2) !important;
}

body.theme-red .spark-box.active {
    border-left: 3px solid #b91c1c !important;
}

body.theme-red .spark-box-icon {
    background: rgba(185, 28, 28, 0.15) !important;
    color: #b91c1c !important;
}

body.theme-red .spark-box-icon svg {
    stroke: #b91c1c !important;
}

/* Editor tabs with Sparks content - use theme colors */
.editor-tab.sparks-tab {
    color: var(--spark-gold) !important;
}

.editor-tab.sparks-tab .prefix-span {
    color: var(--spark-gold) !important;
}

/* Orange themes - gold tabs */
body.theme-orange .editor-tab.sparks-tab,
body.theme-dark-sparks .editor-tab.sparks-tab {
    color: #FF9A00 !important;
}

body.theme-orange .editor-tab.sparks-tab .prefix-span,
body.theme-dark-sparks .editor-tab.sparks-tab .prefix-span {
    color: #FF9A00 !important;
}

/* Blue theme - tabs and ISKRY header */
body.theme-blue .editor-tab.sparks-tab,
body.theme-blue .editor-tab.sparks-tab .prefix-span {
    color: #1e3a5f !important;
}

body.theme-blue .sparks-header-title {
    color: #1e3a5f !important;
}

body.theme-blue .sparks-header-icon svg {
    stroke: #1e3a5f !important;
}

body.theme-blue .sidebar-section-sparks .create-item .create-prefix svg {
    stroke: #1e3a5f !important;
}

body.theme-blue .sparks-title {
    color: #1e3a5f !important;
}

/* Red theme - tabs and ISKRY header */
body.theme-red .editor-tab.sparks-tab,
body.theme-red .editor-tab.sparks-tab .prefix-span {
    color: #b91c1c !important;
}

body.theme-red .sparks-header-title {
    color: #b91c1c !important;
}

body.theme-red .sparks-header-icon svg {
    stroke: #b91c1c !important;
}

body.theme-red .sidebar-section-sparks .create-item .create-prefix svg {
    stroke: #b91c1c !important;
}

body.theme-red .sparks-title {
    color: #b91c1c !important;
}

/* =============================================================================
   IMPORTED SPARKS IN EDITOR - Override inline styles with theme colors
   ============================================================================= */

/* Target spark blocks in editor (divs with border-left inline style) */
#editorNotes > div[style*="border-left"],
#editorMain > div[style*="border-left"] {
    border-left-color: var(--color-accent) !important;
}

#editorNotes > div[style*="border-left"] > div:first-child,
#editorMain > div[style*="border-left"] > div:first-child {
    color: var(--color-accent) !important;
}

/* =============================================================================
   SIDEBAR SECTION - ISKRY
   ============================================================================= */

/* Sekcja ISKRY - 1/3 dostępnej przestrzeni, z kreską u góry */
.sidebar-section-sparks {
    flex: 1;
    border-top: 1px solid var(--color-border-light, #e5e5e5);
    padding-top: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Sparks header with ISKRY label */
.sparks-header {
    display: flex;
    align-items: center;
    padding: 8px;
    margin-bottom: 4px;
}

.sparks-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--spark-gold);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.sparks-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.sparks-header-icon svg {
    width: 14px;
    height: 14px;
    stroke: var(--spark-gold);
}

/* Sparks create button - use create-prefix for icon */
.sidebar-section-sparks .create-item .create-prefix {
    display: flex;
    align-items: center;
}

.sidebar-section-sparks .create-item .create-prefix svg {
    width: 14px;
    height: 14px;
    stroke: var(--spark-gold);
}

/* ISKRY title in gold */
.sidebar-section-sparks .sparks-title {
    color: var(--spark-gold);
    font-weight: 600;
    letter-spacing: 1px;
}

/* Sparks List - własny slider */
.sparks-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 8px 8px;
    margin-top: 5px;
}

.sparks-list::-webkit-scrollbar {
    width: 4px;
}

.sparks-list::-webkit-scrollbar-thumb {
    background: var(--border, #333);
    border-radius: 2px;
}

/* Spark Box - copied from Sparks app */
.spark-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    /* Use theme colors - override inline styles from JS */
    background: rgba(var(--color-overlay-dark), 0.04) !important;
    border: 1px solid rgba(var(--color-overlay-dark), 0.12) !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.spark-box:hover {
    filter: brightness(0.97);
}

.spark-box.active {
    border-left: 3px solid var(--spark-gold) !important;
}

.spark-box {
    position: relative;
}

.spark-box-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border: none;
    background: transparent;
    color: var(--color-text-muted, #999);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.spark-box:hover .spark-box-delete {
    opacity: 0.5;
}

.spark-box-delete:hover {
    opacity: 1 !important;
    background: rgba(255, 59, 48, 0.15);
    color: #ff3b30;
}

.spark-box-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    /* Override inline styles - use theme colors */
    background: rgba(var(--color-overlay-dark), 0.08) !important;
    color: var(--spark-gold) !important;
}

.spark-box-icon svg {
    width: 14px;
    height: 14px;
    stroke: var(--spark-gold) !important;
}

.spark-box-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.spark-box-title {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-primary, #333);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spark-box-stats {
    font-size: 10px;
    color: var(--color-text-tertiary, #888);
}

/* Spark Popup - copied from Sparks app */
.spark-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(var(--color-overlay-dark), 0.6);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.spark-popup {
    background: var(--color-bg-primary, #fff);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.2s;
}

.spark-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    color: var(--color-accent-text);
    /* Override inline styles - use theme accent color */
    background: var(--color-accent) !important;
}

.spark-popup-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

.spark-popup-title svg {
    width: 20px;
    height: 20px;
}

.spark-popup-close {
    width: 32px;
    height: 32px;
    background: rgba(var(--color-overlay-light), 0.2);
    border: none;
    border-radius: 6px;
    color: var(--color-accent-text);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spark-popup-close:hover {
    background: rgba(var(--color-overlay-light), 0.3);
}

.spark-popup-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.spark-popup-section {
    margin-bottom: 20px;
}

.spark-popup-section:last-child {
    margin-bottom: 0;
}

.spark-popup-section label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-tertiary, #888);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.spark-popup-content {
    padding: 12px;
    background: var(--color-bg-secondary, #f5f5f5);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: 6px;
    min-height: 60px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-primary, #333);
}

.spark-popup-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border-light, #e0e0e0);
    justify-content: flex-end;
}

.spark-popup-footer button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--color-accent-text);
    /* Override inline styles - use theme accent color */
    background: var(--color-accent) !important;
}

.spark-popup-footer button.danger {
    background: var(--color-danger, #e74c3c) !important;
}

/* Add spark button in popup */
.spark-add-btn {
    background: var(--color-accent);
    color: var(--color-accent-text);
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.15s;
}

.spark-add-btn:hover {
    opacity: 0.85;
}

.spark-add-btn span {
    font-size: 16px;
    font-weight: 500;
}

/* Popup form inputs */
.spark-popup-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: 6px;
    font-size: 14px;
    background: var(--color-bg-primary, #fff);
    color: var(--color-text-primary, #333);
    outline: none;
    transition: border-color 0.15s;
}

.spark-popup-input:focus {
    border-color: var(--color-accent);
}

.spark-popup-input::placeholder {
    color: var(--color-text-muted, #999);
}

/* Color picker */
.spark-color-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.spark-color-option {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s;
}

.spark-color-option:hover {
    transform: scale(1.1);
}

.spark-color-option.selected {
    border-color: var(--color-text-primary, #333);
    box-shadow: 0 0 0 2px var(--color-bg-primary, #fff);
}

/* Popup buttons */
.spark-popup-btn-primary {
    background: var(--color-accent);
    color: var(--color-accent-text);
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.spark-popup-btn-primary:hover {
    opacity: 0.85;
}

.spark-popup-btn-secondary {
    background: var(--color-bg-tertiary, #f0f0f0);
    color: var(--color-text-primary, #333);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

/* Header actions (voice button + close) */
.spark-popup-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Voice input button in header - matches close button exactly */
.spark-popup-header .spark-voice-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--color-overlay-light), 0.2);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--color-accent-text);
    transition: all 0.15s;
}

.spark-popup-header .spark-voice-btn:hover {
    background: rgba(var(--color-overlay-light), 0.3);
}

.spark-popup-header .spark-voice-btn svg {
    width: 18px;
    height: 18px;
}

.spark-popup-header .spark-voice-btn.recording {
    background: rgba(255, 255, 255, 0.9);
    color: var(--color-accent);
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.85; }
}

.spark-popup-btn-secondary:hover {
    background: var(--color-bg-secondary, #e8e8e8);
}

/* Spark items list inside popup */
.spark-popup-items-list .spark-item {
    padding: 10px;
    background: var(--color-bg-tertiary, #f0f0f0);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: 6px;
    transition: all 0.15s;
}

.spark-popup-items-list .spark-item:hover {
    background: var(--color-bg-secondary, #e8e8e8);
    border-color: var(--color-accent);
}

.spark-signal-badge {
    background: var(--spark-dark);
    color: white;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 10px;
    font-weight: 600;
}

.spark-action-btn {
    width: 24px;
    height: 24px;
    padding: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.spark-action-btn:hover {
    background: rgba(255, 154, 0, 0.15);
}

.spark-action-btn svg {
    width: 14px;
    height: 14px;
    stroke: var(--spark-gold, #FF9A00);
}

.spark-delete-btn:hover {
    background: rgba(255, 100, 100, 0.15);
}

.spark-delete-btn:hover svg {
    stroke: #e74c3c;
}

/* Empty State */
.sparks-empty {
    text-align: center;
    padding: 24px 16px;
    color: var(--dim, #666);
}

.sparks-empty-icon {
    width: 40px;
    height: 40px;
    margin: 0 auto 12px;
    opacity: 0.4;
}

.sparks-empty-icon svg {
    width: 100%;
    height: 100%;
    stroke: var(--spark-gold);
}

.sparks-empty-text {
    font-size: 11px;
    line-height: 1.5;
}

/* =============================================================================
   PROMOTE TO SPARK BUTTON (in Notepad toolbar)
   ============================================================================= */

.spark-promote-btn {
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0.85;
}

.spark-promote-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--spark-gold, #FF9A00);
    fill: none;
    transition: all 0.2s;
}

.spark-promote-btn:hover {
    opacity: 1;
}

.spark-promote-btn:hover svg {
    stroke: var(--color-accent-hover, var(--spark-light, #FFD93D));
    filter: var(--spark-glow);
    transform: scale(1.1);
}

.spark-promote-btn.active svg {
    stroke: var(--color-accent-hover, var(--spark-light, #FFD93D));
    filter: var(--spark-glow-intense);
}

/* =============================================================================
   SPARK MODAL - Topic Selection
   ============================================================================= */

.spark-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.spark-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.spark-modal {
    background: var(--panel, #0a0a0a);
    border: 1px solid var(--border, #333);
    border-radius: 8px;
    width: 90%;
    max-width: 420px;
    max-height: 80vh;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.spark-modal-overlay.active .spark-modal {
    transform: translateY(0);
}

.spark-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #333);
    background: var(--card, #111);
}

.spark-modal-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--spark-gold);
    display: flex;
    align-items: center;
    gap: 8px;
}

.spark-modal-title svg {
    width: 18px;
    height: 18px;
}

.spark-modal-close {
    width: 28px;
    height: 28px;
    background: var(--input, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 4px;
    color: var(--dim, #888);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.spark-modal-close:hover {
    background: var(--danger, #ef4444);
    border-color: var(--danger, #ef4444);
    color: white;
}

.spark-modal-close svg {
    width: 14px;
    height: 14px;
}

/* Search in modal */
.spark-modal-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #333);
}

.spark-search-input {
    width: 100%;
    background: var(--input, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 4px;
    padding: 10px 12px;
    color: var(--text, #fff);
    font-size: 12px;
    font-family: inherit;
}

.spark-search-input:focus {
    outline: none;
    border-color: var(--spark-gold);
}

.spark-search-input::placeholder {
    color: var(--dim, #666);
}

/* Topic list in modal */
.spark-modal-topics {
    max-height: 280px;
    overflow-y: auto;
    padding: 8px;
}

.spark-modal-topics::-webkit-scrollbar {
    width: 4px;
}

.spark-modal-topics::-webkit-scrollbar-thumb {
    background: var(--border, #333);
    border-radius: 2px;
}

.spark-modal-topic-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 4px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border, #333);
    background: var(--card, #111);
}

.spark-modal-topic-item:hover {
    background: var(--input, #1a1a1a);
    border-color: var(--spark-gold);
}

.spark-modal-topic-item.selected {
    background: var(--spark-gradient);
    border-color: var(--spark-gold);
}

.spark-modal-topic-item.selected .spark-modal-topic-title,
.spark-modal-topic-item.selected .spark-modal-topic-desc {
    color: var(--color-text-primary);
}

.spark-modal-topic-item.selected svg {
    stroke: var(--color-text-primary);
}

.spark-modal-topic-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--input, #1a1a1a);
}

.spark-modal-topic-icon svg {
    width: 18px;
    height: 18px;
}

.spark-modal-topic-info {
    flex: 1;
    min-width: 0;
}

.spark-modal-topic-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text, #fff);
    margin-bottom: 2px;
}

.spark-modal-topic-desc {
    font-size: 11px;
    color: var(--dim, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Create new topic in modal */
.spark-modal-create {
    padding: 12px 16px;
    border-top: 1px solid var(--border, #333);
}

.spark-create-btn {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--border, #444);
    color: var(--dim, #888);
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.spark-create-btn svg {
    width: 14px;
    height: 14px;
}

.spark-create-btn:hover {
    border-color: var(--spark-gold);
    color: var(--spark-gold);
}

.spark-create-btn:hover svg {
    stroke: var(--spark-gold);
}

/* Footer with confirm */
.spark-modal-footer {
    display: flex;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid var(--border, #333);
    background: var(--card, #111);
}

.spark-modal-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.spark-modal-btn svg {
    width: 14px;
    height: 14px;
}

.spark-modal-btn.cancel {
    background: var(--input, #1a1a1a);
    border: 1px solid var(--border, #444);
    color: var(--dim, #888);
}

.spark-modal-btn.cancel:hover {
    border-color: var(--text, #fff);
    color: var(--text, #fff);
}

.spark-modal-btn.confirm {
    background: var(--spark-gradient);
    border: none;
    color: var(--color-text-primary);
    font-weight: 600;
}

.spark-modal-btn.confirm:hover {
    box-shadow: var(--spark-glow);
}

.spark-modal-btn.confirm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* =============================================================================
   SPARK TIMELINE VIEW
   ============================================================================= */

.spark-timeline {
    padding: 16px;
}

.spark-timeline-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border, #333);
}

.spark-timeline-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--spark-gradient-subtle);
    border-radius: 10px;
    border: 1px solid var(--spark-gold);
}

.spark-timeline-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--spark-gold);
}

.spark-timeline-info h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text, #fff);
    margin: 0 0 4px 0;
}

.spark-timeline-info p {
    font-size: 12px;
    color: var(--dim, #888);
    margin: 0;
}

/* Timeline items */
.spark-timeline-item {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: var(--card, #111);
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border, #333);
    transition: all 0.2s;
}

.spark-timeline-item:hover {
    border-color: var(--spark-gold);
    transform: translateY(-1px);
}

.spark-timeline-item.pinned {
    border-color: var(--spark-gold);
    background: var(--spark-gradient-subtle);
}

.spark-item-source {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--input, #1a1a1a);
    border-radius: 6px;
    flex-shrink: 0;
}

.spark-item-source svg {
    width: 20px;
    height: 20px;
    stroke: var(--dim, #888);
}

.spark-item-content {
    flex: 1;
    min-width: 0;
}

.spark-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text, #fff);
    margin-bottom: 4px;
}

.spark-item-preview {
    font-size: 11px;
    color: var(--dim, #888);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.spark-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 10px;
    color: var(--dim, #666);
}

.spark-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.spark-timeline-item:hover .spark-item-actions {
    opacity: 1;
}

.spark-item-action-btn {
    width: 24px;
    height: 24px;
    background: var(--input, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.spark-item-action-btn svg {
    width: 12px;
    height: 12px;
    stroke: var(--dim, #888);
}

.spark-item-action-btn:hover {
    background: var(--spark-gold);
    border-color: var(--spark-gold);
}

.spark-item-action-btn:hover svg {
    stroke: var(--color-text-primary);
}

/* =============================================================================
   CONTEXT HIGHLIGHT (Lasso Effect)
   ============================================================================= */

.context-highlight-spark {
    background-color: rgba(255, 154, 0, 0.15);
    border-radius: 2px;
}

.context-lasso-spark {
    position: relative;
    background-color: rgba(255, 154, 0, 0.05);
    
    /* Marching ants border */
    background-image: 
        linear-gradient(90deg, var(--spark-gold) 50%, transparent 50%), 
        linear-gradient(90deg, var(--spark-gold) 50%, transparent 50%), 
        linear-gradient(0deg, var(--spark-gold) 50%, transparent 50%), 
        linear-gradient(0deg, var(--spark-gold) 50%, transparent 50%);
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
    background-size: 15px 2px, 15px 2px, 2px 15px, 2px 15px;
    background-position: 0 0, 0 100%, 0 0, 100% 0;
    
    animation: marching-ants-spark 1s linear infinite;
}

@keyframes marching-ants-spark {
    0% { background-position: 0 0, 100% 100%, 0 100%, 100% 0; }
    100% { background-position: 20px 0, 80px 100%, 0 80px, 100% 20px; }
}

/* =============================================================================
   CREATE TOPIC FORM (inline in modal)
   ============================================================================= */

.spark-create-form {
    padding: 16px;
}

.spark-form-group {
    margin-bottom: 12px;
}

.spark-form-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--dim, #888);
    margin-bottom: 6px;
}

.spark-form-input {
    width: 100%;
    background: var(--input, #1a1a1a);
    border: 1px solid var(--border, #333);
    border-radius: 4px;
    padding: 10px 12px;
    color: var(--text, #fff);
    font-size: 12px;
    font-family: inherit;
}

.spark-form-input:focus {
    outline: none;
    border-color: var(--spark-gold);
}

.spark-form-textarea {
    min-height: 80px;
    resize: vertical;
}

/* Color picker row */
.spark-color-row {
    display: flex;
    gap: 8px;
}

.spark-color-option {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.spark-color-option:hover {
    transform: scale(1.1);
}

.spark-color-option.selected {
    border-color: white;
    box-shadow: 0 0 0 2px var(--bg, #000);
}

/* =============================================================================
   TIMELINE VIEW - Lista iskier w temacie
   ============================================================================= */

.spark-timeline-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.spark-timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: #1a1a1a;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: all 0.2s;
}

.spark-timeline-item:hover {
    background: var(--color-bg-secondary);
    border-color: var(--spark-gold);
}

.spark-timeline-content {
    flex: 1;
    min-width: 0;
}

.spark-timeline-preview {
    font-size: 13px;
    color: #e0e0e0;
    line-height: 1.5;
    word-break: break-word;
}

.spark-timeline-meta {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
}

.spark-timeline-date {
    color: var(--color-text-secondary);
}

.spark-timeline-source {
    color: var(--spark-gold);
    cursor: pointer;
}

.spark-timeline-source:hover {
    text-decoration: underline;
}

.spark-timeline-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.spark-action-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
}

.spark-action-btn:hover {
    background: #252525;
    border-color: var(--spark-gold);
}

.spark-action-btn.spark-action-delete:hover {
    border-color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.spark-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* =============================================================================
   SPARK NOTE PREVIEW (in modal)
   ============================================================================= */

.spark-note-preview {
    padding: 12px;
    background: var(--spark-gradient-subtle);
    border: 1px solid var(--spark-gold);
    border-radius: 8px;
    margin-bottom: 16px;
}

.spark-preview-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--spark-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.spark-preview-content {
    font-size: 12px;
    color: var(--text-secondary, #ccc);
    line-height: 1.5;
    max-height: 80px;
    overflow-y: auto;
    font-style: italic;
}

/* Open button in topic list */
.spark-open-btn {
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border, #333);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dim, #888);
    transition: all 0.2s;
    margin-left: auto;
    flex-shrink: 0;
}

.spark-open-btn:hover {
    background: var(--spark-gradient);
    border-color: var(--spark-gold);
    color: var(--color-text-primary);
}

.spark-open-btn svg {
    width: 14px;
    height: 14px;
}

/* Form hint */
.spark-form-hint {
    font-size: 10px;
    color: var(--dim, #888);
    margin-top: 6px;
    font-style: italic;
}

/* =============================================================================
   SPARK IMPORT MODAL (* and # commands)
   ============================================================================= */

.spark-import-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
}

.spark-import-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s;
    border-bottom: 1px solid var(--border, #222);
}

.spark-import-item:hover {
    background: rgba(255, 154, 0, 0.1);
}

.spark-import-item:last-child {
    border-bottom: none;
}

.spark-import-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--spark-gradient-subtle, rgba(255, 154, 0, 0.1));
    border-radius: 8px;
    border: 1px solid var(--spark-gold, #FF9A00);
    flex-shrink: 0;
}

.spark-import-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--spark-gold, #FF9A00);
}

.spark-import-info {
    flex: 1;
    min-width: 0;
}

.spark-import-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.spark-import-count {
    font-size: 11px;
    color: var(--dim, #888);
    margin-top: 2px;
}

.spark-import-preview {
    font-size: 11px;
    color: var(--dim, #888);
    margin-top: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.spark-import-link {
    font-size: 10px;
    color: var(--spark-gold, #FF9A00);
    margin-top: 4px;
}

.spark-import-arrow {
    font-size: 20px;
    color: var(--dim, #666);
    flex-shrink: 0;
}

.spark-import-spark .spark-import-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
    background: transparent;
    border: none;
}

/* Table preview */
.spark-table-preview {
    padding: 16px;
}

.spark-table-preview p {
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text, #fff);
}

.spark-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.spark-preview-table th,
.spark-preview-table td {
    padding: 8px;
    border: 1px solid var(--border, #333);
    text-align: left;
}

.spark-preview-table th {
    background: var(--card, #111);
    color: var(--spark-gold, #FF9A00);
    font-weight: 600;
}

.spark-preview-table td {
    color: var(--dim, #888);
}

/* Import actions */
.spark-import-actions {
    display: flex;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid var(--border, #333);
}

.spark-btn {
    padding: 10px 16px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.spark-btn-secondary {
    background: var(--input, #1a1a1a);
    border: 1px solid var(--border, #444);
    color: var(--dim, #888);
}

.spark-btn-secondary:hover {
    border-color: var(--text, #fff);
    color: var(--text, #fff);
}

.spark-btn-primary {
    background: var(--spark-gradient);
    border: none;
    color: var(--color-text-primary);
    font-weight: 600;
    flex: 1;
}

.spark-btn-primary:hover {
    box-shadow: var(--spark-glow);
}

.spark-btn-back {
    margin: 0 16px 8px;
}

/* =============================================================================
   SPARKS MODE IN NOTEPAD (copied from Sparks app)
   ============================================================================= */

/* Sparks editor box - uses theme background */
.notatnik-section.sparks-mode {
    display: flex;
    flex-direction: column;
    background: var(--color-bg-paper-main, #FFFFFF) !important;
}

.notatnik-section.sparks-mode .editor {
    background: var(--color-bg-paper-main, #FFFFFF) !important;
}

/* Idea header - uses theme colors */
.idea-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 48px 48px 12px 48px;
    background: var(--color-bg-paper-main, #FFFFFF);
    flex-shrink: 0;
}


.idea-label {
    /* Override inline styles - use theme colors */
    background: var(--color-bg-tertiary, #f5f5f5) !important;
    color: var(--spark-gold) !important;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 18px;
    white-space: nowrap;
    border: 1px solid rgba(var(--color-overlay-dark), 0.15) !important;
    flex-shrink: 0;
}

.idea-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text-primary, #1a1a1a);
    outline: none;
    padding: 6px 0;
    min-height: 27px;
    line-height: 1;
}

.idea-input:empty::before {
    content: attr(data-placeholder);
    color: var(--muted, #999);
    font-weight: 400;
}

/* =============================================================================
   SPARK ITEMS PANEL (appears on # shortcut) - copied from Sparks app
   ============================================================================= */

.spark-items-panel {
    position: fixed;
    top: 56px;
    right: -360px;
    width: 350px;
    height: calc(100vh - 56px);
    height: calc(100svh - 56px);
    background: var(--color-bg-primary, #fff);
    border-left: 1px solid var(--color-border-light, #e0e0e0);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.spark-items-panel.visible {
    right: 0;
}

.spark-items-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light, #e0e0e0);
    /* Use theme accent color */
    background: var(--color-accent) !important;
    color: var(--color-accent-text);
}

.spark-items-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
}

.spark-items-panel-title svg {
    width: 18px;
    height: 18px;
}

.spark-items-panel-close {
    width: 28px;
    height: 28px;
    background: rgba(var(--color-overlay-light), 0.2);
    border: none;
    border-radius: 4px;
    color: var(--color-accent-text);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spark-items-panel-close:hover {
    background: rgba(var(--color-overlay-light), 0.3);
}

.spark-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Spark item card - copied from Sparks app */
.spark-item {
    position: relative;
    padding: 12px;
    background: var(--color-bg-secondary, #f5f5f5);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    overflow: visible;
}

.spark-item:hover {
    border-color: var(--spark-gold);
    transform: translateX(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

/* Edit button on spark item */
.spark-item-edit {
    position: absolute;
    top: 8px;
    right: 36px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-secondary, #f5f5f5);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 10;
}

.spark-item-edit svg {
    width: 12px;
    height: 12px;
    color: var(--color-text-tertiary, #888);
}

.spark-item:hover .spark-item-edit {
    opacity: 1;
    visibility: visible;
}

.spark-item-edit:hover {
    background: var(--spark-gold);
    border-color: var(--spark-gold);
}

.spark-item-edit:hover svg {
    color: var(--color-text-primary);
}

/* Delete button on spark item */
.spark-item-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-secondary, #f5f5f5);
    border: 1px solid var(--color-border-light, #e0e0e0);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s, visibility 0.15s;
    z-index: 10;
    font-size: 16px;
    color: var(--color-text-tertiary, #888);
}

.spark-item:hover .spark-item-delete {
    opacity: 1;
    visibility: visible;
}

.spark-item-delete:hover {
    background: rgba(255, 59, 48, 0.9);
    border-color: rgba(255, 59, 48, 0.9);
    color: var(--color-accent-text);
}

.spark-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.spark-topic-badge {
    padding: 2px 8px;
    /* Override inline styles - use theme accent color */
    background: rgba(var(--color-accent-rgb, 0,0,0), 0.1) !important;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
    color: var(--color-accent) !important;
}

.spark-date {
    font-size: 10px;
    color: var(--color-text-tertiary, #888);
    margin-left: auto;
}

.spark-content {
    font-size: 12px;
    color: var(--color-text-secondary, #666);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.spark-source {
    font-size: 10px;
    color: var(--color-text-tertiary, #888);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.spark-source svg {
    width: 12px;
    height: 12px;
}

/* Spark item links - use theme colors */
.spark-item a {
    color: var(--spark-gold) !important;
}

body.theme-orange .spark-item a,
body.theme-dark-sparks .spark-item a {
    color: #FF9A00 !important;
}

.spark-items-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-tertiary, #888);
}

.spark-items-empty svg {
    width: 48px;
    height: 48px;
    stroke: var(--spark-gold);
    opacity: 0.4;
    margin-bottom: 12px;
}

.spark-items-empty p {
    font-size: 13px;
    line-height: 1.5;
}

