/* CSS Variables */
:root {
  --gold: #C9A227;
  --dark: #1A1A2E;
  --blue: #16213E;
  --teal: #0F3460;
  --light: #E8E8E8;
  --border: rgba(201, 162, 39, 0.3);
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Base */
body {
  font-family: 'Poppins', sans-serif;
  background: linear-gradient(135deg, var(--dark), var(--blue), var(--teal));
  min-height: 100vh;
  color: var(--light);
}

/* App Layout */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, var(--gold), #E8D48A);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.logo-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--gold), #E8D48A);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Navigation */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  padding: 0.75rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--light);
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.3s;
}

.nav-tab:hover {
  background: rgba(201, 162, 39, 0.1);
}

.nav-tab.active {
  background: linear-gradient(135deg, var(--gold), #B8941F);
  color: var(--dark);
  font-weight: 500;
}

/* Main Layout */
.main {
  flex: 1;
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  padding: 1.5rem;
  gap: 1.5rem;
}

/* Panel */
.panel {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.panel::-webkit-scrollbar {
  width: 6px;
}

.panel::-webkit-scrollbar-thumb {
  background: var(--gold);
  border-radius: 3px;
}

/* Sections */
.section {
  background: rgba(26, 26, 46, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid var(--border);
}

.section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Form Elements */
select,
.input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--dark);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: var(--light);
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
}

select:focus,
.input:focus {
  outline: none;
  border-color: var(--gold);
}

/* Dropdown options styling */
select option {
  background: var(--dark);
  color: var(--light);
  padding: 0.5rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 10px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #B8941F);
  color: var(--dark);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(201, 162, 39, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--light);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
}

/* Layout Helpers */
.row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.range-sel {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.range-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.range-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Ayah Preview */
.ayah-count {
  font-size: 0.8rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.preview-box {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
}

.arabic {
  font-family: 'Scheherazade New', 'Amiri', serif;
  font-size: 1.3rem;
  line-height: 2;
  text-align: right;
  direction: rtl;
  color: var(--gold);
  margin-bottom: 0.75rem;
}

.translation {
  font-size: 0.85rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  font-style: italic;
}

.tafsir-text {
  font-family: 'Scheherazade New', 'Amiri', serif;
  font-size: 1rem;
  line-height: 1.9;
  text-align: right;
  direction: rtl;
  color: rgba(255, 255, 255, 0.85);
}

.reference {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 0.5rem;
}

/* Background Grid */
.bg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.bg-opt {
  aspect-ratio: 1;
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
  border: 2px solid transparent;
  transition: all 0.3s;
}

.bg-opt:hover {
  transform: scale(1.05);
}

.bg-opt.selected {
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(201, 162, 39, 0.4);
}

.bg-opt.upload {
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
}

/* Tabs */
.bg-tabs,
.text-type-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.bg-tab {
  padding: 0.4rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.bg-tab:hover,
.bg-tab.active {
  background: rgba(201, 162, 39, 0.2);
  border-color: var(--gold);
  color: var(--gold);
}

.text-type-tab {
  flex: 1;
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  text-align: center;
}

.text-type-tab:hover,
.text-type-tab.active {
  background: rgba(201, 162, 39, 0.2);
  border-color: var(--gold);
  color: var(--gold);
}

.text-type-tab.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tafsir-note {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  padding: 0.5rem;
  background: rgba(201, 162, 39, 0.1);
  border-radius: 8px;
  margin-top: 0.5rem;
  text-align: center;
}

/* Custom Controls */
.custom-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.custom-label {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  min-width: 90px;
}

.custom-ctrl {
  flex: 1;
}

/* Slider */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slider {
  flex: 1;
  -webkit-appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--gold);
  border-radius: 50%;
  cursor: pointer;
}

.slider-val {
  font-size: 0.8rem;
  color: var(--gold);
  min-width: 35px;
  text-align: right;
}

/* Colors */
.colors {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-opt {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.color-opt:hover {
  transform: scale(1.1);
}

.color-opt.selected {
  border-color: white;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.color-opt.custom {
  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
  position: relative;
  overflow: hidden;
}

.color-opt.custom input {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Toggle */
.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.toggle-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
}

.toggle {
  width: 48px;
  height: 26px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  cursor: pointer;
  position: relative;
  transition: all 0.3s;
}

.toggle.on {
  background: var(--gold);
}

.toggle::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: all 0.3s;
}

.toggle.on::after {
  left: 25px;
}

/* Position Grid */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.pos-btn {
  aspect-ratio: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  padding: 6px;
}

/* Position dot at top for first button */
.pos-btn:nth-child(1) {
  align-items: flex-start;
}

/* Position dot at center for second button */
.pos-btn:nth-child(2) {
  align-items: center;
}

/* Position dot at bottom for third button */
.pos-btn:nth-child(3) {
  align-items: flex-end;
}

.pos-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.pos-btn.selected {
  background: rgba(201, 162, 39, 0.3);
  border-color: var(--gold);
}

.pos-dot {
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
}

/* Decorations */
.deco-opts {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.deco-btn {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.deco-btn:hover,
.deco-btn.selected {
  background: rgba(201, 162, 39, 0.2);
  border-color: var(--gold);
  color: var(--gold);
}

/* Preview Area */
.preview-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.preview-container {
  background: rgba(26, 26, 46, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 700px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.preview-title {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--light);
}

.format-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.format-tab {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.format-tab:hover,
.format-tab.active {
  background: rgba(201, 162, 39, 0.2);
  border-color: var(--gold);
  color: var(--gold);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 1.5rem;
  min-height: 400px;
}

.canvas {
  max-width: 100%;
  max-height: 500px;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
}

/* Actions */
.actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.action-btn {
  padding: 0.9rem 1.75rem;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  cursor: pointer;
}

.action-btn:hover {
  transform: translateY(-2px);
}

.action-btn.download {
  background: linear-gradient(135deg, var(--gold), #B8941F);
  color: var(--dark);
}

.action-btn.share {
  background: rgba(255, 255, 255, 0.1);
  color: var(--light);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.action-btn.save {
  background: rgba(201, 162, 39, 0.2);
  color: var(--gold);
  border: 1px solid var(--gold);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal {
  background: var(--dark);
  border-radius: 20px;
  padding: 2rem;
  max-width: 400px;
  width: 90%;
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gold);
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Social Buttons */
.social-btns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.social-btn {
  padding: 1rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.social-btn:hover {
  transform: translateY(-2px);
}

.social-btn.ig {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: white;
}

.social-btn.fb {
  background: #1877F2;
  color: white;
}

.social-btn.tw {
  background: #1DA1F2;
  color: white;
}

.social-btn.wa {
  background: #25D366;
  color: white;
}

/* Gallery */
.gallery {
  padding: 2rem;
}

.gallery-header {
  text-align: center;
  margin-bottom: 2rem;
}

.gallery-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.gallery-sub {
  color: rgba(255, 255, 255, 0.6);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

.gallery-item {
  background: rgba(26, 26, 46, 0.8);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: all 0.3s;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
}

.gallery-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.gallery-info {
  padding: 1rem;
}

.gallery-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
}

/* Empty State */
.empty {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.empty-text {
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 1rem;
}

/* Search */
.search-box {
  position: relative;
  margin-bottom: 0.75rem;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
}

/* Output Mode Tabs */
.output-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 4px;
}

.output-tab {
  flex: 1;
  padding: 0.75rem 1.5rem;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Poppins', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.output-tab:hover {
  color: var(--light);
  background: rgba(255, 255, 255, 0.05);
}

.output-tab.active {
  background: linear-gradient(135deg, var(--gold), #B8941F);
  color: var(--dark);
}

.output-tab-icon {
  font-size: 1.1rem;
}

/* Video Indicator Overlay */
.video-indicator-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  pointer-events: none;
}

.video-indicator-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  background: rgba(26, 26, 46, 0.95);
  border-radius: 16px;
  border: 1px solid var(--border);
}

.video-ayah-badge {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.video-ayah-badge .count {
  font-size: 1.5rem;
}

/* Pulse Animation Dots */
.pulse-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pulse-dots span {
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-radius: 50%;
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.pulse-dots span:nth-child(1) {
  animation-delay: 0s;
}

.pulse-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.pulse-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse-dot {
  0%, 60%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  30% {
    transform: scale(1.3);
    opacity: 1;
  }
}

/* Video Preview Player */
.video-preview-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.video-preview-player {
  max-width: 100%;
  max-height: 500px;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  background: #000;
}

/* Video Progress */
.video-progress-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  gap: 1rem;
}

.video-progress-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(201, 162, 39, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.video-progress-text {
  font-size: 1rem;
  color: var(--gold);
  font-weight: 500;
}

.video-progress-bar {
  width: 200px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.video-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Action Button Variants */
.action-btn.generate {
  background: linear-gradient(135deg, #4CAF50, #45a049);
  color: white;
}

.action-btn.new-video {
  background: rgba(255, 255, 255, 0.1);
  color: var(--light);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Video Options Panel */
.video-options {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.video-options-row {
  margin-bottom: 0.75rem;
}

.video-options-row:last-child {
  margin-bottom: 0;
}

/* Responsive */
@media (max-width: 1200px) {
  .main {
    flex-direction: column;
  }

  .panel {
    width: 100%;
    max-height: none;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .section {
    flex: 1;
    min-width: 300px;
  }
}

@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
  }

  .panel {
    flex-direction: column;
  }

  .section {
    min-width: 100%;
  }

  .preview-container {
    padding: 1rem;
  }

  .actions {
    flex-direction: column;
  }

  .action-btn {
    width: 100%;
    justify-content: center;
  }
}
