/* Global Styles */
@font-face {
  font-family: "IRANSans";
  src: url("https://armogroup.storage.iran.liara.space/fonts/IranSans/IRANSansWeb%28FaNum%29_Medium.woff")
    format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* {
  font-family: "IRANSans", sans-serif;
}

body {
  margin: 0;
  background-color: black;
  font-family: Arial, sans-serif;
  direction: rtl;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.app-container {
  width: 100%;
  height: 90vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.viewer-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1080px;
  max-height: 1037px;
  margin: auto;
  overflow: hidden;
  border-radius: 48px;
  background: black;
}

@media (max-width: 768px) {
  .app-container {
    padding: 0;
  }

  .viewer-container {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
}

/* Canvas Styles */
#WebARRocksFaceCanvas,
#threeCanvas {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  transform: rotateY(180deg);
  object-fit: cover;
}

#model-viewer {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

#model-viewer canvas {
  width: 100% !important;
  height: 100% !important;
  cursor: grab;
}

#model-viewer canvas:active {
  cursor: grabbing;
}

.hidden {
  display: none !important;
}

/* Loading Container */
#loading-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: black;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Loading Animation */
.loading-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #fff;
  animation: bounce 0.5s ease-in-out infinite;
}

.dot:nth-child(2) {
  animation-delay: 0.1s;
}

.dot:nth-child(3) {
  animation-delay: 0.2s;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Control Buttons Container */
#controls {
  position: absolute;
  z-index: 2;
  right: max(20px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Glass Button Style */
.control-button {
  width: 56px;
  height: 56px;
  border-radius: 32px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.control-button img {
  width: 32px;
  height: 32px;
  filter: brightness(0) invert(1);
  transition: filter 0.3s ease;
}

.control-button.active {
  background: #ffffff;
}

.control-button.active img {
  filter: brightness(0);
}

.control-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Capture Button */
.capture-button {
  position: fixed; /* تغییر از absolute به fixed */
  bottom: max(30px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 1000; /* افزایش z-index */
  display: flex;
  align-items: center;
  justify-content: center;
}

.capture-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none; /* جلوگیری از مشکلات کلیک */
}

/* Error Container */
#error-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 1001;
  display: none;
  backdrop-filter: blur(10px);
}

/* Info Button */
.info-button {
  position: fixed; /* تغییر از absolute به fixed */
  bottom: max(45px, env(safe-area-inset-bottom));
  left: max(45px, env(safe-area-inset-left));
  width: 40px;
  height: 40px;
  border-radius: 20px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 1000; /* افزایش z-index */
  font-size: 14px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
}

.info-button img {
  width: 24px; /* اندازه مشخص برای آیکون */
  height: 24px;
  pointer-events: none; /* جلوگیری از مشکلات کلیک */
}

.info-button.active {
  width: 140px;
  background: white;
  color: black;
  justify-content: center;
}

.info-button.active img {
  opacity: 0;
}

/* Modal Styles */
.photo-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  position: relative;
  max-width: 90%;
  max-height: 90vh;
  background: white;
  border-radius: 24px;
  padding: 40px 20px;
}

.modal-content img {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  border-radius: 24px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.close-button {
  position: absolute;
  top: 10px;
  left: 10px;
  background: white;
  border: none;
  color: black;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Privacy Modal */
.privacy-content {
  background: white;
  padding: 24px;
  border-radius: 24px;
  max-width: 500px;
  width: 90%;
}

.privacy-text {
  text-align: right;
  color: black;
}

.privacy-text h3 {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 16px;
}

.privacy-text p {
  margin-bottom: 12px;
  line-height: 1.6;
}

/* Mobile Specific Adjustments */
@media (max-width: 768px) {
  #controls {
    right: max(20px, env(safe-area-inset-right) + 10px);
    gap: 16px;
  }

  .control-button {
    width: 48px;
    height: 48px;
    padding: 10px;
  }

  .control-button img {
    width: 28px;
    height: 28px;
  }

  .modal-content {
    width: 95%;
    max-height: 80vh;
    margin: 20px;
    padding: 30px 15px;
  }

  .modal-content img {
    max-height: calc(80vh - 60px);
  }

  .close-button {
    top: 8px;
    left: 8px;
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
}

/* تنظیمات موبایل */
@media (max-width: 768px) {
  .capture-button {
    bottom: max(
      40px,
      env(safe-area-inset-bottom) + 20px
    ); /* افزایش فاصله از پایین */
  }

  .info-button {
    bottom: max(40px, env(safe-area-inset-bottom) + 20px);
    left: max(16px, env(safe-area-inset-left));
  }
}

/* تنظیمات مخصوص آیفون */
@supports (-webkit-touch-callout: none) {
  .capture-button {
    bottom: max(
      50px,
      env(safe-area-inset-bottom) + 30px
    ); /* فاصله بیشتر برای آیفون */
  }

  .info-button {
    bottom: max(50px, env(safe-area-inset-bottom) + 30px);
  }
  #controls {
    right: max(20px, env(safe-area-inset-right) + 10px);
  }

  .modal-content {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
