/*--------------------------------------------------------------
# PhyFa Phyond Styles - v1.1.2 (Pagination & Loader Fix)
--------------------------------------------------------------*/

/* --- Font Application --- */
.phyfa-container h1, .phyfa-container h2, .phyfa-container h3, .phyfa-container h4, .phyfa-container h5, .phyfa-container h6,
.phyfa-modal-content h1, .phyfa-modal-content h2, .phyfa-modal-content h3, .phyfa-modal-content h4, .phyfa-modal-content h5, .phyfa-modal-content h6 {
    font-family: var(--phyfa-font-primary);
    font-weight: 600;
}
.phyfa-container, .phyfa-modal-content p, .phyfa-user-response p, .phyfa-explanation-pending {
    font-family: var(--phyfa-font-primary);
}
.phyfa-button, #phyfa-phyond-challenge-form textarea {
    font-family: var(--phyfa-font-primary);
}

/* General Container */
.phyfa-container.phyfa-phyond-container {
    font-family: var(--phyfa-font-primary);
    color: var(--phyfa-text-light);
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
}

/* Section Titles */
.phyfa-phyond-history-container .phyfa-section-title {
    font-size: 1.8em;
    margin-bottom: 30px;
    color: var(--phyfa-text-light);
    text-align: center;
    padding-bottom: 15px;
    font-weight: 600 !important;
    font-family: var(--phyfa-font-primary) !important;
}

/* Challenge Buttons */
.phyfa-phyond-challenge-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

/* --- Modal Size Correction --- */
#phyfa-challenge-modal .phyfa-modal-content,
#phyfa-explanation-modal .phyfa-modal-content {
    width: 90%;
    max-width: 1100px;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#phyfa-challenge-modal .phyfa-modal-body,
#phyfa-explanation-modal .phyfa-modal-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    margin-top: 30px;
    text-align: right;
}
#phyfa-challenge-modal,
#phyfa-explanation-modal {
    z-index: 9990;
}
#phyfa-challenge-modal .phyfa-modal-body::-webkit-scrollbar,
#phyfa-explanation-modal .phyfa-modal-body::-webkit-scrollbar {
  width: 8px;
}
#phyfa-challenge-modal .phyfa-modal-body::-webkit-scrollbar-track,
#phyfa-explanation-modal .phyfa-modal-body::-webkit-scrollbar-track {
  background: var(--phyfa-background-dark);
  border-radius: 4px;
}
#phyfa-challenge-modal .phyfa-modal-body::-webkit-scrollbar-thumb,
#phyfa-explanation-modal .phyfa-modal-body::-webkit-scrollbar-thumb {
  background-color: var(--phyfa-primary-color);
  border-radius: 4px;
  border: 2px solid var(--phyfa-background-dark);
}
#phyfa-challenge-modal .phyfa-modal-close,
#phyfa-explanation-modal .phyfa-modal-close {
     top: 15px;
     left: 20px;
     z-index: 10;
}

/* Modal Content Styling */
#phyfa-challenge-content,
#phyfa-explanation-content {
    text-align: center;
}
#phyfa-challenge-content h3,
#phyfa-explanation-content h3 {
     font-size: 1.6em !important;
     margin-bottom: 10px;
     color: var(--phyfa-primary-color);
     padding-bottom: 10px;
     border-bottom: 2px solid #f89b29;
     font-weight: 600 !important;
     font-family: var(--phyfa-font-primary) !important;
}
#phyfa-challenge-content p:first-of-type {
    margin-bottom: 25px;
    color: #f89b29;
    font-size: 1em;
}

/* Challenge/Explanation Image Styling */
.phyfa-phyond-challenge-image,
.phyfa-phyond-explanation-image {
    width: 100%;
    text-align: center;
    margin-bottom: 25px;
}
.phyfa-phyond-challenge-image img,
.phyfa-phyond-explanation-image img {
    max-width: 100%;
    width: auto;
    max-height: 75vh;
    height: auto;
    border-radius: 8px;
    display: inline-block;
    border: 1px solid var(--phyfa-background-light);
}

/* Challenge Form */
#phyfa-phyond-challenge-form {
    margin-top: 20px;
    padding: 0;
    background: none;
    border: none;
    text-align: right;
}
#phyfa-phyond-challenge-form textarea {
    width: 100%;
    min-height: 120px;
    border-radius: 8px;
    padding: 15px;
    box-sizing: border-box;
    background: var(--phyfa-background-dark);
    color: var(--phyfa-text-light);
    border: 1px solid var(--phyfa-background-light);
    @supports (corner-shape: squircle) {
    border-radius: 80px;
    corner-shape: squircle;
    }
    resize: vertical;
    font-size: 1em;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: 15px;
}
#phyfa-phyond-challenge-form textarea:focus {
    border-color: var(--phyfa-primary-color);
    outline: none;
    box-shadow: 0 0 5px rgba(230, 87, 23, 0.5);
}
#phyfa-phyond-challenge-form button[type="submit"] {
    display: block;
    width: auto;
    padding: 12px 30px;
    margin: 15px auto 0 auto;
}

/* History Styles */
.phyfa-phyond-history-list {
    display: flex;
    flex-direction: column;
    gap: 30px;
    transition: opacity 0.3s ease-in-out; /* Smooth fade for AJAX */
}
.phyfa-phyond-history-item {
    background: var(--phyfa-background-darker);
    border-radius: 10px;
    padding: 25px;
    border: 1px solid var(--phyfa-background-light);
    transition: border-color 0.3s ease;
}
.phyfa-phyond-history-item:hover {
    border-color: var(--phyfa-primary-color);
}
.phyfa-phyond-history-item h3 {
    color: var(--phyfa-primary-color);
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--phyfa-background-light);
    padding-bottom: 10px;
    font-size: 1.4em !important;
    font-weight: 600 !important;
    font-family: var(--phyfa-font-primary) !important;
}
.phyfa-phyond-history-item p {
    margin-bottom: 10px;
    color: var(--phyfa-text-gray);
    line-height: 1.6;
}
.phyfa-phyond-history-item p strong {
    color: var(--phyfa-text-light);
    margin-left: 8px;
}

/* User Response Box in History */
.phyfa-user-response {
    width: 100%;
    margin: 25px 0;
    padding: 20px;
    background: var(--phyfa-background-dark);
    color: var(--phyfa-text-light);
    border-radius: 8px;
    border-right: 4px solid var(--phyfa-primary-color);
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    box-sizing: border-box;
}
.phyfa-user-response h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--phyfa-primary-color);
    font-size: 1.1em !important;
    font-weight: 600 !important;
    font-family: var(--phyfa-font-primary) !important;
}

/* Explanation Image in History */
.phyfa-phyond-explanation-image h4 {
     margin-top: 25px;
     margin-bottom: 10px;
     color: var(--phyfa-primary-color);
     font-size: 1.1em !important;
     font-weight: 600 !important;
     font-family: var(--phyfa-font-primary) !important;
}
.phyfa-phyond-history-container .phyfa-phyond-history-item .phyfa-phyond-explanation-image img, .phyfa-phyond-history-container .phyfa-phyond-history-item .phyfa-phyond-challenge-image img {
     max-width: 100%;
     width: auto;
     max-height: 60vh;
     height: auto;
     border-radius: 8px;
     display: block;
     margin: 15px auto;
     border: 1px solid var(--phyfa-background-light);
}

.phyfa-explanation-pending {
    margin-top: 20px;
    color: var(--phyfa-text-gray);
    font-style: italic;
}

/* Claim Points Button */
.phyfa-phyond-claim-points {
    margin-top: 20px;
    display: inline-block;
    padding: 10px 20px;
    font-size: 0.9em;
}
.phyfa-phyond-claim-points:disabled {
    background-color: var(--phyfa-success-color);
    opacity: 1;
    cursor: default;
    transform: none;
}
.phyfa-phyond-claim-points:disabled:hover {
     background-color: var(--phyfa-success-color);
}

/* --- NEW & IMPROVED: Pagination Styles --- */
.phyfa-phyond-history-container .phyfa-pagination {
    margin-top: 40px;
    text-align: center;
    direction: ltr; /* Ensure correct layout for pagination controls */
}

.phyfa-phyond-history-container .phyfa-pagination .page-numbers {
    display: inline-block;
    padding: 8px 15px;
    margin: 0 4px;
    border-radius: 5px;
    background-color: var(--phyfa-background-dark);
    color: var(--phyfa-text-gray);
    border: 1px solid var(--phyfa-background-light);
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    font-family: var(--phyfa-font-primary);
    font-size: 0.9em;
}

.phyfa-phyond-history-container .phyfa-pagination .page-numbers:not(.current):hover {
    background-color: var(--phyfa-primary-color);
    color: #fff;
    border-color: var(--phyfa-primary-color);
    transform: translateY(-2px);
}

.phyfa-phyond-history-container .phyfa-pagination .page-numbers.current {
    background-color: var(--phyfa-primary-color);
    color: #fff;
    border-color: var(--phyfa-primary-color);
    cursor: default;
}


/* --- NEW & IMPROVED: History AJAX Loading State --- */
.phyfa-phyond-history-container {
    position: relative; 
    min-height: 200px; 
}

.phyfa-phyond-history-container.phyfa-history-loading::after {
    content: '';
    position: absolute;
    top: 150px;
    left: 50%;
    width: 40px;
    height: 40px;
    /* --- FIX: Set initial transform for horizontal centering --- */
    transform: translateX(-50%); 
    border: 4px solid var(--phyfa-background-light);
    border-top-color: var(--phyfa-primary-color);
    border-radius: 50%;
    animation: phyfa-spin 1s linear infinite;
    z-index: 10;
}

/* Ensure the animation is defined */
@keyframes phyfa-spin {
    /* --- FIX: Combine positioning and rotation transforms --- */
    /* This ensures the element stays centered while rotating. */
    to {
        transform: translateX(-50%) rotate(360deg);
    }
}


/* --- Card Styles (Unchanged) --- */
.phyond-card-grid {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
    gap: 1.5rem;
    max-width: 900px;
    width: 100%;
    margin: 20px auto;
    padding: 10px;
}
.phyond-card {
    flex: 1 1 300px;
    max-width: 420px;
    background: linear-gradient(135deg, #252626 0%, #1b1a1b 100%);
    border-radius: 15px;
    border: 2px solid #403d39;
    @supports (corner-shape: squircle) {
    border-radius: 100px;
    corner-shape: squircle;

  }
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}
.phyond-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 212, 107, 0.1), transparent);
    transition: left 0.6s ease;
    transform: skewX(-25deg);
    left: -100%;
    pointer-events: none; 
}
.phyond-card:hover::before {
    left: 120%;
}
.phyond-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border-color: #e65717;
}
.phyond-inner {
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.2rem;
    min-height: 250px;
}
.phyond-card-icon {
    font-size: 3rem;
    color: #e65717;
    margin-bottom: 0.5rem;
    transition: all 0.3s;
    text-shadow: 0 0 10px rgba(230, 87, 23, 0.4);
}
.phyond-card:hover .phyond-card-icon {
    color: #f89b29;
    transform: scale(1.1);
    text-shadow: 0 0 20px rgba(248, 155, 41, 0.7);
}
.phyond-card-title, .phyond-card-desc {
    color: #fffcf2;
    margin: 0;
}
.phyond-card-title { color: #f89b29 !important; font-size: 3rem !important; font-weight: 400 !important; font-family: 'Aparat' !important; }
.phyond-card-desc { color: #F89B48; font-size: 1rem !important; font-weight: 400 !important; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .phyfa-phyond-challenge-buttons {
        flex-direction: column;
        gap: 15px;
    }
    .phyfa-phyond-challenge-buttons button {
        width: 100%;
        margin: 0;
        box-sizing: border-box;
    }
    #phyfa-phyond-challenge-form button[type="submit"]{
      width: 100%;
      box-sizing: border-box;
    }
    .phyfa-phyond-history-item { padding: 20px; }
    .phyfa-phyond-history-item h3 { font-size: 1.3em !important; }

    #phyfa-challenge-modal .phyfa-modal-content,
    #phyfa-explanation-modal .phyfa-modal-content {
        width: 95%;
        height: 95vh;
        max-height: 95vh;
    }
    .phyond-card-title {
        font-size: 2rem !important;
    }
    .phyond-card-desc {
     font-size: 0.9rem !important;   
    }
}

@media (max-width: 480px) {
    #phyfa-challenge-content h3,
    #phyfa-explanation-content h3 {
         font-size: 1.4em !important;
    }
    .phyfa-phyond-history-item h3 { font-size: 1.2em !important; }
    .phyfa-phyond-history-container .phyfa-pagination .page-numbers {
        padding: 6px 10px;
        font-size: 0.8em;
    }
    
    .phyond-card-title {
        font-size: 2rem !important;
    }
    
    .phyond-card-desc {
     font-size: 0.9rem !important;   
    }
}

/* --- Phyond Point Icon Styles --- */
.phyfa-point-icon-png.phyfa-phyond-icon {
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
    margin: 0 3px;
    display: inline-block;
}
#phyfa-message-modal .phyfa-point-icon-png.phyfa-phyond-icon {
    width: 1.2em;
    height: 1.2em;
    vertical-align: -0.2em;
}