/* Styles for Gallery */
.gallery-filter {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 30px;
  gap: 10px;
}

.filter-btn {
  background-color: var(--bg-alice-blue);
  color: var(--text-slate-gray);
  font-size: var(--fs-6);
  font-weight: 500;
  padding: 5px 20px;
  border-radius: 5px;
  cursor: pointer;
  transition: 0.3s ease;
  border: none;
}

.filter-btn.active, .filter-btn:hover {
  background-color: var(--bg-majorelle-blue);
  color: var(--text-white);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-item {
  overflow: hidden;
  border-radius: 10px;
  box-shadow: var(--shadow-1);
  cursor: pointer;
  transition: transform 0.3s ease;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Enhanced Gallery Section */
.gallery.section {
  padding: 60px 0;
}

.gallery .container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 15px;
}

.gallery-filter {
  margin-bottom: 30px;
}

.section-text {
  margin-bottom: 30px;
}

/* Ensure all gallery items maintain consistent height */
.gallery-image {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Make sure images stay within their container */
.gallery-image img {
  flex: 1;
  max-height: 250px;
  min-height: 250px;
}

.gallery-item:hover {
  transform: translateY(-5px);
}

.gallery-image {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
}

.gallery-image img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}

.gallery-image figcaption {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item:hover figcaption {
  opacity: 1;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.9);
}

.lightbox-content {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  max-width: 80%;
  margin: 0 auto;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  margin: auto;
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 30px;
  color: white;
  cursor: pointer;
  z-index: 11;
}

.lightbox-controls {
  width: 100%;
  display: flex;
  justify-content: space-between;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-prev,
.lightbox-next {
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  padding: 10px 15px;
  cursor: pointer;
  font-size: 18px;
  border-radius: 3px;
}

.lightbox-caption {
  color: white;
  text-align: center;
  padding: 10px;
  margin-top: 15px;
  font-size: 16px;
}

/* Project Modal */
.project-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.85);
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.project-modal.open {
  opacity: 1;
}

.modal-project-content {
  background-color: var(--white);
  margin: 5% auto;
  padding: 30px;
  width: 90%;
  max-width: 950px;
  border-radius: 12px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
  color: var(--independence);
  max-height: 90vh;
  overflow-y: auto;
}

.project-modal.open .modal-project-content {
  transform: translateY(0);
  opacity: 1;
}

.close-modal {
  position: absolute;
  top: 15px;
  right: 20px;
  color: var(--independence);
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.9);
}

.close-modal:hover {
  color: var(--orange-soda);
  transform: rotate(90deg);
}

.project-details {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .project-details {
    flex-direction: row;
    gap: 30px;
  }
  
  .img-container {
    flex: 0 0 45%;
    max-width: 45%;
  }
  
  .project-info {
    flex: 1;
  }
}

.img-container {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  height: 300px;
}

.modal-project-img {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.project-info {
  padding: 0;
}

.modal-project-title {
  margin-top: 0;
  margin-bottom: 15px;
  color: var(--midnight-blue);
  font-size: 28px;
  font-weight: var(--fw-600);
  letter-spacing: -0.5px;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tag {
  background-color: var(--independence);
  color: var(--white);
  padding: 6px 12px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.tag:hover {
  background-color: var(--orange-soda);
  transform: translateY(-2px);
}

.project-description {
  margin-bottom: 25px;
  line-height: 1.7;
  color: var(--independence);
  font-size: 16px;
}

.tech-stack h4 {
  margin-bottom: 15px;
  color: var(--midnight-blue);
  font-size: 20px;
  font-weight: var(--fw-600);
  position: relative;
  padding-left: 15px;
}

.tech-stack h4::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 20px;
  background-color: var(--orange-soda);
  border-radius: 2px;
}

.tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 15px 30px;
  list-style: none;
  padding-left: 0;
  margin-bottom: 30px;
}

.tech-list li {
  position: relative;
  padding-left: 18px;
  color: var(--independence);
  font-size: 15px;
  flex: 0 0 calc(50% - 30px);
}

.tech-list li::before {
  content: "•";
  color: var(--orange-soda);
  position: absolute;
  left: 0;
  font-size: 18px;
}

.project-links {
  display: flex;
  gap: 15px;
  margin-top: 20px;
}

.live-demo-link,
.source-code-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 5px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.live-demo-link {
  background-color: var(--orange-soda);
  color: white;
}

.source-code-link {
  background-color: var(--independence);
  color: var(--white);
}

.live-demo-link:hover,
.source-code-link:hover {
  opacity: 0.9;
  transform: translateY(-2px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .modal-project-content {
    padding: 20px;
    margin: 10% auto;
    width: 95%;
  }
  
  .project-info {
    padding: 0;
  }
  
  .img-container {
    height: 250px;
  }
  
  .tech-list li {
    flex: 0 0 100%;
  }
  
  .project-links {
    flex-direction: column;
  }
  
  .live-demo-link,
  .source-code-link {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .modal-project-content {
    padding: 15px;
    margin: 15% auto;
  }
  
  .img-container {
    height: 200px;
  }
  
  .close-modal {
    top: 10px;
    right: 10px;
    font-size: 26px;
  }
  
  .modal-project-title {
    font-size: 22px;
  }
}

/* Contact Form Button */
.btn-submit {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.btn-submit ion-icon {
  font-size: 18px;
}

/* Social Links */
.social-links {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}

.social-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background-color: var(--bg-alice-blue);
  color: var(--text-slate-gray);
  border-radius: 50%;
  font-size: 20px;
  transition: 0.3s ease;
}

.social-link:hover {
  background-color: var(--bg-majorelle-blue);
  color: var(--text-white);
  transform: translateY(-5px);
}

/* Form Status */
.form-status {
  padding: 10px;
  margin-bottom: 15px;
  border-radius: 5px;
  display: none;
}

.form-status.success {
  display: block;
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.form-status.error {
  display: block;
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* Loading States */
.loading {
  position: relative;
  min-height: 200px;
}

.loading::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.7);
  z-index: 0;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 5px solid var(--bg-alice-blue);
  border-top-color: var(--bg-majorelle-blue);
  animation: spinner 0.8s linear infinite;
  z-index: 1;
}

@keyframes spinner {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Cross-browser Compatibility and Mobile Responsiveness */

/* Fix for Safari */
@supports (-webkit-appearance:none) {
  .gallery-grid {
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    gap: 20px;
  }
  
  .gallery-item {
    -webkit-box-flex: 0;
    -webkit-flex: 0 0 calc(33.333% - 14px);
    flex: 0 0 calc(33.333% - 14px);
  }
  
  @media (max-width: 768px) {
    .gallery-item {
      -webkit-flex: 0 0 calc(50% - 10px);
      flex: 0 0 calc(50% - 10px);
    }
  }
  
  @media (max-width: 575px) {
    .gallery-item {
      -webkit-flex: 0 0 100%;
      flex: 0 0 100%;
    }
  }
}

/* Mobile Responsiveness Adjustments */
@media (max-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    padding: 0 20px;
  }
  
  .project-modal .modal-project-content {
    width: 90%;
    padding: 15px;
  }
  
  .lightbox-img {
    max-width: 90%;
  }
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
  }
  
  .gallery-filter {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  
  .filter-btn {
    margin-bottom: 5px;
    width: auto;
  }
  
  .project-details {
    flex-direction: column;
  }
  
  .modal-project-img {
    margin: 0 auto 15px;
  }
  
  .lightbox-controls {
    position: relative;
    margin-top: 15px;
  }
}

@media (max-width: 575px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }
  
  .project-links {
    flex-direction: column;
    gap: 10px;
  }
  
  .live-demo-link, .source-code-link {
    width: 100%;
    text-align: center;
  }
  
  .form-status {
    font-size: 14px;
  }
}

/* High-DPI / Retina Display Adjustments */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .gallery-image img, .modal-project-img {
    image-rendering: -webkit-optimize-contrast;
  }
}

.portfolio-card {
  position: relative;
  z-index: 2; /* Ensure this is above the loading overlay */
}
