/* Gallery Styles - زیبا، واکنش‌گرا و سئوپسند */

:root {
  --gallery-primary: #2563eb;
  --gallery-primary-hover: #1d4ed8;
  --gallery-secondary: #64748b;
  --gallery-bg: #f8fafc;
  --gallery-card-bg: #ffffff;
  --gallery-border: #e2e8f0;
  --gallery-text: #1e293b;
  --gallery-text-light: #64748b;
  --gallery-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --gallery-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --gallery-radius: 0.75rem;
  --gallery-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-container {
  min-height: 60vh;
  padding: 2rem 1rem;
  background: var(--gallery-bg);
}

/* Header Section */
.gallery-header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem 0;
}

.gallery-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--gallery-text);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.gallery-header p {
  font-size: 1.125rem;
  color: var(--gallery-text-light);
  max-width: 600px;
  margin: 0 auto;
}

/* Filters Section */
.gallery-filters {
  background: var(--gallery-card-bg);
  border-radius: var(--gallery-radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--gallery-shadow);
}

.gallery-filters form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: end;
}

.gallery-filters .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.gallery-filters label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gallery-text);
  margin-bottom: 0.25rem;
}

.gallery-filters input[type="search"],
.gallery-filters select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gallery-border);
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: var(--gallery-transition);
  background: var(--gallery-card-bg);
  color: var(--gallery-text);
}

.gallery-filters input[type="search"]:focus,
.gallery-filters select:focus {
  outline: none;
  border-color: var(--gallery-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.gallery-filters button {
  padding: 0.75rem 2rem;
  background: var(--gallery-primary);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--gallery-transition);
  width: 100%;
  max-width: 200px;
  justify-self: start;
}

.gallery-filters button:hover {
  background: var(--gallery-primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--gallery-shadow-hover);
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

@media (max-width: 640px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* Media Card */
.gallery-card {
  background: var(--gallery-card-bg);
  border-radius: var(--gallery-radius);
  overflow: hidden;
  box-shadow: var(--gallery-shadow);
  transition: var(--gallery-transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--gallery-shadow-hover);
}

.gallery-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  width: 100%;
  cursor: pointer;
  font-family: inherit;
}

.gallery-card-image-wrapper {
  position: relative;
  width: 100%;
  padding-top: 75%; /* 4:3 Aspect Ratio */
  overflow: hidden;
  background: #f1f5f9;
}

.gallery-card-image-wrapper img,
.gallery-card-image-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--gallery-transition);
}

.gallery-card:hover .gallery-card-image-wrapper img,
.gallery-card:hover .gallery-card-image-wrapper video {
  transform: scale(1.05);
}

.gallery-card-image-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
  opacity: 0;
  transition: var(--gallery-transition);
}

.gallery-card:hover .gallery-card-image-wrapper::after {
  opacity: 1;
}

.gallery-card-type-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 1;
  backdrop-filter: blur(4px);
}

.gallery-card-content {
  padding: 1rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.gallery-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--gallery-text);
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 3rem;
}

.gallery-card-meta {
  margin-top: auto;
  padding-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--gallery-text-light);
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.gallery-meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.gallery-meta-item i {
  color: var(--gallery-primary);
  font-size: 0.75rem;
}

/* Empty State */
.gallery-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gallery-text-light);
}

.gallery-empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.gallery-empty h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--gallery-text);
}

.gallery-empty p {
  font-size: 1rem;
}

/* Pagination */
.gallery-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 3rem;
}

.gallery-pagination a,
.gallery-pagination span {
  padding: 0.5rem 1rem;
  border: 2px solid var(--gallery-border);
  border-radius: 0.5rem;
  text-decoration: none;
  color: var(--gallery-text);
  font-weight: 500;
  transition: var(--gallery-transition);
  min-width: 44px;
  text-align: center;
}

.gallery-pagination a:hover {
  background: var(--gallery-primary);
  color: white;
  border-color: var(--gallery-primary);
  transform: translateY(-2px);
}

.gallery-pagination .current {
  background: var(--gallery-primary);
  color: white;
  border-color: var(--gallery-primary);
}

.gallery-pagination .disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Detail Page */
.gallery-detail {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.gallery-detail-header {
  margin-bottom: 2rem;
}

.gallery-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gallery-primary);
  text-decoration: none;
  font-weight: 600;
  margin-bottom: 1rem;
  transition: var(--gallery-transition);
}

.gallery-detail-back:hover {
  color: var(--gallery-primary-hover);
  gap: 0.75rem;
}

.gallery-detail-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gallery-text);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.gallery-detail-media {
  background: var(--gallery-card-bg);
  border-radius: var(--gallery-radius);
  overflow: hidden;
  box-shadow: var(--gallery-shadow);
  margin-bottom: 2rem;
}

.gallery-detail-media img,
.gallery-detail-media video {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-detail-media video {
  max-height: 80vh;
  object-fit: contain;
}

.gallery-detail-description {
  background: var(--gallery-card-bg);
  border-radius: var(--gallery-radius);
  padding: 2rem;
  box-shadow: var(--gallery-shadow);
  line-height: 1.8;
  color: var(--gallery-text);
  font-size: 1.125rem;
}

.gallery-detail-description p {
  margin-bottom: 1rem;
}

.gallery-detail-description p:last-child {
  margin-bottom: 0;
}

/* Breadcrumb */
.gallery-breadcrumb {
  padding: 1rem 0;
  font-size: 0.875rem;
  color: var(--gallery-text-light);
  margin-bottom: 1rem;
}

.gallery-breadcrumb a {
  color: var(--gallery-primary);
  text-decoration: none;
  transition: var(--gallery-transition);
}

.gallery-breadcrumb a:hover {
  text-decoration: underline;
}

.gallery-breadcrumb span {
  margin: 0 0.5rem;
  color: var(--gallery-text-light);
}

/* Loading State */
.gallery-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  color: var(--gallery-text-light);
}

.gallery-loading::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 4px solid var(--gallery-border);
  border-top-color: var(--gallery-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .gallery-container {
    padding: 1rem 0.5rem;
  }

  .gallery-header h1 {
    font-size: 2rem;
  }

  .gallery-header p {
    font-size: 1rem;
  }

  .gallery-filters {
    padding: 1rem;
  }

  .gallery-filters form {
    grid-template-columns: 1fr;
  }

  .gallery-filters button {
    max-width: 100%;
    justify-self: stretch;
  }

  .gallery-detail-title {
    font-size: 1.5rem;
  }

  .gallery-detail-description {
    padding: 1.5rem;
    font-size: 1rem;
  }
}

/* Print Styles */
@media print {
  .gallery-filters,
  .gallery-pagination,
  .gallery-detail-back {
    display: none;
  }

  .gallery-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}

/* Accessibility */
.gallery-card:focus-visible,
.gallery-pagination a:focus-visible,
.gallery-detail-back:focus-visible {
  outline: 3px solid var(--gallery-primary);
  outline-offset: 2px;
}

/* Detail Page Meta & Tags */
.gallery-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--gallery-text-light);
}

.gallery-meta-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gallery-meta-item i {
  color: var(--gallery-primary);
}

.gallery-meta-item a {
  color: var(--gallery-primary);
  text-decoration: none;
  transition: var(--gallery-transition);
}

.gallery-meta-item a:hover {
  text-decoration: underline;
}

.gallery-detail-tags {
  background: var(--gallery-card-bg);
  border-radius: var(--gallery-radius);
  padding: 1.5rem;
  box-shadow: var(--gallery-shadow);
  margin-top: 2rem;
}

.gallery-detail-tags h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gallery-text);
  margin-bottom: 1rem;
}

.gallery-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gallery-tag {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--gallery-bg);
  color: var(--gallery-primary);
  border: 2px solid var(--gallery-border);
  border-radius: 2rem;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--gallery-transition);
}

.gallery-tag:hover {
  background: var(--gallery-primary);
  color: white;
  border-color: var(--gallery-primary);
  transform: translateY(-2px);
}

/* Gallery Modal/Lightbox */
.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.gallery-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(4px);
}

.gallery-modal-content {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: slideUp 0.3s ease;
}

.gallery-modal-media {
  position: relative;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: var(--gallery-radius);
  overflow: hidden;
}

.gallery-modal-media img,
.gallery-modal-media video {
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.gallery-modal-info {
  background: var(--gallery-card-bg);
  border-radius: var(--gallery-radius);
  padding: 1.5rem;
  max-width: 800px;
  width: 100%;
  box-shadow: var(--gallery-shadow);
}

.gallery-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.gallery-modal-info h3 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gallery-text);
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.gallery-modal-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.gallery-modal-view-count {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--gallery-text-light);
  font-size: 0.875rem;
}

.gallery-modal-view-count i {
  color: var(--gallery-primary);
}

.gallery-modal-view-count-number {
  font-weight: 600;
}

.gallery-modal-info p {
  font-size: 1rem;
  color: var(--gallery-text-light);
  line-height: 1.6;
  margin: 0 0 1rem 0;
  text-align: right;
}

.gallery-modal-share {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gallery-border);
  flex-wrap: wrap;
}

.gallery-share-btn {
  background: var(--gallery-primary);
  color: #fff;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--gallery-shadow);
  text-align: center;
  transition: background 0.3s ease;
  border: none;
  text-decoration: none;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0;
  flex-shrink: 0;
  line-height: 1;
  position: relative;
}

.gallery-share-btn i {
  display: block;
  line-height: 1;
  margin: 0;
  padding: 0;
  font-style: normal;
  font-variant: normal;
  text-rendering: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: auto;
  height: auto;
}

.gallery-share-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--gallery-shadow-hover);
}

.gallery-share-telegram {
  background: #0088cc;
}

.gallery-share-telegram:hover {
  background: #006ba3;
}

.gallery-share-whatsapp {
  background: #25d366;
}

.gallery-share-whatsapp:hover {
  background: #1da851;
}



.gallery-modal-close,
.gallery-modal-prev,
.gallery-modal-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--gallery-transition);
  z-index: 2;
  color: var(--gallery-text);
  font-size: 1.25rem;
  box-shadow: var(--gallery-shadow);
}

.gallery-modal-close:hover,
.gallery-modal-prev:hover,
.gallery-modal-next:hover {
  background: white;
  transform: scale(1.1);
  box-shadow: var(--gallery-shadow-hover);
}

.gallery-modal-close {
  top: 1rem;
  left: 1rem;
}

.gallery-modal-prev {
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
}

.gallery-modal-next {
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .gallery-modal-content {
    max-width: 100vw;
    max-height: 100vh;
    padding: 1rem;
  }

  .gallery-modal-media {
    max-height: 70vh;
  }

  .gallery-modal-media img,
  .gallery-modal-media video {
    max-height: 70vh;
  }

  .gallery-modal-close,
  .gallery-modal-prev,
  .gallery-modal-next {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .gallery-modal-close {
    top: 0.5rem;
    left: 0.5rem;
  }

  .gallery-modal-prev {
    right: 0.5rem;
  }

  .gallery-modal-next {
    left: 0.5rem;
  }

  .gallery-modal-info {
    padding: 1rem;
  }

  .gallery-modal-info h3 {
    font-size: 1.25rem;
  }

  .gallery-modal-share {
    gap: 0.75rem;
  }

  .gallery-share-btn {
    width: 44px;
    height: 44px;
    font-size: 1.125rem;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  :root {
    --gallery-bg: #0f172a;
    --gallery-card-bg: #1e293b;
    --gallery-border: #334155;
    --gallery-text: #f1f5f9;
    --gallery-text-light: #94a3b8;
  }

  .gallery-modal-info {
    background: var(--gallery-card-bg);
  }

  .gallery-modal-close,
  .gallery-modal-prev,
  .gallery-modal-next {
    background: rgba(30, 41, 59, 0.9);
    color: var(--gallery-text);
  }

  .gallery-modal-close:hover,
  .gallery-modal-prev:hover,
  .gallery-modal-next:hover {
    background: var(--gallery-card-bg);
  }
}

