/**
 * Site Enhancements CSS
 * - Page transitions
 * - Loading screen
 * - Back-to-top button
 * - Section dividers
 * - Skills animations
 * - Contact form enhancements
 * - Portfolio filtering effects
 * - Theme toggle
 */

/* ============================================
   1. PAGE LOADING SCREEN
   ============================================ */
.page-loader {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #040b14 0%, #0a192f 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  text-align: center;
}

.loader-spinner {
  width: 50px;
  height: 50px;
  position: relative;
  margin: 0 auto 20px;
}

.loader-spinner::before,
.loader-spinner::after {
  content: '';
  position: absolute;
  border-radius: 50%;
}

.loader-spinner::before {
  inset: 0;
  border: 3px solid rgba(20, 157, 221, 0.2);
}

.loader-spinner::after {
  inset: 0;
  border: 3px solid transparent;
  border-top-color: #149ddd;
  animation: loaderSpin 0.8s linear infinite;
}

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

.loader-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.loader-progress {
  width: 150px;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 15px;
  overflow: hidden;
}

.loader-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #149ddd, #4fc3f7);
  width: 0;
  transition: width 0.3s ease;
}

/* ============================================
   2. PAGE TRANSITIONS
   ============================================ */
.page-transition {
  position: fixed;
  inset: 0;
  background: #040b14;
  z-index: 99998;
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.page-transition.active {
  transform: translateY(0);
}

body.page-transitioning {
  overflow: hidden;
}

/* Content fade-in on load */
.page-content {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

body.page-loaded .page-content {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   3. BACK TO TOP BUTTON (ENHANCED)
   ============================================ */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #149ddd 0%, #0d7ab5 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  z-index: 9996;
  box-shadow: 0 4px 15px rgba(20, 157, 221, 0.3);
  overflow: hidden;
}

.back-to-top.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: linear-gradient(135deg, #0d7ab5 0%, #149ddd 100%);
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(20, 157, 221, 0.4);
  color: #fff;
}

/* Progress ring */
.back-to-top .progress-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
}

.back-to-top .progress-ring circle {
  fill: none;
  stroke-width: 3;
}

.back-to-top .progress-ring .progress-bg {
  stroke: rgba(255, 255, 255, 0.2);
}

.back-to-top .progress-ring .progress-value {
  stroke: #fff;
  stroke-dasharray: 157;
  stroke-dashoffset: 157;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.1s ease;
}

/* ============================================
   4. SECTION DIVIDERS
   ============================================ */
.section-divider {
  position: relative;
  height: 100px;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.section-divider svg {
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0;
}

.section-divider.wave-top svg {
  top: 0;
}

.section-divider.wave-bottom svg {
  bottom: 0;
  transform: rotate(180deg);
}

.section-divider path {
  fill: var(--section-bg, #f5f8fd);
}

/* Different section backgrounds */
.section-divider.to-dark path {
  fill: #040b14;
}

.section-divider.to-light path {
  fill: #f5f8fd;
}

.section-divider.to-white path {
  fill: #fff;
}

/* Animated wave */
.section-divider.animated path {
  animation: wavePulse 8s ease-in-out infinite;
}

@keyframes wavePulse {
  0%, 100% { d: path("M0,64 C200,100 400,20 600,64 C800,108 1000,44 1200,64 L1200,120 L0,120 Z"); }
  50% { d: path("M0,64 C200,20 400,100 600,64 C800,28 1000,90 1200,64 L1200,120 L0,120 Z"); }
}

/* ============================================
   5. SKILLS SECTION ANIMATION
   ============================================ */
.skill-item {
  margin-bottom: 25px;
}

.skill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.skill-name {
  font-weight: 600;
  color: #45505b;
  font-size: 0.95rem;
}

.skill-percent {
  font-size: 0.85rem;
  color: #149ddd;
  font-weight: 600;
}

.skill-bar {
  height: 10px;
  background: rgba(20, 157, 221, 0.1);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.skill-progress {
  height: 100%;
  background: linear-gradient(90deg, #149ddd 0%, #4fc3f7 100%);
  border-radius: 5px;
  width: 0;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.skill-progress::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  animation: skillShine 2s ease-in-out infinite;
  animation-delay: 1.5s;
}

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

/* Skill categories */
.skill-category {
  margin-bottom: 35px;
}

.skill-category-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #45505b;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.skill-category-title i {
  color: #149ddd;
}

/* ============================================
   6. CONTACT FORM ENHANCEMENTS
   ============================================ */
.php-email-form .form-group {
  position: relative;
  margin-bottom: 25px;
}

.php-email-form label {
  position: absolute;
  left: 15px;
  top: 12px;
  color: #6c757d;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  pointer-events: none;
  background: transparent;
  padding: 0 5px;
}

.php-email-form .form-control {
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  transition: all 0.3s ease;
  background: #fff;
}

.php-email-form .form-control:focus {
  border-color: #149ddd;
  box-shadow: 0 0 0 4px rgba(20, 157, 221, 0.1);
}

/* Floating label effect */
.php-email-form .form-control:focus + label,
.php-email-form .form-control:not(:placeholder-shown) + label,
.php-email-form .form-control.has-value + label {
  top: -10px;
  left: 10px;
  font-size: 0.8rem;
  color: #149ddd;
  background: #fff;
}

/* Input validation states */
.php-email-form .form-control.is-valid {
  border-color: #28a745;
}

.php-email-form .form-control.is-invalid {
  border-color: #dc3545;
  animation: inputShake 0.5s ease;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

/* Submit button */
.php-email-form button[type="submit"] {
  position: relative;
  padding: 12px 35px;
  border-radius: 30px;
  overflow: hidden;
  transition: all 0.3s ease;
}

.php-email-form button[type="submit"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.php-email-form button[type="submit"]:hover::before {
  transform: translateX(100%);
}

/* Success message animation */
.form-success-message {
  animation: successPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes successPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================
   7. PORTFOLIO FILTERING EFFECTS
   ============================================ */
.portfolio-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 30px;
}

.portfolio-filters li {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #45505b;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 25px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.portfolio-filters li::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #149ddd 0%, #4fc3f7 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
  border-radius: 25px;
}

.portfolio-filters li:hover {
  color: #149ddd;
  border-color: rgba(20, 157, 221, 0.3);
}

.portfolio-filters li.filter-active {
  color: #fff;
  border-color: transparent;
}

.portfolio-filters li.filter-active::before {
  opacity: 1;
}

/* Portfolio items transition */
.portfolio-item {
  transition: all 0.4s ease;
}

.portfolio-item.filtering {
  opacity: 0;
  transform: scale(0.8);
}

.portfolio-item.filtered-in {
  animation: portfolioFadeIn 0.5s ease forwards;
}

@keyframes portfolioFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   8. THEME TOGGLE BUTTON
   ============================================ */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: rgba(20, 157, 221, 0.1);
  border: 2px solid rgba(20, 157, 221, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9997;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  background: rgba(20, 157, 221, 0.2);
  border-color: #149ddd;
  transform: scale(1.1);
}

.theme-toggle i {
  font-size: 1.2rem;
  color: #149ddd;
  transition: transform 0.5s ease;
}

.theme-toggle:hover i {
  transform: rotate(180deg);
}

/* Sun/Moon icons */
.theme-toggle .bi-sun-fill {
  display: none;
}

.theme-toggle .bi-moon-fill {
  display: block;
}

[data-theme="dark"] .theme-toggle .bi-sun-fill {
  display: block;
}

[data-theme="dark"] .theme-toggle .bi-moon-fill {
  display: none;
}

[data-theme="dark"] .theme-toggle {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.3);
}

[data-theme="dark"] .theme-toggle i {
  color: #ffc107;
}

/* ============================================
   9. DARK MODE ENHANCEMENTS
   ============================================ */
[data-theme="dark"] .page-loader {
  background: linear-gradient(135deg, #020508 0%, #0a1628 100%);
}

[data-theme="dark"] .skill-name {
  color: #e0e0e0;
}

[data-theme="dark"] .skill-bar {
  background: rgba(79, 195, 247, 0.1);
}

[data-theme="dark"] .php-email-form .form-control {
  background: #112240;
  border-color: #233554;
  color: #e0e0e0;
}

[data-theme="dark"] .php-email-form label {
  color: #8892b0;
}

[data-theme="dark"] .php-email-form .form-control:focus + label,
[data-theme="dark"] .php-email-form .form-control:not(:placeholder-shown) + label {
  background: #112240;
}

[data-theme="dark"] .portfolio-filters li {
  color: #ccd6f6;
}

[data-theme="dark"] .section-divider.to-light path {
  fill: #0a192f;
}

/* ============================================
   10. REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .loader-spinner::after,
  .skill-progress::after,
  .section-divider.animated path {
    animation: none;
  }
  
  .page-transition,
  .page-content,
  .back-to-top,
  .portfolio-item {
    transition: none;
  }
  
  .portfolio-item.filtered-in {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ============================================
   11. RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
  .back-to-top {
    width: 45px;
    height: 45px;
    bottom: 20px;
    right: 20px;
    font-size: 20px;
  }
  
  .theme-toggle {
    top: 15px;
    left: 15px;  /* Position on left side on mobile */
    right: auto;
    width: 40px;
    height: 40px;
    z-index: 9996;  /* Below mobile nav toggle to avoid conflicts */
  }
  
  .section-divider {
    height: 60px;
  }
  
  .portfolio-filters li {
    padding: 6px 15px;
    font-size: 0.85rem;
  }
}
