/**
 * History Sidebar Component
 * Shows last 10 lookups with ability to reopen them
 */

.history-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 260px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
    transition: left 0.3s ease;
    z-index: 10000;
    display: flex;
    flex-direction: column;
}

.history-sidebar.open {
    left: 0;
}

.history-toggle-btn {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 60px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 9999;
    transition: all 0.3s ease;
    box-shadow: none;
    border: none;
    outline: none;
    outline-offset: 0;
    /* Use a single solid purple color for the toggle to avoid gradient */
    background: #6f42c1;
    overflow: hidden;
}

.history-toggle-btn::before {
    content: '';
    position: absolute;
    top: -200%;
    left: -200%;
    width: 300%;
    height: 500%;
    /* Softer edges on both sides of the highlight */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0) 30%,
        rgba(255, 255, 255, 0.08) 40%,
        rgba(255, 255, 255, 0.22) 47%,
        rgba(255, 255, 255, 0.38) 50%,
        rgba(255, 255, 255, 0.22) 53%,
        rgba(255, 255, 255, 0.08) 60%,
        rgba(255, 255, 255, 0) 70%,
        rgba(255, 255, 255, 0) 100%
    );
    filter: blur(10px);
    -webkit-filter: blur(10px);
    will-change: transform;
    /* Disable shine on the button - use a simple solid color */
    display: none;
    pointer-events: none; /* keep inert */
}

@keyframes shine {
    0% {
        transform: translateX(-100%) translateY(-100%);
    }
    100% {
        transform: translateX(160%) translateY(160%);
    }
}

.history-sidebar.open + .history-toggle-btn {
    left: 260px;
}

.history-toggle-btn:hover {
    background: #5a2ea6; /* Slightly darker purple on hover */
    width: 45px;
    box-shadow: none;
}

/* Remove borders/outlines on all interaction states */
.history-toggle-btn:focus,
.history-toggle-btn:active,
.history-toggle-btn:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
}

/* Ensure Firefox doesn't add inner focus border */

/* Remove Firefox inner focus border */
.history-toggle-btn::-moz-focus-inner { border: 0; }

/* Remove tap highlight on mobile */
.history-toggle-btn { -webkit-tap-highlight-color: transparent; }

.history-toggle-icon {
    display: inline-block;
    filter: grayscale(100%) brightness(2); /* make emoji white like KB */
}

.history-header {
    padding: 10px 12px; /* shorter header bar */
    background: var(--primary-color); /* match tabs blue */
    color: white;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Per-item delete button (small, outlined) */
.history-item-delete {
    margin-left: auto;
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff !important;
    border: 1px solid var(--danger-color) !important;
    color: var(--danger-color) !important;
    font-size: 0; /* hide any text nodes */
    line-height: 1;
    padding: 0;
    border-radius: 4px; /* subtle rounding */
    cursor: pointer;
    opacity: 0.9;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.history-item-delete svg {
    width: 12px;
    height: 12px;
    display: block;
}

.history-item-delete:hover {
    background: var(--danger-color) !important;
    color: #ffffff !important;
    opacity: 1;
}

.history-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.history-header * {
    color: white !important;
    filter: grayscale(100%) brightness(2) !important; /* white icons like KB */
}

.history-close {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 28px;
    min-width: 28px;
    max-width: 28px;
    padding: 0;
    height: 28px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-close:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    background: var(--bg-main);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.history-item:hover {
    background: #e9ecef;
    transform: translateX(4px);
    border-left-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-item-expired {
    opacity: 0.5;
    cursor: default !important;
    background: #f0f0f0 !important;
    filter: grayscale(80%);
}

.history-item-expired:hover {
    background: #f0f0f0 !important;
    transform: none !important;
    border-left-color: transparent !important;
    box-shadow: none !important;
}

.history-item-status-expired {
    font-size: 10px;
    color: var(--danger-color);
    font-weight: 600;
    background: rgba(220, 53, 69, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
    margin-right: 4px;
}

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

.history-item-icon {
    font-size: 16px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 4px;
    filter: grayscale(100%) opacity(0.6); /* make emoji light grey */
}

.history-item-tool {
    font-weight: 600;
    font-size: 13px;
    color: #495057;
    flex: 1;
}

.history-item-time {
    font-size: 11px;
    color: var(--text-muted);
}

/* Place the timestamp/time subtitle under the file name (URL) */
.history-item-url + .history-item-time {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
}

.history-item-url {
    font-size: 12px;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.history-item-summary {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.history-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
    filter: grayscale(100%) opacity(0.5); /* make emoji light grey */
}

.history-empty p {
    margin: 0;
    font-size: 14px;
}

.history-footer {
    padding: 15px;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.history-clear-btn {
    width: 100%;
    padding: 10px;
    background: white;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.trash-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.history-clear-btn:hover {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
}



/* Tool type colors */
.history-item[data-tool="dns"] .history-item-icon {
    color: var(--primary-color);
}

.history-item[data-tool="tracking"] .history-item-icon {
    color: var(--success-color);
}

.history-item[data-tool="feed"] .history-item-icon {
    color: var(--warning-color);
}

.history-item[data-tool="form_scan"] .history-item-icon,
.history-item[data-tool="form_preview"] .history-item-icon {
    color: var(--primary-color);
}

.history-item[data-tool="regex"] .history-item-icon {
    color: #6f42c1;
}

/* Scrollbar styling */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.history-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Confirmation Modal */
.confirm-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.confirm-modal-overlay.active {
    display: flex;
}

.confirm-modal {
    background-color: white;
    border-radius: 8px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.confirm-modal h3 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 18px;
}

.confirm-modal p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.confirm-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.confirm-modal-buttons button {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.confirm-modal-buttons .btn-cancel {
    background: var(--text-muted);
    color: white;
}

.confirm-modal-buttons .btn-cancel:hover {
    background: var(--text-main);
}

.confirm-modal-buttons .btn-confirm {
    background: var(--danger-color);
    color: white;
}

.confirm-modal-buttons .btn-confirm:hover {
    background: #c82333;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .history-sidebar {
        width: 280px;
        left: -280px;
    }
    
    .history-sidebar.open + .history-toggle-btn {
        left: 280px;
    }
}
/* Unified history sidebar adjustments */
.history-sidebar {
    background: var(--bg-card) !important;
    border-left: 1px solid var(--border-color) !important;
    box-shadow: -5px 0 25px rgba(0,0,0,0.05) !important;
}
.history-item {
    border-radius: var(--border-radius-md) !important;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-main) !important;
    box-shadow: var(--shadow-sm) !important;
    transition: all var(--transition-fast) !important;
}
.history-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md) !important;
    border-color: var(--primary-light) !important;
}
