/**
 * Enhanced Pagination Styles
 * Provides consistent, modern pagination styling for both logged-in and guest users
 * across all service views (index, services_all, ajax paginated)
 */

/* ============================================
   PAGINATION CONTAINER
   ============================================ */
.pagination-section {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px 0;
    padding: 20px 0;
}

/* ============================================
   PAGINATION CONTROLS
   ============================================ */
.pagination {
    display: flex !important;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 0 !important;
}

.pagination .page-item {
    list-style: none;
}

.pagination .page-link {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 8px 12px !important;
    margin-left: 0 !important;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5 !important;
    color: #667eea !important;
    background-color: #fff !important;
    background: #fff !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Ripple effect on click */
.pagination .page-link::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.pagination .page-link:active::before {
    width: 200px;
    height: 200px;
}

/* Hover State */
.pagination .page-link:hover:not(.disabled) {
    color: #fff !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: #667eea !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
    z-index: 2;
}

/* Focus State */
.pagination .page-link:focus {
    z-index: 2;
    outline: 2px solid #667eea !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.25) !important;
}

/* Active State */
.pagination .page-item.active .page-link {
    z-index: 1;
    color: #fff !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: #667eea !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4) !important;
    font-weight: 600;
    cursor: default;
}

/* Disabled State */
.pagination .page-item.disabled .page-link {
    color: #adb5bd !important;
    background-color: #f8f9fa !important;
    background: #f8f9fa !important;
    border-color: #e9ecef !important;
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
}
}

.pagination .page-item.disabled .page-link:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* Override core.css first and last child styles */
.pagination .page-item:first-child .page-link {
    margin-left: 0 !important;
    border-radius: 8px !important;
}

.pagination .page-item:last-child .page-link {
    border-radius: 8px !important;
}

/* ============================================
   PAGINATION INFO TEXT
   ============================================ */
.pagination-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
    padding: 15px 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.1);
}

.pagination-info .text-muted {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

/* ============================================
   NAVIGATION BUTTONS (Prev/Next)
   ============================================ */
.pagination .page-nav {
    font-weight: 600;
    padding: 8px 16px;
}

.pagination .page-nav i {
    font-size: 12px;
}

/* ============================================
   ELLIPSIS SEPARATOR
   ============================================ */
.pagination .page-item.disabled .page-link {
    background: transparent;
    border-color: transparent;
    color: #adb5bd;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .pagination-section {
        padding: 15px 0;
        margin: 20px 0;
    }
    
    .pagination {
        gap: 5px;
    }
    
    .pagination .page-link {
        min-width: 36px;
        height: 36px;
        padding: 6px 10px;
        font-size: 13px;
    }
    
    .pagination .page-nav {
        padding: 6px 12px;
    }
    
    /* Hide some page numbers on mobile for better UX */
    /* Using data attribute for easier JavaScript control if needed */
    .pagination .page-item.mobile-hidden {
        display: none;
    }
    
    /* Keep essential navigation visible */
    .pagination .page-item:first-child,
    .pagination .page-item:last-child,
    .pagination .page-item.active {
        display: block;
    }
    
    .pagination-info {
        padding: 12px 15px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .pagination .page-link {
        min-width: 32px;
        height: 32px;
        padding: 5px 8px;
        font-size: 12px;
        border-width: 1px;
    }
    
    .pagination-info {
        flex-direction: column;
        text-align: center;
    }
    
    /* Show only essential page items on very small screens */
    .pagination .page-item {
        display: none;
    }
    
    /* Always show navigation buttons and current page */
    .pagination .page-item.active,
    .pagination .page-item:first-child, /* Previous */
    .pagination .page-item:last-child   /* Next */
    {
        display: block;
    }
}

/* ============================================
   LOADING STATE
   ============================================ */
.pagination-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.pagination-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   THEME-SPECIFIC OVERRIDES
   ============================================ */

/* For services_all.php theme view (guest users) */
body:has(.services-container) .page-link {
    background: rgba(255, 255, 255, 0.95);
}

body:has(.services-container) .page-link:hover:not(.disabled) {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

body:has(.services-container) .page-item.active .page-link {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* For admin/logged-in table view */
.paginated-services-container .pagination {
    margin-top: 0;
}

.paginated-services-container .pagination-info {
    border-radius: 8px;
    margin-top: 15px;
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */
.pagination .page-link:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    z-index: 1;
}

.pagination .page-link:focus:not(:focus-visible) {
    outline: none;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .pagination-section,
    .pagination-info {
        display: none;
    }
}

/* ============================================
   DARK MODE SUPPORT (if needed)
   ============================================ */
@media (prefers-color-scheme: dark) {
    .pagination .page-link {
        background-color: #2d3436;
        color: #dfe6e9;
        border-color: #4a5568;
    }
    
    .pagination .page-link:hover:not(.disabled) {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        border-color: #667eea;
    }
    
    .pagination .page-item.disabled .page-link {
        background-color: #1a1d20;
        color: #6c757d;
    }
    
    .pagination-info {
        background: rgba(102, 126, 234, 0.1);
        border-color: rgba(102, 126, 234, 0.2);
    }
}

/* ============================================
   ANIMATION VARIANTS
   ============================================ */
.pagination .page-link {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Stagger animation for page numbers */
.pagination .page-item:nth-child(1) .page-link { animation-delay: 0s; }
.pagination .page-item:nth-child(2) .page-link { animation-delay: 0.05s; }
.pagination .page-item:nth-child(3) .page-link { animation-delay: 0.1s; }
.pagination .page-item:nth-child(4) .page-link { animation-delay: 0.15s; }
.pagination .page-item:nth-child(5) .page-link { animation-delay: 0.2s; }
.pagination .page-item:nth-child(6) .page-link { animation-delay: 0.25s; }
.pagination .page-item:nth-child(7) .page-link { animation-delay: 0.3s; }
.pagination .page-item:nth-child(8) .page-link { animation-delay: 0.35s; }
.pagination .page-item:nth-child(9) .page-link { animation-delay: 0.4s; }
