/**
 * Test Builder Pro - Questions Pagination Styles
 *
 * @package TestBuilderPro
 * @subpackage Assets\CSS
 * @since 2.0.0
 */

/* 
 * Additional test-specific colors
 * (not in variables.css to preserve existing design)
 */
:root {
  --tbp-question-number-bg: #efc718;
  --tbp-button-bg: #efc718;
  --tbp-button-hover: #e5be10;
  --tbp-prev-button-bg: #777777;
  --tbp-prev-button-hover: #666666;
  --tbp-submit-button-bg: #2ecc71;
  --tbp-submit-button-hover: #27ae60;
  --tbp-error-color: #ff4444;
  --tbp-progress-gradient: linear-gradient(90deg, #6198ff, #2481d8);
  --tbp-progress-complete: #2ecc71;
}

/* Base Utilities */
.tbp-hide {
  display: none;
}

.tbp-clear {
  clear: both;
  margin-bottom: var(--tbp-space-md);
}

/* Container Layouts */
.tbp-test-container {
  margin-top: 60px; /* Height of fixed progress bar + padding */
}

.tbp-disclaimer {
  background-color: var(--tbp-light-bg);
  padding: var(--tbp-space-sm);
  margin-bottom: var(--tbp-space-lg);
  border-left: 4px solid #908eff;
}

/* Grid Layout */
.tbp-page-questions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 25px;
  align-items: start;
  justify-items: center;
  max-width: 760px;
  margin-right: auto;
  margin-left: auto;
}

/* Question Styling */
.tbp-question {
  background: #f4f4f4;
  width: 100%;
  border: 1px solid #c8c8c8;
  overflow: hidden;
  margin: 0;
  transition: var(--tbp-transition);
}

.tbp-question-text {
  height: 90px;
  background: var(--tbp-white);
  width: 100%;
  position: relative;
  padding: var(--tbp-space-sm) var(--tbp-space-sm) var(--tbp-space-sm) 70px;
  display: flex;
  align-items: center;
  line-height: 1.4;
}

.tbp-question-number {
  background: var(--tbp-question-number-bg);
  width: 60px;
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--tbp-font-size-lg);
  font-weight: 500;
}

/* Answer Options Styling */
.tbp-options {
  padding: var(--tbp-space-sm);
}

.tbp-option {
  border-bottom: 1px dashed var(--tbp-border-light);
  transition: background-color 0.2s ease;
}

.tbp-option:last-child {
  border-bottom: none;
}

.tbp-option:hover {
  background-color: var(--tbp-light-bg);
}

.tbp-option input[type="radio"] {
  margin: 12px var(--tbp-space-sm);
}

.tbp-option label {
  padding: var(--tbp-space-sm) var(--tbp-space-xs);
  display: inline-block;
  cursor: pointer;
  width: calc(100% - 40px);
  vertical-align: middle;
}

/* Error States */
.unanswered-highlight {
  border: 1px solid var(--tbp-error-color) !important;
  box-shadow: 0 0 5px rgba(255, 68, 68, 0.4) !important;
}

.tbp-error-message {
  color: var(--tbp-error-color);
  font-weight: bold;
  text-align: center;
  margin: var(--tbp-space-sm) 0;
  padding: var(--tbp-space-sm);
  display: none;
  animation: fadeIn 0.3s ease;
}

/* Enhanced Pulse Animation for Unanswered Questions */
.pulse-animation {
  animation: pulse-border 1.8s infinite;
  position: relative;
  z-index: 2; /* Ensure it's above the darkened questions */
}

@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.8);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(255, 68, 68, 0.4);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
  }
}

/* Warning Mode - Darken answered questions to make unanswered stand out */
.tbp-warning-mode .tbp-question {
  position: relative;
  transition: all 0.5s ease;
}

.tbp-warning-mode .tbp-question::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.15);
  z-index: 1;
  pointer-events: none; /* Allow clicks to pass through */
  transition: opacity 0.3s ease;
}

/* Remove darkening effect from unanswered questions */
.tbp-warning-mode .unanswered-highlight::after {
  opacity: 0;
}

/* Extra highlight for current focused question */
.current-focus {
  border: 1px solid var(--tbp-error-color) !important;
  box-shadow: 0 0 0 3px rgba(255, 68, 68, 0.9) !important;
  z-index: 5;
  position: relative;
  transform: scale(1.02);
  transition: transform 0.3s ease;
}

/* Remove darkening from current focus */
.tbp-warning-mode .current-focus::after {
  opacity: 0;
}

/* The current focus should also have a more prominent highlight */
.current-focus.pulse-animation {
  animation: pulse-border-focus 1.5s infinite;
}

@keyframes pulse-border-focus {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.9);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(255, 68, 68, 0.5);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0);
  }
}

/* Submit Area */
.tbp-submit-quiz-results {
  padding: var(--tbp-space-lg);
  margin: var(--tbp-space-lg) 0;
  border-radius: var(--tbp-radius-md);
  text-align: center;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Button base styles */
.tbp-btn {
  border: none;
  border-radius: var(--tbp-radius-sm);
  padding: var(--tbp-space-sm) var(--tbp-space-xl);
  font-size: var(--tbp-font-size-md-l);
  cursor: pointer;
  transition: var(--tbp-transition);
  box-shadow: var(--tbp-shadow-sm);
  color: var(--tbp-text-white);
}

/* Button states */
.tbp-btn-ready {
  background: var(--tbp-submit-button-bg) !important;
}

.tbp-btn-ready:hover {
  background: var(--tbp-submit-button-hover) !important;
  transform: translateY(-1px);
  box-shadow: var(--tbp-shadow-md);
}

.tbp-btn-inactive {
  background: #cecece !important;
  color: #666;
  cursor: pointer;
  opacity: 0.9;
  box-shadow: none;
}

.tbp-btn-inactive:hover {
  background: #d8d8d8 !important;
  transform: none;
  box-shadow: none;
}

.tbp-btn-warning {
  background: var(--tbp-error-color) !important;
}

.tbp-btn-warning:hover {
  background: #e04141 !important;
  transform: translateY(-1px);
  box-shadow: var(--tbp-shadow-md);
}

/* Submit Button Highlight Animation */
.tbp-submit-highlight {
  animation: submitHighlight 2s ease-in-out;
  transform: scale(1.05);
}

@keyframes submitHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.8);
    transform: scale(1.05);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(46, 204, 113, 0.4);
    transform: scale(1.05);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    transform: scale(1);
  }
}

/* Progress Bar Container */
.tbp-progress-container {
  position: fixed;
  top: -60px;
  left: 0;
  right: 0;
  z-index: var(--tbp-z-modal);
  background: rgba(255, 255, 255, 0.95);
  padding: var(--tbp-space-sm) var(--tbp-space-md);
  box-shadow: var(--tbp-shadow-sm);
  transition: top 0.3s ease-in-out;
}

.tbp-progress-container.visible {
  top: 0;
}

.tbp-progress-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--tbp-space-sm);
}

.tbp-progress-bar {
  flex-grow: 1;
  height: 8px;
  background: #e0e0e0;
  border-radius: var(--tbp-radius-sm);
  overflow: hidden;
}

.tbp-progress-bar-fill {
  height: 100%;
  width: 0;
  background: var(--tbp-progress-gradient);
  transition: width 0.3s ease-in-out;
  border-radius: var(--tbp-radius-sm);
  position: relative;
}

/* Green state for 100% */
.tbp-progress-bar-fill.complete {
  background: var(--tbp-progress-complete);
}

/* Progress Bar Error States */
.tbp-progress-container.error-state {
  background: rgba(255, 68, 68, 0.95);
  color: white;
}

.tbp-progress-container.error-state .tbp-progress-bar {
  background: rgba(255, 255, 255, 0.3);
}

.tbp-progress-container.error-state .tbp-progress-bar-fill {
  background: rgba(255, 255, 255, 0.8);
}

.tbp-progress-container.complete-state {
  background: rgba(46, 204, 113, 0.95);
  color: white;
}

.tbp-progress-container.complete-state .tbp-progress-bar {
  background: rgba(255, 255, 255, 0.3);
}

.tbp-progress-container.complete-state .tbp-progress-bar-fill {
  background: rgba(255, 255, 255, 0.9);
}

/* Progress Text Styling */
.tbp-progress-text {
  font-weight: 600;
  font-size: var(--tbp-font-size-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.tbp-progress-text.error-text {
  font-size: var(--tbp-font-size-sm);
  max-width: 300px;
}

/* Responsive adjustments for progress bar */
@media screen and (max-width: 768px) {
  .tbp-progress-text {
    max-width: 150px;
    font-size: var(--tbp-font-size-sm);
  }

  .tbp-progress-text.error-text {
    max-width: 250px;
    font-size: var(--tbp-font-size-xs);
  }
}

@media screen and (max-width: 499px) {
  .tbp-progress-text {
    max-width: 100px;
  }

  .tbp-progress-text.error-text {
    max-width: 180px;
  }
}

/* Shimmer effect */
.tbp-progress-bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* iOS Specific Fixes */
/* Ensure the question header has a proper flex layout */
.ios-device .tbp-question-text,
.ios-device .tbp-question-number {
  position: static;
  height: auto;
  min-height: 0;
  padding: 0;
  margin: 0;
}

/* iOS question layout structure */
.ios-device .tbp-question-header {
  display: flex;
  background: #ffffff;
  width: 100%;
  min-height: 90px;
  border-collapse: collapse;
  font-size: 0;
}

/* Container for the number to ensure proper layout */
.ios-device .tbp-question-number-wrapper {
  flex: 0 0 60px;
  width: 60px;
  position: relative;
  margin: 0;
  padding: 0;
  font-size: 0;
}

/* Number element with fixed dimensions */
.ios-device .tbp-question-number-ios {
  background: #efc718;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 500;
  position: absolute;
  top: 0;
  left: 0;
}

/* Content area with proper padding and layout */
.ios-device .tbp-question-content-ios {
  flex: 1;
  padding: 15px;
  padding-left: 15px;
  margin-left: 0;
  display: flex;
  align-items: center;
  line-height: 1.4;
  min-height: 60px;
  font-size: 1rem;
}

/* Make sure the content doesn't overlap */
.ios-device .tbp-question-content-ios p {
  margin: 0;
  padding: 0;
}

/* Fix option layout for iOS */
.ios-device .tbp-option {
  display: flex;
  align-items: center;
  border-bottom: 1px dashed #f0f0f0;
  padding: 0;
  margin: 0;
}

.ios-device .tbp-option:last-child {
  border-bottom: none;
}

.ios-device .tbp-option input[type="radio"] {
  margin: 12px 10px;
  flex: 0 0 auto;
}

.ios-device .tbp-option label {
  flex: 1;
  padding: 10px 5px;
  display: block;
  width: auto;
}

/* Force hardware acceleration for smoother rendering */
.ios-device .tbp-question,
.ios-device .tbp-question-header,
.ios-device .tbp-question-number-wrapper,
.ios-device .tbp-question-content-ios {
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-sizing: border-box;
}

/* Force layout recalculation on iOS */
.ios-device .tbp-question {
  opacity: 0.99;
}

/* Hide Sticky Header on test pages */
.test-template-tests .ast-main-header-wrap.main-header-bar-wrap.sticky-header {
  display: none !important;
}

/* Responsive Adjustments */
@media screen and (max-width: 672px) {
  .tbp-page-questions {
    grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  }
}

@media screen and (max-width: 499px) {
  form#tbp-test-form .tbp-page-questions fieldset {
    max-width: 300px;
    width: 100%;
  }

  .tbp-btn {
    padding: var(--tbp-space-sm) var(--tbp-space-lg);
    font-size: var(--tbp-font-size-md);
  }
}
