/* ====== AI RECATEGORIZATION MODAL STYLES ====== */

/* Slide-in panel from right (Figma-style) */
.correction-modal {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    max-width: 100%;
    height: 100vh;
    background: var(--bg-light, #1a1f3a);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.7);
    z-index: 99999;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.correction-modal.active {
    right: 0;
    animation: slideInFromRight 0.3s ease-out;
}

.correction-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.correction-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--info));
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.correction-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
}

.correction-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.correction-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.correction-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.correction-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-lighter);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* Product info section */
.correction-product-info {
    background: var(--bg);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.correction-product-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    word-break: break-word;
}

.correction-product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.correction-product-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Confidence badges - color-coded */
.confidence-badge-lg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.confidence-badge-lg.high {
    background: rgba(42, 157, 143, 0.2);
    color: var(--success);
    border: 1px solid rgba(42, 157, 143, 0.4);
}

.confidence-badge-lg.medium {
    background: rgba(244, 162, 97, 0.2);
    color: var(--warning);
    border: 1px solid rgba(244, 162, 97, 0.4);
}

.confidence-badge-lg.low {
    background: rgba(231, 111, 81, 0.2);
    color: var(--danger);
    border: 1px solid rgba(231, 111, 81, 0.4);
}

.confidence-text {
    font-size: 0.75rem;
    margin-left: 4px;
    opacity: 0.9;
}

/* Current category display */
.current-category {
    margin-bottom: 1.5rem;
}

.current-category-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.current-category-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    padding: 1rem;
    border-radius: 10px;
    border: 2px solid var(--primary);
}

.current-category-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1rem;
}

.current-category-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* AI Reasoning section */
.ai-reasoning {
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.1), rgba(155, 89, 182, 0.1));
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(67, 97, 238, 0.3);
}

.ai-reasoning-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--info);
    margin-bottom: 0.75rem;
}

.ai-reasoning-header i {
    font-size: 1rem;
}

.ai-reasoning-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ai-reasoning-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.85rem;
    color: var(--text);
}

.ai-reasoning-list li i {
    color: var(--success);
    font-size: 0.75rem;
    margin-top: 4px;
    flex-shrink: 0;
}

.keyword-highlight {
    background: rgba(42, 157, 143, 0.2);
    color: var(--success);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Category suggestions */
.category-suggestions {
    margin-bottom: 1.5rem;
}

.category-suggestions-header {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.category-suggestion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: all 0.2s ease;
}

.category-suggestion:hover {
    border-color: var(--primary-light);
    background: rgba(42, 157, 143, 0.05);
    transform: translateX(4px);
}

.category-suggestion.selected {
    border-color: var(--primary);
    background: rgba(42, 157, 143, 0.1);
}

.category-suggestion-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.category-suggestion-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-lighter);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.category-suggestion:hover .category-suggestion-icon,
.category-suggestion.selected .category-suggestion-icon {
    background: var(--primary);
    color: white;
}

.category-suggestion-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.category-suggestion-reason {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.category-suggestion-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Rule creation section */
.rule-creation {
    background: var(--bg);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border);
}

.rule-creation-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.rule-toggle {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.rule-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.rule-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: 26px;
    transition: 0.3s;
}

.rule-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.rule-toggle input:checked + .rule-toggle-slider {
    background: var(--primary);
}

.rule-toggle input:checked + .rule-toggle-slider:before {
    transform: translateX(22px);
}

.rule-toggle-label {
    font-weight: 600;
    font-size: 0.95rem;
}

.rule-toggle-label small {
    display: block;
    font-weight: normal;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.rule-scope-options {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.rule-scope-options.active {
    display: block;
}

.rule-scope-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.rule-scope-radio {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rule-scope-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-lighter);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.rule-scope-option:hover {
    background: var(--bg-light);
}

.rule-scope-option input {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

.rule-scope-option label {
    cursor: pointer;
    flex: 1;
}

.rule-scope-option .scope-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.rule-scope-option .scope-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.rule-preview {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(42, 157, 143, 0.1);
    border-radius: 8px;
    border: 1px dashed var(--primary);
}

.rule-preview-header {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
}

.rule-preview-text {
    font-size: 0.85rem;
    color: var(--text);
    font-family: monospace;
}

/* Clickable product rows */
.product-row-clickable {
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
}

.product-row-clickable:hover {
    background: rgba(42, 157, 143, 0.15);
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px !important;
    padding-right: 12px !important;
    transform: translateX(2px);
}

.product-row-clickable .edit-icon {
    opacity: 0.3;
    transition: all 0.2s ease;
    color: var(--primary, #2a9d8f);
    font-size: 0.75rem;
    background: rgba(42, 157, 143, 0.2);
    padding: 4px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.product-row-clickable:hover .edit-icon {
    opacity: 1;
    background: var(--primary, #2a9d8f);
    color: white;
    transform: scale(1.1);
}

/* Tooltip for edit icon */
.product-row-clickable .edit-icon::before {
    content: '';
    position: absolute;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Add click hint on first few products */
.product-row-clickable:first-child::after {
    content: 'Click to recategorize';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary, #2a9d8f);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    margin-right: 8px;
}

.product-row-clickable:first-child:hover::after {
    opacity: 1;
}

/* Responsive for modal */
@media (max-width: 500px) {
    .correction-modal {
        width: 100%;
        right: -100%;
    }
}

/* Animation for modal entrance */
@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Pulse effect on hover for products to encourage clicking */
@keyframes subtlePulse {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 0 2px rgba(42, 157, 143, 0.3); }
}

.product-row-clickable:hover {
    animation: subtlePulse 1.5s ease infinite;
}

/* Confidence mini-badge for inline display */
.confidence-mini {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    margin-left: 6px;
}

.confidence-mini.high {
    background: rgba(42, 157, 143, 0.2);
    color: var(--success, #2a9d8f);
}

.confidence-mini.medium {
    background: rgba(244, 162, 97, 0.2);
    color: var(--warning, #f4a261);
}

.confidence-mini.low {
    background: rgba(231, 111, 81, 0.2);
    color: var(--danger, #e76f51);
}

/* Recategorize hint styles */
.recategorize-hint {
    animation: fadeIn 0.5s ease;
}

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

/* Better button styles for modal */
.correction-footer .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.correction-footer .btn-secondary {
    background: var(--bg-lighter, #252a4a);
    color: var(--text, #e0e6ed);
}

.correction-footer .btn-secondary:hover {
    background: var(--border, #2a2f4a);
}

.correction-footer .btn-primary {
    background: linear-gradient(135deg, var(--primary, #2a9d8f), var(--primary-light, #3fb5a6));
    color: white;
}

.correction-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(42, 157, 143, 0.4);
}

.correction-footer .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
