/* Analytics History Component Styles */

.analytics-history {
    margin-top: 30px;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-header {
    margin-bottom: 20px;
}

.history-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.history-title-bar h3 {
    margin: 0;
    color: #2c3e50;
    /* Remove font-size to use the standardized size from styles.css */
}

.toggle-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #495057;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.toggle-btn:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.toggle-icon {
    font-size: 12px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.history-content {
    transition: all 0.3s ease;
}

.history-header h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.history-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.search-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input, .tag-filter {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.tag-filter {
    min-width: 120px;
}

.bookmark-filter {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    user-select: none;
}

.date-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.date-controls input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.btn-secondary {
    padding: 8px 16px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-secondary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.history-table-container {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table th {
    background: #343a40;
    color: white;
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

.history-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

.history-table tr:hover {
    background: #f8f9fa;
}

.date-cell {
    min-width: 100px;
}

.date-cell .date {
    display: block;
    font-weight: 500;
    color: #2c3e50;
}

.date-cell .time {
    display: block;
    font-size: 12px;
    color: #6c757d;
}

.prompt-cell {
    min-width: 200px;
    max-width: 300px;
}

.prompt-text {
    line-height: 1.4;
    word-break: break-word;
}

.dataset-cell {
    text-align: center;
    min-width: 80px;
}

.dataset-size {
    display: block;
    font-weight: 600;
    color: #28a745;
    font-size: 16px;
}

.records-label {
    font-size: 11px;
    color: #6c757d;
    text-transform: uppercase;
}

.summary-cell {
    min-width: 250px;
    max-width: 400px;
}

.summary-text {
    line-height: 1.4;
    margin-bottom: 5px;
}

.confidence {
    font-size: 12px;
    color: #17a2b8;
    font-weight: 500;
}

.tags-cell {
    min-width: 120px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.tag {
    background: #e9ecef;
    color: #495057;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.add-tag-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-tag-btn:hover {
    background: #0056b3;
}

.actions-cell {
    min-width: 120px;
}

.actions-cell .action-buttons {
    display: flex !important;
    flex-direction: row !important;
    gap: 4px !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 16px;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background: #e9ecef;
}

.bookmark-btn.bookmarked {
    color: #ffc107;
}

.delete-btn:hover {
    background: #f8d7da;
    color: #721c24;
}

.no-data {
    text-align: center;
    padding: 40px 20px;
}

.no-history p {
    margin: 0;
    color: #6c757d;
}

.no-history .subtext {
    font-size: 12px;
    margin-top: 5px;
}

.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
}

#page-info {
    font-size: 14px;
    color: #6c757d;
}

/* Modal styles */
.analytics-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: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
}

.close-modal:hover {
    color: #495057;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-primary {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: #0056b3;
}

.detail-section {
    margin-bottom: 25px;
}

.detail-section h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.prompt-detail {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #007bff;
    font-style: italic;
    line-height: 1.5;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.filter-item {
    background: #e9ecef;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.results-summary p {
    margin: 5px 0;
    font-size: 14px;
}

.response-summary {
    margin-top: 15px;
}

.response-summary h5 {
    margin: 0 0 8px 0;
    color: #495057;
}

.response-summary p {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    line-height: 1.5;
    margin: 0;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 20px 0;
}

.comparison-item {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.comparison-item h5 {
    margin: 0 0 10px 0;
    color: #6c757d;
    font-size: 14px;
}

.dataset-count {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
}

.dataset-count.increased {
    color: #28a745;
}

.dataset-count.decreased {
    color: #dc3545;
}

.dataset-count.same {
    color: #17a2b8;
}

.dataset-label {
    display: block;
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
}

.data-table-container {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
}

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

.data-preview-table th {
    background: #f8f9fa;
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.data-preview-table td {
    padding: 8px;
    border-bottom: 1px solid #dee2e6;
}

/* Message styles */
.loading-message, .error-message, .success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    max-width: 400px;
}

.loading-content, .error-content, .success-content {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
}

.loading-content {
    border-left: 4px solid #007bff;
}

.error-content {
    border-left: 4px solid #dc3545;
}

.success-content {
    border-left: 4px solid #28a745;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tag Editor Modal */
.tag-editor-modal .modal-content {
    max-width: 500px;
}

.tag-editor {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tag-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.current-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.current-tags .tag {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #e9ecef;
    color: #495057;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.current-tags .tag .remove-tag {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.current-tags .tag .remove-tag:hover {
    background: #dc3545;
    color: white;
}

/* Responsive design - Only stack on very small mobile screens */
@media (max-width: 320px) {
    .history-controls {
        flex-direction: column;
    }
    
    .search-controls, .date-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-input {
        min-width: auto;
    }
    
    .history-table {
        font-size: 12px;
    }
    
    .history-table th,
    .history-table td {
        padding: 8px 4px;
    }
    
    .modal-content {
        margin: 10px;
        max-width: calc(100vw - 20px);
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
    }
    
    /* Remove action-buttons column stacking override */
    /* .action-buttons {
        flex-direction: column;
        gap: 2px;
    } */
    
    .btn-icon {
        font-size: 12px;
        padding: 2px;
    }
}

/* Empty State Styles */
.empty-state {
    text-align: center !important;
    padding: 40px 20px;
    color: #6c757d;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.7;
    text-align: center !important;
}

.empty-state h4 {
    margin: 0 0 12px 0;
    color: #495057;
    font-weight: 500;
    text-align: center !important;
}

.empty-state p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    max-width: 400px;
    margin: 0 auto;
    text-align: center !important;
}

/* Dark Theme Support */
body.dark-theme .analytics-history {
    background: #2c2c2c !important;
    color: #ffffff !important;
}

body.dark-theme .history-title-bar h3 {
    color: #ffffff !important;
}

body.dark-theme .toggle-btn {
    background: #383838 !important;
    border: 1px solid #404040 !important;
    color: #ffffff !important;
}

body.dark-theme .toggle-btn:hover {
    background: #404040 !important;
    border-color: #555555 !important;
}

body.dark-theme .history-item {
    background: #383838 !important;
    border: 1px solid #404040 !important;
    color: #ffffff !important;
}

body.dark-theme .history-item:hover {
    background: #404040 !important;
}

body.dark-theme .history-item .question {
    color: #ffffff !important;
}

body.dark-theme .history-item .timestamp {
    color: #cccccc !important;
}

body.dark-theme .history-item .response {
    color: #e0e0e0 !important;
}

body.dark-theme .empty-state {
    color: #cccccc !important;
}

body.dark-theme .empty-state h4 {
    color: #ffffff !important;
}

body.dark-theme .empty-state p {
    color: #cccccc !important;
    text-align: center !important;
}

/* Sort indicator styling */
.sort-indicator {
    font-size: 12px;
    color: #6c757d;
    margin-left: 5px;
    opacity: 0.7;
    font-weight: bold;
}

.history-table th {
    position: relative;
}

.history-table th:first-child {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

body.dark-theme .sort-indicator {
    color: #adb5bd;
}

body.dark-theme .history-table th:first-child {
    background: linear-gradient(135deg, #383838 0%, #404040 100%);
}
