/**
 * Search Results Counter Styles
 * 
 * Visual design for dynamic search results count display.
 * Supports multiple formats (simple, detailed, badge) with responsive design.
 * 
 * @package TeamPortal
 * @subpackage Assets/CSS/Components
 * @since Phase 5.2.1
 * @version 1.0.0
 */

/* ============================================
   SEARCH RESULTS COUNTER - BASE
   ============================================ */

.tp-search-results-counter {
    display: none; /* Hidden by default, shown when needed */
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    transition: all 0.3s ease;
}

/* Dark mode */
body.dark-mode .tp-search-results-counter {
    background: #1f2937;
    border-color: #374151;
}

/**
 * Visibility States
 */
.tp-search-results-counter.tp-counter-visible {
    display: block;
    animation: counterSlideIn 0.3s ease;
}

.tp-search-results-counter.tp-counter-hidden {
    display: none;
}

/**
 * State Colors
 */
/* All results (no filter) */
.tp-search-results-counter.tp-counter-all {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

body.dark-mode .tp-search-results-counter.tp-counter-all {
    background: #1e3a8a;
    border-color: #3b82f6;
    color: #dbeafe;
}

/* Filtered results */
.tp-search-results-counter.tp-counter-filtered {
    background: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

body.dark-mode .tp-search-results-counter.tp-counter-filtered {
    background: #78350f;
    border-color: #f59e0b;
    color: #fef3c7;
}

/* Empty results */
.tp-search-results-counter.tp-counter-empty {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

body.dark-mode .tp-search-results-counter.tp-counter-empty {
    background: #7f1d1d;
    border-color: #ef4444;
    color: #fee2e2;
}

/* ============================================
   COUNTER CONTENT LAYOUTS
   ============================================ */

.tp-counter-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

/**
 * Badge Format
 * Compact pill-style counter
 */
.tp-counter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #3b82f6;
    color: #ffffff;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
}

.tp-counter-badge .tp-counter-number {
    font-weight: 700;
    font-size: 14px;
}

.tp-counter-badge .tp-counter-label {
    opacity: 0.9;
}

/**
 * Detailed Format
 * Full information display with icon
 */
.tp-counter-detailed {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.tp-counter-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 6px;
    color: #3b82f6;
    font-size: 14px;
    flex-shrink: 0;
}

body.dark-mode .tp-counter-icon {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.tp-counter-text {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex: 1;
    flex-wrap: wrap;
}

.tp-counter-label {
    color: #6b7280;
    font-size: 13px;
}

body.dark-mode .tp-counter-label {
    color: #9ca3af;
}

.tp-counter-current,
.tp-counter-number {
    font-weight: 700;
    font-size: 16px;
    color: #111827;
    font-variant-numeric: tabular-nums; /* Monospaced numbers for smooth animation */
}

body.dark-mode .tp-counter-current,
body.dark-mode .tp-counter-number {
    color: #f9fafb;
}

.tp-counter-separator {
    color: #9ca3af;
    font-size: 13px;
}

.tp-counter-total {
    font-weight: 600;
    font-size: 14px;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}

body.dark-mode .tp-counter-total {
    color: #d1d5db;
}

.tp-counter-suffix {
    color: #6b7280;
    font-size: 13px;
}

body.dark-mode .tp-counter-suffix {
    color: #9ca3af;
}

.tp-counter-percentage {
    margin-left: auto;
    padding: 4px 10px;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.dark-mode .tp-counter-percentage {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* ============================================
   STATE-SPECIFIC STYLING
   ============================================ */

/**
 * Filtered State
 */
.tp-search-results-counter.tp-counter-filtered .tp-counter-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

body.dark-mode .tp-search-results-counter.tp-counter-filtered .tp-counter-icon {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.tp-search-results-counter.tp-counter-filtered .tp-counter-current {
    color: #92400e;
}

body.dark-mode .tp-search-results-counter.tp-counter-filtered .tp-counter-current {
    color: #fef3c7;
}

/**
 * Empty State
 */
.tp-search-results-counter.tp-counter-empty .tp-counter-icon {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

body.dark-mode .tp-search-results-counter.tp-counter-empty .tp-counter-icon {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.tp-search-results-counter.tp-counter-empty .tp-counter-current {
    color: #991b1b;
}

body.dark-mode .tp-search-results-counter.tp-counter-empty .tp-counter-current {
    color: #fee2e2;
}

/* ============================================
   ANIMATIONS
   ============================================ */

/**
 * Slide In Animation
 */
@keyframes counterSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/**
 * Number Change Flash
 */
@keyframes numberFlash {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.tp-counter-current[data-animating],
.tp-counter-number[data-animating] {
    animation: numberFlash 0.3s ease;
}

/**
 * Reduced Motion Support
 */
@media (prefers-reduced-motion: reduce) {
    .tp-search-results-counter,
    .tp-counter-current,
    .tp-counter-number,
    .tp-counter-badge {
        animation: none;
        transition: none;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/**
 * Mobile (<768px)
 */
@media (max-width: 767px) {
    .tp-search-results-counter {
        padding: 10px 12px;
        font-size: 13px;
        margin-bottom: 12px;
    }

    .tp-counter-detailed {
        gap: 8px;
    }

    .tp-counter-icon {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .tp-counter-current,
    .tp-counter-number {
        font-size: 15px;
    }

    .tp-counter-label,
    .tp-counter-separator,
    .tp-counter-suffix {
        font-size: 12px;
    }

    .tp-counter-percentage {
        padding: 3px 8px;
        font-size: 11px;
    }

    /* Stack on very small screens */
    @media (max-width: 480px) {
        .tp-counter-text {
            flex-wrap: wrap;
        }

        .tp-counter-percentage {
            margin-left: 0;
            margin-top: 4px;
        }
    }
}

/**
 * Tablet (768px - 1024px)
 */
@media (min-width: 768px) and (max-width: 1024px) {
    .tp-search-results-counter {
        padding: 11px 14px;
    }
}

/* ============================================
   INTEGRATION WITH DATATABLE
   ============================================ */

/**
 * Position counter above table
 */
.dataTables_wrapper > .tp-search-results-counter,
.dataTables_wrapper > #search-results-counter {
    margin-top: 0;
    margin-bottom: 16px;
}

/**
 * Position counter in filters area
 */
.team-portal-filters + .tp-search-results-counter,
.team-portal-filters + #search-results-counter {
    margin-top: 12px;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/**
 * Focus States
 */
.tp-search-results-counter:focus-within {
    outline: 2px solid var(--focus-ring-color, #3b82f6);
    outline-offset: 2px;
}

/**
 * Screen Reader Only Text
 */
.tp-counter-sr-only {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/**
 * High Contrast Mode
 */
@media (prefers-contrast: high) {
    .tp-search-results-counter {
        border-width: 2px;
    }

    .tp-counter-current,
    .tp-counter-number {
        font-weight: 800;
    }

    .tp-counter-icon {
        border: 2px solid currentColor;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .tp-search-results-counter {
        page-break-inside: avoid;
        border-color: #000;
        background: #fff !important;
        color: #000 !important;
    }

    .tp-counter-icon {
        display: none;
    }

    .tp-counter-percentage {
        background: #f0f0f0 !important;
        color: #000 !important;
    }
}

/* ============================================
   ALTERNATIVE POSITIONS
   ============================================ */

/**
 * Inline Counter (in toolbar)
 */
.tp-counter-inline {
    display: inline-flex;
    margin: 0;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
}

.tp-counter-inline .tp-counter-icon {
    width: 20px;
    height: 20px;
    font-size: 10px;
}

.tp-counter-inline .tp-counter-current {
    font-size: 13px;
}

/**
 * Sticky Counter (fixed position on scroll)
 */
.tp-counter-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode .tp-counter-sticky {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
