/**
 * PMERIT Voice Preview Modal Styles
 * Professional, accessible, mobile-responsive design
 */

/* ========================================
   MODAL OVERLAY & CONTAINER
   ======================================== */

.voice-preview-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ========================================
   MODAL CONTENT
   ======================================== */

.modal-content {
  position: relative;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  margin: 5vh auto;
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ========================================
   MODAL HEADER
   ======================================== */

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 28px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-bottom: none;
}

.modal-header h3 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  font-size: 32px;
  color: white;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
  line-height: 1;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.close-btn:active {
  transform: scale(0.95);
}

/* ========================================
   MODAL BODY
   ======================================== */

.modal-body {
  padding: 28px;
  max-height: calc(85vh - 200px);
  overflow-y: auto;
  overflow-x: hidden;
}

/* Custom scrollbar */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f3f4f6;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.modal-intro {
  margin: 0 0 24px 0;
  font-size: 15px;
  color: #6b7280;
  line-height: 1.6;
}

/* ========================================
   VOICE LIST
   ======================================== */

.voice-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ========================================
   VOICE ITEM
   ======================================== */

.voice-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: white;
  transition: all 0.2s;
  cursor: pointer;
  position: relative;
}

.voice-item:hover {
  border-color: #3b82f6;
  background: #f9fafb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.voice-item.selected {
  border-color: #3b82f6;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.voice-item.selected::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: #3b82f6;
  border-radius: 12px 0 0 12px;
}

/* ========================================
   VOICE ICON
   ======================================== */

.voice-icon {
  font-size: 32px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  border-radius: 10px;
  flex-shrink: 0;
}

.voice-item.selected .voice-icon {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

/* ========================================
   VOICE INFO
   ======================================== */

.voice-info {
  flex: 1;
  min-width: 0;
}

.voice-name {
  margin: 0 0 4px 0;
  font-size: 17px;
  font-weight: 600;
  color: #1f2937;
  line-height: 1.2;
}

.voice-description {
  margin: 0;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.4;
}

.voice-item.selected .voice-name {
  color: #1e40af;
}

/* ========================================
   VOICE ACTIONS
   ======================================== */

.voice-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.preview-btn,
.select-btn {
  padding: 10px 18px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  color: #374151;
  white-space: nowrap;
  line-height: 1;
}

.preview-btn:hover,
.select-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-btn:active,
.select-btn:active {
  transform: translateY(0);
}

.preview-btn {
  background: #f3f4f6;
  border-color: #d1d5db;
}

.preview-btn:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.preview-btn.playing {
  background: #fef3c7;
  border-color: #fbbf24;
  color: #92400e;
}

.select-btn {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.select-btn:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.select-btn.selected {
  background: #10b981;
  border-color: #10b981;
  pointer-events: none;
}

/* ========================================
   MODAL FOOTER
   ======================================== */

.modal-footer {
  padding: 20px 28px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.quota-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px 0;
  font-size: 15px;
  color: #374151;
  font-weight: 500;
}

.quota-icon {
  font-size: 18px;
}

.quota-value {
  font-weight: 600;
  color: #3b82f6;
}

.quota-note {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.4;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.voice-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 24px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  font-size: 15px;
  font-weight: 500;
  z-index: 10001;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.voice-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.voice-toast-success {
  color: #065f46;
  border-left: 4px solid #10b981;
}

.voice-toast-error {
  color: #991b1b;
  border-left: 4px solid #ef4444;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .modal-content {
    width: 95%;
    max-height: 90vh;
    margin: 5vh auto;
    border-radius: 12px;
  }

  .modal-header {
    padding: 20px 20px;
  }

  .modal-header h3 {
    font-size: 20px;
  }

  .close-btn {
    width: 36px;
    height: 36px;
    font-size: 28px;
  }

  .modal-body {
    padding: 20px;
    max-height: calc(90vh - 180px);
  }

  .modal-intro {
    font-size: 14px;
  }

  .voice-list {
    gap: 12px;
  }

  .voice-item {
    flex-wrap: wrap;
    padding: 16px;
  }

  .voice-icon {
    width: 44px;
    height: 44px;
    font-size: 26px;
  }

  .voice-actions {
    width: 100%;
    margin-top: 12px;
    justify-content: flex-end;
  }

  .preview-btn,
  .select-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .modal-footer {
    padding: 16px 20px;
  }

  .quota-info {
    font-size: 14px;
  }

  .voice-toast {
    width: 90%;
    text-align: center;
  }
}

/* ========================================
   PREMIUM VOICE STYLING
   ======================================== */

/* Premium voice item */
.voice-item.voice-premium {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, rgba(245, 158, 11, 0.1) 100%);
  border-color: rgba(245, 158, 11, 0.3);
}

.voice-item.voice-premium:hover {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.15) 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

.voice-item.voice-premium.selected {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0.2) 100%);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.25);
}

.voice-item.voice-premium.selected::before {
  background: linear-gradient(180deg, #f59e0b, #d97706);
}

.voice-item.voice-premium .voice-icon {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.voice-item.voice-premium.selected .voice-icon {
  background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
}

/* Premium badge */
.premium-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 8px;
  letter-spacing: 0.05em;
  vertical-align: middle;
  box-shadow: 0 1px 3px rgba(245, 158, 11, 0.3);
}

/* Premium tier note */
.voice-tier-note {
  margin: 4px 0 0 0;
  font-size: 11px;
  color: #b45309;
  font-weight: 500;
  opacity: 0.9;
}

/* Premium select button */
.voice-item.voice-premium .select-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border-color: #f59e0b;
}

.voice-item.voice-premium .select-btn:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #d97706;
}

.voice-item.voice-premium .select-btn.selected {
  background: #10b981;
  border-color: #10b981;
}

/* ========================================
   FREE VOICE STYLING
   ======================================== */

/* Free badge */
.free-badge {
  display: inline-block;
  background: #22c55e;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 8px;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* ========================================
   LOCKED VOICE STYLING
   ======================================== */

.voice-item.voice-locked {
  opacity: 0.75;
  cursor: pointer;
}

.voice-item.voice-locked:hover {
  border-color: #f59e0b;
  opacity: 0.9;
}

.voice-item.voice-locked .voice-icon {
  filter: grayscale(30%);
}

/* Upgrade button */
.upgrade-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.upgrade-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  background: linear-gradient(135deg, #d97706, #b45309);
}

.upgrade-btn:active {
  transform: translateY(0);
}

/* ========================================
   SECTION HEADERS
   ======================================== */

.voice-section-header {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin: 20px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.voice-section-header:first-of-type {
  margin-top: 0;
}

.voice-section-header.voice-section-premium {
  color: #b45309;
  border-bottom-color: rgba(245, 158, 11, 0.3);
}

/* ========================================
   UPGRADE MODAL
   ======================================== */

.upgrade-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10002;
  animation: fadeIn 0.2s ease-out;
}

.upgrade-modal-content {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease-out;
}

.upgrade-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #f3f4f6;
  border: none;
  font-size: 24px;
  color: #6b7280;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
  line-height: 1;
}

.upgrade-close-btn:hover {
  background: #e5e7eb;
  color: #374151;
}

.upgrade-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.upgrade-modal-content h3 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
}

.upgrade-modal-content p {
  margin: 0 0 20px 0;
  font-size: 15px;
  color: #6b7280;
  line-height: 1.5;
}

.upgrade-features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  text-align: left;
}

.upgrade-features li {
  padding: 8px 0;
  font-size: 14px;
  color: #374151;
  border-bottom: 1px solid #f3f4f6;
}

.upgrade-features li:last-child {
  border-bottom: none;
}

.upgrade-cta-btn {
  display: inline-block;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  text-decoration: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.2s;
  margin-bottom: 12px;
}

.upgrade-cta-btn:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

.upgrade-later-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  transition: color 0.2s;
}

.upgrade-later-btn:hover {
  color: #374151;
}

/* ========================================
   MOBILE RESPONSIVE - ADDITIONAL
   ======================================== */

@media (max-width: 768px) {
  .voice-section-header {
    font-size: 11px;
    margin: 16px 0 10px 0;
  }

  .upgrade-btn {
    padding: 8px 14px;
    font-size: 13px;
  }

  .upgrade-modal-content {
    padding: 24px;
  }

  .upgrade-modal-content h3 {
    font-size: 20px;
  }
}

/* ========================================
   DARK MODE OVERRIDES
   ======================================== */

/* Modal container */
[data-theme="dark"] .voice-preview-modal .modal-content {
  background: var(--bg-elevated, #252525);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Modal body */
[data-theme="dark"] .voice-preview-modal .modal-body {
  background: var(--bg-elevated, #252525);
}

/* Scrollbar in dark mode */
[data-theme="dark"] .voice-preview-modal .modal-body::-webkit-scrollbar-track {
  background: var(--bg-secondary, #1E1E1E);
}

[data-theme="dark"] .voice-preview-modal .modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color-medium, #404040);
}

[data-theme="dark"] .voice-preview-modal .modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted, #8A8A8A);
}

/* Modal intro text */
[data-theme="dark"] .voice-preview-modal .modal-intro {
  color: var(--text-secondary, #B0B0B0);
}

/* Modal header - subtle dark gradient instead of bright blue */
[data-theme="dark"] .voice-preview-modal .modal-header {
  background: linear-gradient(135deg, #2a3a4a 0%, #1e2a3a 100%);
  border-bottom: 1px solid var(--border-color, #333333);
}

/* Voice items */
[data-theme="dark"] .voice-item {
  background: var(--bg-secondary, #1E1E1E);
  border-color: var(--border-color, #333333);
}

[data-theme="dark"] .voice-item:hover {
  background: var(--bg-elevated, #252525);
  border-color: var(--interactive-primary, #598bca);
  box-shadow: 0 4px 12px rgba(89, 139, 202, 0.2);
}

[data-theme="dark"] .voice-item.selected {
  background: rgba(89, 139, 202, 0.15);
  border-color: var(--interactive-primary, #598bca);
  box-shadow: 0 4px 12px rgba(89, 139, 202, 0.25);
}

[data-theme="dark"] .voice-item.selected::before {
  background: var(--interactive-primary, #598bca);
}

/* Voice icon */
[data-theme="dark"] .voice-icon {
  background: linear-gradient(135deg, var(--bg-secondary, #1E1E1E) 0%, var(--border-color, #333333) 100%);
}

[data-theme="dark"] .voice-item.selected .voice-icon {
  background: linear-gradient(135deg, rgba(89, 139, 202, 0.2) 0%, rgba(89, 139, 202, 0.3) 100%);
}

/* Voice name and description */
[data-theme="dark"] .voice-name {
  color: var(--text-primary, #E9E9E9);
}

[data-theme="dark"] .voice-description {
  color: var(--text-secondary, #B0B0B0);
}

[data-theme="dark"] .voice-item.selected .voice-name {
  color: var(--interactive-primary, #598bca);
}

/* Action buttons */
[data-theme="dark"] .preview-btn {
  background: var(--bg-secondary, #1E1E1E);
  border-color: var(--border-color, #333333);
  color: var(--text-primary, #E9E9E9);
}

[data-theme="dark"] .preview-btn:hover {
  background: var(--border-color, #333333);
  border-color: var(--border-color-medium, #404040);
}

[data-theme="dark"] .preview-btn.playing {
  background: rgba(251, 191, 36, 0.15);
  border-color: #fbbf24;
  color: #fbbf24;
}

[data-theme="dark"] .select-btn {
  background: var(--interactive-primary, #598bca);
  border-color: var(--interactive-primary, #598bca);
  color: white;
}

[data-theme="dark"] .select-btn:hover {
  background: var(--interactive-primary-hover, #6a9bd8);
  border-color: var(--interactive-primary-hover, #6a9bd8);
}

/* Modal footer */
[data-theme="dark"] .voice-preview-modal .modal-footer {
  background: var(--bg-secondary, #1E1E1E);
  border-color: var(--border-color, #333333);
}

[data-theme="dark"] .quota-info {
  color: var(--text-primary, #E9E9E9);
}

[data-theme="dark"] .quota-value {
  color: var(--interactive-primary, #598bca);
}

[data-theme="dark"] .quota-note {
  color: var(--text-secondary, #B0B0B0);
}

/* Toast notifications */
[data-theme="dark"] .voice-toast {
  background: var(--bg-elevated, #252525);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .voice-toast-success {
  color: var(--color-success, #4CAF7A);
}

[data-theme="dark"] .voice-toast-error {
  color: var(--color-error, #FF5252);
}

/* Section headers */
[data-theme="dark"] .voice-section-header {
  color: var(--text-muted, #8A8A8A);
  border-color: var(--border-color-light, #2A2A2A);
}

/* Premium voice styling in dark mode */
[data-theme="dark"] .voice-item.voice-premium {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.12) 100%);
  border-color: rgba(245, 158, 11, 0.4);
}

[data-theme="dark"] .voice-item.voice-premium:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(245, 158, 11, 0.18) 100%);
  border-color: #f59e0b;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .voice-item.voice-premium.selected {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.22) 100%);
  border-color: #f59e0b;
}

[data-theme="dark"] .voice-item.voice-premium .voice-icon {
  background: linear-gradient(135deg, rgba(254, 243, 199, 0.15) 0%, rgba(253, 230, 138, 0.2) 100%);
}

[data-theme="dark"] .voice-item.voice-premium.selected .voice-icon {
  background: linear-gradient(135deg, rgba(253, 230, 138, 0.2) 0%, rgba(252, 211, 77, 0.25) 100%);
}

[data-theme="dark"] .voice-item.voice-premium .voice-name {
  color: #fbbf24;
}

[data-theme="dark"] .voice-item.voice-premium.selected .voice-name {
  color: #fcd34d;
}

/* Premium badge */
[data-theme="dark"] .premium-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

/* Upgrade button */
[data-theme="dark"] .upgrade-btn {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.25));
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

[data-theme="dark"] .upgrade-btn:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(217, 119, 6, 0.35));
  border-color: #f59e0b;
}

/* Upgrade modal */
[data-theme="dark"] .upgrade-modal-content {
  background: var(--bg-elevated, #252525);
}

[data-theme="dark"] .upgrade-modal-content h3 {
  color: var(--text-primary, #E9E9E9);
}

[data-theme="dark"] .upgrade-modal-content p {
  color: var(--text-secondary, #B0B0B0);
}

[data-theme="dark"] .upgrade-features li {
  color: var(--text-primary, #E9E9E9);
  border-color: var(--border-color-light, #2A2A2A);
}

[data-theme="dark"] .upgrade-later-btn {
  color: var(--text-secondary, #B0B0B0);
}

[data-theme="dark"] .upgrade-later-btn:hover {
  color: var(--text-primary, #E9E9E9);
}