/* TOKEN COUNTER STYLES */
.token-counter-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.token-counter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.token-counter-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.details-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.details-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.token-display {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.token-progress-bar {
    width: 100%;
    height: 25px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.token-progress-fill {
    height: 100%;
    background: #28a745;
    transition: width 0.5s ease, background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: bold;
}

.token-percent {
    text-align: right;
    font-size: 1.1rem;
    opacity: 0.9;
}

.token-breakdown {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.token-breakdown h4 {
    margin-top: 0;
    margin-bottom: 15px;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 1rem;
}

.breakdown-reset {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 0.95rem;
    opacity: 0.9;
}

/* TOKEN WARNINGS */
.token-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

.token-exceeded {
    background: #f8d7da;
    border: 1px solid #dc3545;
    color: #721c24;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
}

/* RAG SECTION STYLES */
.rag-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.rag-section h2 {
    margin-top: 0;
    color: #2c3e50;
    margin-bottom: 25px;
}

/* ANALYSIS MODE SELECTOR */
.analysis-mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.mode-option input[type="radio"] {
    display: none;
}

.mode-label {
    display: block;
    padding: 20px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    background: #f8f9fa;
}

.mode-option input[type="radio"]:checked + .mode-label {
    border-color: #667eea;
    background: #f0f3ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.mode-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.mode-icon {
    font-size: 2rem;
    margin-right: 10px;
}

.mode-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2c3e50;
}

.mode-description {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 15px;
    font-style: italic;
}

.mode-examples {
    margin-bottom: 15px;
}

.mode-examples strong {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
}

.mode-examples ul {
    margin: 0;
    padding-left: 20px;
}

.mode-examples li {
    margin-bottom: 5px;
    color: #555;
    font-size: 0.9rem;
}

.mode-sample {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

.mode-sample strong {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
}

.sample-text {
    margin: 0;
    color: #555;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-line;
}

.mode-footer {
    color: #667eea;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

/* QUERY INPUT */
.rag-query-container {
    margin-bottom: 25px;
}

#ragQuery {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 15px;
    transition: border-color 0.3s;
}

#ragQuery:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* LOADING INDICATOR */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

#loadingText {
    color: #666;
    font-size: 1.1rem;
}

/* RESULTS DISPLAY */
.rag-results {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    border: 2px solid #e0e0e0;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

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

.mode-badge {
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.badge-standard {
    background: #d4edda;
    color: #155724;
}

.badge-advanced {
    background: #d1ecf1;
    color: #0c5460;
}

.rag-answer {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    line-height: 1.8;
    color: #2c3e50;
    font-size: 1.05rem;
    border-left: 4px solid #667eea;
}

.sources-section {
    margin-bottom: 20px;
}

.sources-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
}

.sources-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.source-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    transition: box-shadow 0.3s;
}

.source-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.source-item strong {
    color: #667eea;
}

.source-item small {
    color: #666;
    display: block;
    margin-top: 5px;
}

.token-usage-info {
    background: #e7f3ff;
    padding: 12px;
    border-radius: 8px;
    color: #004085;
    font-size: 0.95rem;
    text-align: center;
    font-weight: 500;
}

/* RESPONSIVE DESIGN */
@media (max-width: 768px) {
    .analysis-mode-selector {
        grid-template-columns: 1fr;
    }
    
    .sources-list {
        grid-template-columns: 1fr;
    }
    
    .token-display {
        font-size: 1.5rem;
    }
}

/* === TRENDS TAB STYLES === */
/* Add these styles to the END of your existing styles.css file */

/* Parameter Checkboxes */
.parameter-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
}

.parameter-checkbox:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.parameter-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #10b981;
}

.parameter-checkbox input[type="checkbox"]:checked + span {
    font-weight: 600;
    color: #065f46;
}

.parameter-checkbox span {
    font-size: 0.875rem;
    color: #374151;
    user-select: none;
}

/* Date Range Buttons */
.date-range-btn {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #6b7280;
    font-weight: 500;
}

.date-range-btn:hover {
    background: #f9fafb;
    border-color: #10b981;
}

.date-range-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: #fff;
    font-weight: 600;
}

/* Chart Container */
#trendsChart {
    max-height: 400px;
}

/* Trends Stats Cards */
#trends-stats .bg-white {
    transition: transform 0.2s, box-shadow 0.2s;
}

#trends-stats .bg-white:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive Trends */
@media (max-width: 640px) {
    #parameter-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .date-range-btn {
        flex: 1;
        min-width: 0;
    }
    
    #trendsChart {
        max-height: 300px;
    }
}

/* ==========================================
   TAG SELECTOR STYLES
   Add to your existing styles.css
   ========================================== */

/* Tag Checkbox Labels */
.tag-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: #fff;
    font-size: 0.875rem;
    color: #374151;
    user-select: none;
}

.tag-checkbox-label:hover {
    background: #f9fafb;
    border-color: #10b981;
}

.tag-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #10b981;
    flex-shrink: 0;
}

.tag-checkbox-label input[type="checkbox"]:checked {
    background: #10b981;
}

.tag-checkbox-label:has(input:checked) {
    background: #ecfdf5;
    border-color: #10b981;
    font-weight: 600;
    color: #065f46;
}

/* Compare Toggle Section */
#compare-tags-toggle {
    animation: slideDown 0.3s ease-out;
}

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

#compare-mode-checkbox {
    cursor: pointer;
}

#compare-tags-toggle label:hover {
    opacity: 0.9;
}

/* Category Group Styles (if not already present) */
.category-group {
    margin-bottom: 1.5rem;
}

.category-header {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.parameters-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
    margin-left: 12px;
}

/* Trends Container Layout */
.trends-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    min-height: 500px;
}

.trends-sidebar {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.trends-chart-area {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.5rem;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.btn-secondary {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e5e7eb;
    color: #374151;
}

.btn-small {
    font-size: 0.75rem;
    padding: 4px 10px;
}

.search-box {
    margin-bottom: 1rem;
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.search-box input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Chart Controls */
.chart-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.chart-controls h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.chart-options {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.chart-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: #6b7280;
    cursor: pointer;
}

.chart-options input[type="checkbox"] {
    cursor: pointer;
    accent-color: #10b981;
}

.chart-options select {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    background: white;
}

.chart-options select:focus {
    outline: none;
    border-color: #10b981;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
}

#trends-chart {
    width: 100% !important;
    height: 100% !important;
}

.no-data-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    font-size: 1rem;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .trends-container {
        grid-template-columns: 1fr;
    }
    
    .trends-sidebar {
        position: static;
    }
    
    .parameters-list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 640px) {
    #tag-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .chart-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .parameters-list {
        grid-template-columns: 1fr;
    }
}

/* Animation for smooth transitions */
.tab-content {
    animation: fadeIn 0.3s ease-in;
}

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