/* Importing Persian fonts */
@import url('https://cdn.fontcdn.ir/Font/Persian/Vazir/Vazir.css');
@import url('https://cdn.fontcdn.ir/Font/Persian/IRANSans/IRANSans.css');

/* Reset default styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Base styles */
body {
  font-family: 'Vazir', 'IRANSans', Arial, sans-serif;
  background: #f4f7fc;
  color: #1e293b;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  direction: rtl;
  text-align: right;
  line-height: 1.8;
  overflow-x: hidden;
}

/* Header */
.header {
  background: #1e3a8a;
  padding: 12px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
}

.logo {
  width: clamp(50px, 6vw, 60px);
  height: clamp(50px, 6vw, 60px);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #e2e8f0;
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

.header h1 {
  font-family: 'IRANSans', sans-serif;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  color: #ffffff;
  text-align: center;
  margin: 0 10px;
}

.nav {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-link {
  color: #d1d5db;
  text-decoration: none;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.nav-link:hover {
  background: #60a5fa;
  color: #ffffff;
  transform: translateY(-2px);
}

.nav-link.active {
  background: #1d4ed8;
  color: #ffffff;
}

/* Main container */
.container {
  background: #ffffff;
  padding: clamp(20px, 4vw, 30px);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  width: 90%;
  max-width: 1200px;
  margin: clamp(80px, 12vw, 100px) auto 30px;
}

/* Headings */
h1 {
  font-family: 'IRANSans', sans-serif;
  font-size: clamp(1.8rem, 5vw, 2.2rem);
  color: #0b8a26;
  margin-bottom: 20px;
  text-align: center;
}

h2 {
  font-size: clamp(1.4rem, 3.5vw, 1.8rem);
  color: #ff0000;
  margin-bottom: 15px;
  text-align: center;
}

h3 {
  font-size: clamp(1.4rem, 3.5vw, 1.8rem);
  color: #1f7d61;
  margin-bottom: 15px;
  text-align: center;
}

.detail-title {
  font-size: clamp(1.6rem, 4vw, 2rem);
  color: #ff0000;
  margin-bottom: 20px;
  text-align: center;
  font-weight: 700;
}

/* Search input */
.search-input {
  width: 100%;
  max-width: 450px;
  padding: 12px 15px;
  margin-bottom: 15px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  font-family: 'Vazir', sans-serif;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  background: #f9fafb;
}

.search-input:focus {
  border-color: #1e3a8a;
  box-shadow: 0 0 8px rgba(30, 58, 138, 0.3);
}

/* Main buttons */
.main-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  padding: 15px;
}

.button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 15px;
  background: #1e3a8a;
  border-radius: 10px;
  text-decoration: none;
  color: #ffffff;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 500;
  transition: background-color 0.3s ease, transform 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.button:hover {
  background: #3b82f6;
  transform: translateY(-2px);
}

.button img {
  width: clamp(40px, 8vw, 50px);
  height: clamp(40px, 8vw, 50px);
  border-radius: 50%;
  object-fit: cover;
  margin-left: 10px;
  border: 2px solid #e2e8f0;
}

.button span {
  flex-grow: 1;
  text-align: right;
}

/* List container */
.list-container {
  background: #f9fafb;
  padding: clamp(15px, 4vw, 20px);
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
  width: 100%;
  margin: 15px auto;
}

/* List item */
.list-item {
  display: flex;
  align-items: center;
  background: #ffffff;
  padding: clamp(10px, 2.5vw, 15px);
  margin-bottom: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 500;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.list-item:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
}

.list-item-image {
  width: clamp(40px, 8vw, 50px);
  height: clamp(40px, 8vw, 50px);
  border-radius: 50%;
  object-fit: cover;
  margin-left: 15px;
  border: 2px solid #e2e8f0;
}

/* Detail container */
.detail-container {
  background: #ffffff;
  padding: clamp(20px, 4vw, 30px);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  width: 100%;
  margin: 15px auto;
}

/* Detail image */
.detail-image-container {
  text-align: center;
  margin-bottom: 25px;
}

.detail-image {
  max-width: 100%;
  max-height: clamp(150px, 35vw, 300px);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.detail-image:hover {
  transform: scale(1.02);
}

/* Qari container */
.qari-container {
  background: #f9fafb;
  padding: clamp(15px, 4vw, 20px);
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
  width: 100%;
  margin: 15px auto;
  max-height: 400px;
  overflow-y: auto;
}

.qari-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  padding: clamp(10px, 2.5vw, 15px);
  margin-bottom: 10px;
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.qari-name {
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 500;
  color: #1e293b;
  flex: 1;
  margin-right: 15px;
}

.qari-item .audio-player {
  width: 60%;
  border-radius: 8px;
  background: #f9fafb;
  padding: 8px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* Descriptions */
.imam-description, .shahid-description {
  font-family: 'Vazir', sans-serif;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  line-height: 2;
  margin: 20px 0;
  padding: 20px;
  border-radius: 12px;
  background: #f9fafb;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.imam-description *, .shahid-description * {
  max-width: 100%;
  overflow-wrap: break-word;
}

.shahid-description p {
  margin-bottom: 1.2rem;
}

.shahid-description strong {
  font-weight: 700;
}

.shahid-description u {
  text-decoration: underline;
}

.shahid-description .ql-align-center {
  text-align: center !important;
}

.shahid-description .ql-align-right {
  text-align: right !important;
}

.shahid-description .ql-align-left {
  text-align: left !important;
}

.shahid-description .ql-direction-rtl {
  direction: rtl;
}

.shahid-description .ql-direction-ltr {
  direction: ltr;
}

/* 404 Not Found styles */
.not-found-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(20px, 5vw, 30px);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  min-height: calc(100vh - clamp(80px, 12vw, 100px) - 60px);
}

.not-found-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.not-found-text {
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  color: #1e293b;
  margin-bottom: 20px;
}

.not-found-image {
  max-width: 100%;
  max-height: clamp(100px, 20vw, 150px);
  border-radius: 10px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

/* Back button */
.back-button {
  display: inline-block;
  padding: clamp(10px, 2.5vw, 12px) clamp(20px, 4vw, 25px);
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 100%);
  color: #ffffff;
  text-decoration: none;
  border-radius: 8px;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  font-weight: 500;
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.back-button:hover {
  background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Loading spinner */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top: 3px solid #1e3a8a;
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
  margin: 15px auto;
}

.loading-text {
  text-align: center;
  color: #1e3a8a;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  margin-top: 8px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* PDF viewer */
.webview-container {
  width: 100%;
  height: clamp(350px, 70vw, 550px);
  margin: 15px 0;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
}

#pdfViewer {
  width: 100%;
  height: 100%;
  border: none;
}

/* Audio player */
.audio-player {
  width: 100%;
  margin-top: 15px;
  border-radius: 8px;
  background: #f9fafb;
  padding: 8px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

/* Footer */
.footer {
  background: #1e3a8a;
  padding: clamp(15px, 4vw, 20px);
  text-align: center;
  color: #ffffff;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
  margin-top: auto;
}

.footer a {
  color: #e2e8f0;
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer a:hover {
  color: #ffffff;
}

/* Responsive design */
@media (max-width: 1200px) {
  .container {
    max-width: 1000px;
  }
  .header-container {
    padding: 0 12px;
  }
}

@media (max-width: 992px) {
  .header-container {
    gap: 8px;
  }
  .nav {
    gap: 8px;
  }
  .nav-link {
    padding: 6px 12px;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
  }
  .container {
    margin-top: 90px;
    padding: 20px;
  }
  .webview-container {
    height: 500px;
  }
  .qari-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .qari-item .audio-player {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .header-container {
    gap: 6px;
  }
  .header h1 {
    font-size: clamp(1.3rem, 3.5vw, 1.6rem);
  }
  .logo {
    width: clamp(45px, 5vw, 55px);
    height: clamp(45px, 5vw, 55px);
  }
  .nav {
    gap: 6px;
  }
  .nav-link {
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    padding: 5px 10px;
  }
  h1 {
    font-size: clamp(1.6rem, 4vw, 2rem);
  }
  h2, .detail-title {
    font-size: clamp(1.3rem, 3vw, 1.6rem);
  }
  .container {
    margin-top: 80px;
    padding: 15px;
  }
  .list-item {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    padding: 12px;
  }
  .list-item-image {
    width: clamp(35px, 7vw, 50px);
    height: clamp(35px, 7vw, 50px);
  }
  .search-input {
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    padding: 8px 12px;
  }
  .detail-image {
    max-height: 250px;
  }
  .not-found-image {
    max-height: 120px;
  }
  .button {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    padding: 12px;
  }
  .button img {
    width: clamp(35px, 7vw, 45px);
    height: clamp(35px, 7vw, 45px);
  }
  .webview-container {
    height: 450px;
  }
}

@media (max-width: 576px) {
  .header-container {
    padding: 0 8px;
  }
  .header h1 {
    font-size: clamp(1.2rem, 3vw, 1.4rem);
  }
  .logo {
    width: clamp(40px, 4vw, 50px);
    height: clamp(40px, 4vw, 50px);
  }
  .nav {
    gap: 5px;
  }
  .nav-link {
    font-size: clamp(0.7rem, 1.8vw, 0.85rem);
    padding: 4px 8px;
  }
  h1 {
    font-size: clamp(1.4rem, 3.5vw, 1.8rem);
  }
  h2, .detail-title {
    font-size: clamp(1.2rem, 2.8vw, 1.4rem);
  }
  .container {
    padding: 10px;
    margin-top: 75px;
  }
  .list-item {
    font-size: clamp(0.85rem, 1.8vw, 1rem);
    padding: 10px;
  }
  .list-item-image {
    width: clamp(30px, 6vw, 40px);
    height: clamp(30px, 6vw, 40px);
  }
  .search-input {
    font-size: clamp(0.75rem, 1.8vw, 0.9rem);
    padding: 7px 10px;
  }
  .detail-image {
    max-height: 200px;
  }
  .not-found-image {
    max-height: 100px;
  }
  .button {
    font-size: clamp(0.85rem, 1.8vw, 1rem);
    padding: 10px;
  }
  .button img {
    width: clamp(30px, 6vw, 40px);
    height: clamp(30px, 6vw, 40px);
  }
  .webview-container {
    height: 400px;
  }
}
