:root {
    --primary-color: #4CA633;
    --primary-hover: #3d8029;
    --primary-light: #e8f5e2;
    --primary-dark: #2d5f1e;
    --text-color: #6c757d;
    --border-color: #e9ecef;
    --white: #ffffff;
    --light-gray: #f8f9fa;
    --shadow: 0 2px 8px rgba(76, 166, 51, 0.12);
    --shadow-hover: 0 6px 20px rgba(76, 166, 51, 0.2);
    --shadow-active: 0 4px 14px rgba(76, 166, 51, 0.25);
}

.pagination {
    margin: 0 16px 0 0;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    padding: 0.5rem 0;
}

.page-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--text-color);
    text-decoration: none;
    background: linear-gradient(145deg, var(--white) 0%, #fdfdfd 100%);
    border: 2px solid var(--border-color);
    border-radius: 0.75rem !important;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 3rem;
    min-height: 3rem;
    text-align: center;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.pagination-wrapper p {
    margin: 0 1rem !important;
}

.page-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(76, 166, 51, 0.1), transparent);
    transition: left 0.5s ease;
    z-index: 0;
}

.page-link:hover::before {
    left: 100%;
}

.page-link:hover {
    color: var(--primary-color);
    background: linear-gradient(145deg, var(--primary-light) 0%, #f0f8ed 100%);
    border-color: var(--primary-color);
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-hover);
    z-index: 2;
}

.page-link:focus {
    color: var(--primary-color);
    background: linear-gradient(145deg, var(--primary-light) 0%, #f0f8ed 100%);
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(76, 166, 51, 0.3), var(--shadow-hover);
    transform: translateY(-2px);
}

.page-item.active .page-link {
    color: var(--white);
    background: linear-gradient(145deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-active);
    transform: translateY(-2px);
    z-index: 3;
    font-weight: 700;
}

.page-item.active .page-link::before {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.page-item.active .page-link:hover {
    background: linear-gradient(145deg, var(--primary-hover) 0%, var(--primary-dark) 100%);
    border-color: var(--primary-hover);
    transform: translateY(-4px) scale(1.03);
    box-shadow: 0 8px 25px rgba(76, 166, 51, 0.3);
}

.page-item.disabled .page-link {
    color: #adb5bd;
    pointer-events: none;
    background: linear-gradient(145deg, var(--light-gray) 0%, #f1f3f4 100%);
    border-color: var(--border-color);
    opacity: 0.65;
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.page-item:first-child .page-link,
.page-item:last-child .page-link {
    font-weight: 700;
    border-radius: 0.75rem !important;
    background: linear-gradient(145deg, var(--white) 0%, #f8f9fa 100%);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    position: relative;
    overflow: hidden;
}

.page-item:first-child .page-link:hover,
.page-item:last-child .page-link:hover {
    background: linear-gradient(145deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: var(--white);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(76, 166, 51, 0.25);
}

.page-item:first-child .page-link:hover::after {
    transform: translateX(-3px);
}

.page-item:last-child .page-link:hover::after {
    transform: translateX(3px);
}

.page-item.active .page-link {
    animation: pulse-active 2s infinite;
}

@keyframes pulse-active {
    0% {
        box-shadow: var(--shadow-active);
    }
    50% {
        box-shadow: 0 4px 20px rgba(76, 166, 51, 0.35);
    }
    100% {
        box-shadow: var(--shadow-active);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .pagination {
        gap: 0.375rem;
    }

    .page-link {
        padding: 0.75rem 0.875rem;
        font-size: 0.875rem;
        min-width: 2.75rem;
        min-height: 2.75rem;
        border-radius: 0.625rem;
    }

    .page-item:first-child .page-link,
    .page-item:last-child .page-link {
        padding: 0.75rem 1.25rem;
    }
}

@media (max-width: 576px) {
    .pagination {
        gap: 0.25rem;
    }

    .page-link {
        padding: 0.625rem 0.75rem;
        font-size: 0.825rem;
        min-width: 2.5rem;
        min-height: 2.5rem;
        border-radius: 0.5rem;
    }

    .page-item:first-child .page-link,
    .page-item:last-child .page-link {
        padding: 0.625rem 1rem;
    }

    /* Ẩn các số trang ở giữa trên mobile, chỉ hiện active và adjacent */
    .page-item:not(.active):not(:first-child):not(:last-child):not(:nth-child(2)):not(:nth-last-child(2)) {
        display: none;
    }

    /* Hiện dots indicator */
    .pagination::before {
        content: '⋯';
        color: var(--text-color);
        font-size: 1.2em;
        margin: 0 0.5rem;
        align-self: center;
    }
}

/* Loading state với animation đẹp */
.pagination-loading {
    opacity: 0.8;
    pointer-events: none;
}

.pagination-loading .page-link {
    position: relative;
    overflow: hidden;
}

.pagination-loading .page-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(76, 166, 51, 0.3),
        transparent
    );
    animation: loading-shimmer 1.8s infinite;
    z-index: 1;
}

@keyframes loading-shimmer {
    0% {
        left: -100%;
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        left: 100%;
        opacity: 0;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #adb5bd;
        --border-color: #495057;
        --white: #343a40;
        --light-gray: #495057;
        --primary-light: rgba(76, 166, 51, 0.15);
    }

    .page-link {
        background: linear-gradient(145deg, #343a40 0%, #2d3238 100%);
        border-color: #495057;
    }

    .page-link:hover {
        background: linear-gradient(145deg, rgba(76, 166, 51, 0.15) 0%, rgba(76, 166, 51, 0.1) 100%);
    }

    .page-item:first-child .page-link,
    .page-item:last-child .page-link {
        background: linear-gradient(145deg, #343a40 0%, #2d3238 100%);
    }

    .page-item.disabled .page-link {
        background: linear-gradient(145deg, #495057 0%, #3d4349 100%);
        color: #6c757d;
    }
}

/* Wrapper styling */
.pagination-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 2.5rem 0;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(76, 166, 51, 0.02) 0%, rgba(76, 166, 51, 0.05) 100%);
    border-radius: 1rem;
}

.pagination-info {
    color: var(--text-color);
    font-size: 0.925rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    text-align: center;
    padding: 0.75rem 1.5rem;
    background: rgba(76, 166, 51, 0.05);
    border-radius: 2rem;
    border: 1px solid rgba(76, 166, 51, 0.1);
}

/* Size variants */
.pagination-lg .page-link {
    padding: 1.125rem 1.75rem;
    font-size: 1.075rem;
    min-width: 3.5rem;
    min-height: 3.5rem;
    border-radius: 1rem;
}

.pagination-sm .page-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-width: 2.25rem;
    min-height: 2.25rem;
    border-radius: 0.375rem;
}
