/* Sentence History Component Styles */

/* History Button */
/* Default desktop/tablet positioning - top right of input area */
.history-button {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent !important;
    border: none !important;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    transition: all 0.2s ease;
    min-width: 44px; /* Touch-friendly minimum */
    min-height: 44px;
    justify-content: center;
    color: #333 !important;
}

.history-button:hover:not(:disabled) {
    background: #e8f4fd;
    box-shadow: 0 2px 8px rgba(21, 101, 192, 0.15);
    transform: translateY(-1px);
}

.history-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: transparent !important;
    color: #999 !important;
}

.history-button.active {
    background: #1565c0;
    color: white;
}

.history-icon {
    font-size: 16px;
    line-height: 1;
}

.history-count {
    background: white;
    color: #666;
    border: 1px solid #666;
    border-radius: 10px;
    padding: 1px 5px;
    font-size: 11px;
    font-weight: bold;
    min-width: 16px;
    text-align: center;
    position: absolute;
    top: -6px;
    right: -2px; /* Position closer to the clock icon */
    line-height: 1.2;
    z-index: 10;
    pointer-events: none; /* Don't interfere with button clicks */
}

/* History Dropdown - desktop/tablet positioning */
.history-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 400px;
    max-width: calc(100vw - 20px);
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 500px; /* Optimized for ~10 items + header */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.history-title {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.history-clear {
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s ease;
}

.history-clear:hover {
    background: #f44336;
    color: white;
}

/* History List */
.history-list {
    overflow-y: auto;
    max-height: 420px; /* Allow space for ~10 items with scrolling */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    flex: 1; /* Take remaining space after header */
}

.history-list::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* History Items - scoped to dropdown to avoid conflicts */
.history-dropdown .history-item {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.history-dropdown .history-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background-color 0.2s ease;
}

.history-dropdown .history-item:hover {
    background: #f8f9fa;
    transform: translateX(2px);
}

.history-dropdown .history-item:hover::before {
    background: #1565c0;
}

.history-dropdown .history-item:last-child {
    border-bottom: none;
}

.history-dropdown .history-item-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}

.history-dropdown .history-item-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.3;
    color: #333;
    word-break: break-word;
}

.history-dropdown .history-item-text.truncated {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-dropdown .history-item-remove {
    background: none;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    color: #999;
    opacity: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.history-dropdown .history-item:hover .history-item-remove {
    opacity: 1;
}

.history-dropdown .history-item-remove:hover {
    background: #f44336;
    color: white;
}

.history-dropdown .history-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #666;
    gap: 8px;
}

.history-dropdown .history-item-timestamp {
    flex-shrink: 0;
}

.history-dropdown .history-item-badges {
    display: flex;
    gap: 4px;
    align-items: center;
}

.history-dropdown .history-item-badge {
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.history-badge-language {
    background: #e3f2fd;
    color: #1565c0;
}

.history-badge-analysis {
    background: #f3e5f5;
    color: #7b1fa2;
}

.history-badge-success {
    background: #e8f5e8;
    color: #2e7d32;
}

.history-badge-failed {
    background: #ffebee;
    color: #c62828;
}

/* Empty State */
.history-empty {
    padding: 32px 16px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Click indicator for better UX - use specific selectors to avoid conflicts */
.history-dropdown .history-item-text {
    position: relative;
}

/* Add subtle arrow on hover to indicate clickability */
.history-dropdown .history-item:hover .history-item-text::after {
    content: "→";
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #1565c0;
    font-weight: bold;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.history-empty-icon {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.5;
}

/* More items indicator */
.history-more-indicator {
    padding: 12px 16px;
    text-align: center;
    color: #666;
    font-size: 12px;
    font-style: italic;
    border-top: 1px solid #f0f0f0;
    background: #f9f9f9;
}

/* Mobile/Tablet Optimizations - Same breakpoint as ad system for consistency */
@media (max-width: 1048px) {
    /* On mobile, keep history button in top-right but make it smaller */
    .history-button {
        padding: 6px;
        min-width: 32px;
        min-height: 32px;
        top: 6px;
        right: 6px;
    }
    
    .history-icon {
        font-size: 12px;
    }
    
    /* Hide count badge on mobile */
    .history-count {
        display: none !important;
    }
    
    .history-dropdown {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        top: 140px !important; /* Position below input area */
        width: auto !important;
        max-width: none !important;
        max-height: 60vh !important;
        z-index: 9999 !important;
        margin: 0 !important;
    }
    
    .history-dropdown .history-item {
        padding: 12px 16px; /* Larger touch targets */
    }
    
    .history-dropdown .history-item-text {
        font-size: 14px;
    }
}

/* Dark mode support (if implemented) */
@media (prefers-color-scheme: dark) {
    .history-dropdown {
        background: #2d2d2d;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .history-header {
        background: #333;
        border-bottom-color: #444;
    }
    
    .history-title {
        color: #e0e0e0;
    }
    
    .history-dropdown .history-item {
        border-bottom-color: #444;
    }
    
    .history-dropdown .history-item:hover {
        background: #383838;
    }
    
    .history-dropdown .history-item-text {
        color: #e0e0e0;
    }
    
    .history-button {
        background: #333;
        border-color: #555;
        color: #e0e0e0;
    }
    
    .history-button:hover:not(:disabled) {
        background: #444;
        border-color: #666;
    }
}


