/* Universal Context Menu Styles */

.universal-context-menu {
    position: fixed;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 6px rgba(0, 0, 0, 0.05);
    z-index: 10000;
    min-width: 200px;
    max-width: 280px;
    padding: 6px 0;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 14px;
    backdrop-filter: blur(8px);
    animation: contextMenuShow 0.15s ease-out;
    user-select: none;
}

.universal-context-menu.hidden {
    display: none;
}

@keyframes contextMenuShow {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.context-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: #374151;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    gap: 12px;
}
.context-menu-item[data-action="toggle-ai-section"] { font-weight: 600; }
.context-menu-item[data-action="toggle-ai-section"] .context-menu-icon { color: #111827; }

.context-menu-item:hover:not(.disabled) {
    background: #f3f4f6;
    color: #111827;
}

.context-menu-item:active:not(.disabled) {
    background: #e5e7eb;
}

.context-menu-item.disabled {
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

.context-menu-item.destructive {
    color: #dc2626;
}

.context-menu-item.destructive:hover:not(.disabled) {
    background: #fef2f2;
    color: #b91c1c;
}

.context-menu-item.destructive:active:not(.disabled) {
    background: #fee2e2;
}

.context-menu-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0.7;
}

/* Toggle visual (Include in Chat) */
.context-menu-item[data-action="toggle-include-chat"] .context-menu-icon {
    width: 22px;
    height: 22px;
}
.context-menu-item[data-action="toggle-include-chat"].on .context-menu-icon {
    color: #3b82f6;
}

.context-menu-item:hover:not(.disabled) .context-menu-icon {
    opacity: 1;
}

.context-menu-item.destructive .context-menu-icon {
    color: #dc2626;
}

.context-menu-label {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.context-menu-shortcut {
    margin-left: auto;
    font-size: 12px;
    opacity: 0.6;
    font-weight: 400;
    color: #6b7280;
}

/* Scope chips bar */
.context-scope-bar {
    display: flex;
    gap: 6px;
    padding: 6px 8px 8px 8px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 4px;
}
.scope-chip {
    font-size: 11px;
    line-height: 1;
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    color: #374151;
    cursor: pointer;
}
.scope-chip.selected {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #93c5fd;
}

/* Submenu styles */
.submenu-wrapper { position: relative; }
.has-submenu { position: relative; }
.context-submenu {
    position: absolute;
    top: 0;
    left: 100%;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15), 0 4px 6px rgba(0, 0, 0, 0.05);
    z-index: 10001;
    min-width: 220px;
    padding: 6px 0;
}
.context-submenu.hidden { display: none; }
.context-menu-sublabel {
    font-size: 11px;
    color: #6b7280;
    opacity: 0.9;
}

.context-menu-separator {
    height: 1px;
    background: #e5e7eb;
    margin: 6px 0;
}

/* Submenu indicator (for future use) */
.context-menu-item .submenu-indicator {
    margin-left: auto;
    opacity: 0.5;
    transform: rotate(-90deg);
    transition: transform 0.2s ease;
}

.context-menu-item:hover .submenu-indicator {
    opacity: 0.8;
}

/* Keyboard focus support */
.context-menu-item:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    background: #eff6ff;
}

.context-menu-item.keyboard-selected {
    background: #eff6ff;
    color: #1d4ed8;
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

/* Playground side panel */
.playground-panel {
    position: fixed;
    top: 56px;
    right: 0;
    width: 420px;
    height: calc(100vh - 56px - 32px);
    background: #fff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -10px 0 25px rgba(0,0,0,0.08);
    z-index: 12000;
    display: flex;
    flex-direction: column;
}
.playground-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
}
.playground-header .pg-close { border: none; background: none; cursor: pointer; font-size: 16px; opacity: 0.7; }
.playground-header .pg-close:hover { opacity: 1; }
.playground-body { padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.playground-body .form-row { display: flex; flex-direction: column; gap: 6px; }
.playground-body .form-row.two { flex-direction: row; gap: 12px; }
.playground-body .form-row.two > div { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.playground-body input, .playground-body select, .playground-body textarea { border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px; font-size: 14px; }
.playground-body label { font-size: 12px; color: #6b7280; }
.playground-body label .light { color: #9ca3af; font-weight: 400; }
.playground-footer { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid #e5e7eb; }
.playground-footer .spacer { flex: 1; }
.playground-footer .primary { background: #3b82f6; color: #fff; border: 1px solid #3b82f6; border-radius: 6px; padding: 8px 12px; cursor: pointer; }
.playground-footer .pg-delete { background: #fff; color: #374151; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 12px; cursor: pointer; }

@media (prefers-color-scheme: dark) {
  .playground-panel { background: #1f2937; border-left-color: #374151; }
  .playground-header { border-bottom-color: #374151; }
  .playground-body input, .playground-body select, .playground-body textarea { background: #111827; color: #f9fafb; border-color: #374151; }
  .playground-footer { border-top-color: #374151; }
  .playground-footer .pg-delete { background: #1f2937; color: #d1d5db; border-color: #374151; }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .universal-context-menu {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }

    .context-menu-item {
        color: #d1d5db;
    }

    .context-menu-item:hover:not(.disabled) {
        background: #374151;
        color: #f9fafb;
    }

    .context-menu-item:active:not(.disabled) {
        background: #4b5563;
    }

    .context-menu-item.disabled {
        color: #6b7280;
    }

    .context-menu-item.destructive {
        color: #f87171;
    }

    .context-menu-item.destructive:hover:not(.disabled) {
        background: #450a0a;
        color: #fca5a5;
    }

    .context-menu-separator {
        background: #374151;
    }

    .context-scope-bar { border-bottom-color: #374151; }
    .scope-chip { background: #1f2937; border-color: #374151; color: #d1d5db; }
    .scope-chip.selected { background: #1e3a8a; border-color: #60a5fa; color: #93c5fd; }
    .context-submenu { background: #1f2937; border-color: #374151; }
    .context-menu-sublabel { color: #9ca3af; }

    .context-menu-item:focus {
        outline-color: #60a5fa;
        background: #1e3a8a;
    }
}

/* Responsive adjustments for smaller screens */
@media (max-width: 640px) {
    .universal-context-menu {
        min-width: 180px;
        max-width: 250px;
        font-size: 13px;
    }

    .context-menu-item {
        padding: 10px 14px;
        gap: 10px;
    }

    .context-menu-icon {
        width: 14px;
        height: 14px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .universal-context-menu {
        border-width: 2px;
        border-color: #000;
    }

    .context-menu-item {
        color: #000;
    }

    .context-menu-item:hover:not(.disabled) {
        background: #000;
        color: #fff;
    }

    .context-menu-separator {
        background: #000;
        height: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .universal-context-menu {
        animation: none;
    }

    .context-menu-item {
        transition: none;
    }
}

/* Modal Styles for Context Menu Actions */
.context-menu-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    backdrop-filter: blur(4px);
    animation: modalShow 0.2s ease-out;
}

@keyframes modalShow {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(4px);
    }
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 90vw;
    max-height: 90vh;
    overflow: auto;
    min-width: 320px;
    animation: modalContentShow 0.2s ease-out;
}

@keyframes modalContentShow {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h3 {
    margin: 0 0 20px 0;
    padding: 20px 20px 0 20px;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 16px;
}

.modal-actions {
    padding: 16px 20px 20px 20px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    border-top: 1px solid #f3f4f6;
    margin-top: 20px;
}

.modal-actions button {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: white;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-actions button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.modal-actions .btn-cancel {
    color: #6b7280;
}

.modal-actions .btn-new-collection,
.modal-actions .btn-replace-all {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.modal-actions .btn-new-collection:hover,
.modal-actions .btn-replace-all:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* Collection Selection Modal */
.collection-list {
    padding: 0 20px;
    max-height: 300px;
    overflow-y: auto;
}

.collection-option {
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fafafa;
}

.collection-option:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
}

.collection-name {
    font-weight: 500;
    color: #111827;
}

/* Icon Picker Modal */
.icon-grid {
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.icon-option {
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-align: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fafafa;
}

.icon-option:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
    transform: scale(1.05);
}

/* Text Formatting Modal */
.formatting-options {
    padding: 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.format-btn {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fafafa;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
}

.format-btn:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
}

/* Find & Replace Modal */
.find-replace-form {
    padding: 0 20px;
}

.find-replace-form input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    transition: border-color 0.15s ease;
}

.find-replace-form input[type="text"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.find-options {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.find-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
}

.find-options input[type="checkbox"] {
    margin: 0;
}

/* Model Selection Modal */
.model-list {
    padding: 0 20px;
    max-height: 300px;
    overflow-y: auto;
}

.model-option {
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fafafa;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-option:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
}

.model-option.selected {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.model-name {
    font-weight: 500;
}

.current-badge {
    background: #3b82f6;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Properties Modal */
.properties-list {
    padding: 0 20px;
}

.property-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.property-row:last-child {
    border-bottom: none;
}

.property-label {
    font-weight: 500;
    color: #374151;
}

.property-value {
    color: #6b7280;
    font-family: monospace;
}

/* Dark mode support for modals */
@media (prefers-color-scheme: dark) {
    .context-menu-modal {
        background: rgba(0, 0, 0, 0.7);
    }

    .modal-content {
        background: #1f2937;
        color: #f9fafb;
    }

    .modal-content h3 {
        color: #f9fafb;
        border-bottom-color: #374151;
    }

    .modal-actions {
        border-top-color: #374151;
    }

    .modal-actions button {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }

    .modal-actions button:hover {
        background: #4b5563;
        border-color: #6b7280;
    }

    .collection-option,
    .icon-option,
    .format-btn,
    .model-option {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }

    .collection-option:hover,
    .icon-option:hover,
    .format-btn:hover,
    .model-option:hover {
        background: #4b5563;
        border-color: #60a5fa;
    }

    .model-option.selected {
        background: #1e3a8a;
        border-color: #60a5fa;
        color: #93c5fd;
    }

    .find-replace-form input[type="text"] {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }

    .find-replace-form input[type="text"]:focus {
        border-color: #60a5fa;
        box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
    }

    .property-row {
        border-bottom-color: #374151;
    }

    .property-label {
        color: #d1d5db;
    }

    .property-value {
        color: #9ca3af;
    }
}

/* Responsive adjustments for modals */
@media (max-width: 640px) {
    .modal-content {
        min-width: 280px;
        margin: 20px;
    }

    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    }

    .formatting-options {
        grid-template-columns: 1fr;
    }

    .find-options {
        flex-direction: column;
        gap: 8px;
    }
} 

/* Recipe Edit Modal */
.recipe-edit-modal .modal-content {
    min-width: 500px;
    max-width: 600px;
}

.recipe-edit-form {
    padding: 0 20px;
}

.recipe-edit-form input,
.recipe-edit-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    font-family: system-ui, -apple-system, sans-serif;
    transition: border-color 0.15s ease;
}

.recipe-edit-form input:focus,
.recipe-edit-form textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.recipe-edit-form textarea {
    resize: vertical;
    min-height: 120px;
}

.modal-actions .btn-save {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.modal-actions .btn-save:hover {
    background: #059669;
    border-color: #059669;
} 