/* Dashboard & Generator Styles */

/* App Navigation */
.app-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.user-plan {
  padding: 4px 10px;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.user-usage {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.user-menu {
  position: relative;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.user-avatar:hover {
  border-color: var(--accent-primary);
}

/* Hybrid Dropdown (Hover + Click Support) */
.user-menu {
  position: relative;
  padding-bottom: 20px; /* Safe zone below avatar */
  margin-bottom: -20px;
}

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 220px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px) scale(0.95);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 9999;
  padding: 8px 0;
}

/* Invisible Bridge to prevent closing */
.user-dropdown::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 20px;
  background: transparent;
}

/* Show on Hover OR Click (.show class) */
.user-menu:hover .user-dropdown,
.user-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Fix White Text on White Button */
.btn-white {
    background: white;
    color: #7c3aed !important; /* Force purple text - accent primary */
    font-weight: 600;
    border: none;
}
.btn-white:hover {
    background: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.25);
}

.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border-radius: var(--radius-sm);
  margin: 2px 6px;
}

.user-dropdown a:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(59, 130, 246, 0.1));
  color: var(--text-primary);
  transform: translateX(2px);
}

.user-dropdown hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 6px 12px;
  opacity: 0.5;
}

.app-nav .lang-wrapper {
  margin-right: var(--space-md);
}

/* App Main */
.app-main {
  padding-top: 100px;
  min-height: 100vh;
}

/* Dashboard Header - Premium Enhancement */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2xl);
  padding: var(--space-xl);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(59, 130, 246, 0.05) 100%);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-xl);
}

.header-content h1 {
  font-size: 2.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.header-content p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Stats Row - Premium Enhancement */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-xl) var(--space-lg);
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: rgba(139, 92, 246, 0.3);
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.stat-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-card .stat-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Actions Row */
.actions-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: var(--space-lg);
}

/* Email List */
.email-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.email-card {
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.email-card:hover {
  border-color: var(--accent-primary);
  transform: translateX(4px);
}

.email-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.email-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.email-prospect {
  font-weight: 600;
}

.email-date {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.delete-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.4; /* Visible by default for touch devices */
  transition: all var(--transition-fast);
}

.email-card:hover .delete-btn {
  opacity: 1; /* Bright on hover/active */
}

.delete-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.email-company {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
}

.email-preview {
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Loading State */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
  gap: var(--space-md);
  color: var(--text-muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-3xl);
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: var(--space-lg);
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  /* Removed backdrop-filter: blur() to prevent content from being blurred */
}

.modal-content {
  position: relative;
  z-index: 9999; /* Nuclear option to fix blur issue */
  width: 100%;
  max-width: 700px;
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.25rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--error);
  color: white;
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  max-height: calc(80vh - 80px);
}

/* Generator Layout */
.generator-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-xl);
  min-height: calc(100vh - 140px);
}

.generator-form {
  padding: var(--space-xl);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
}

.generator-form h1 {
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.form-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-xl);
}

.form-section {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
  border-bottom: none;
}

.form-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.input-group {
  margin-bottom: var(--space-md);
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--text-secondary);
}

.input {
  width: 100%;
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition-fast);
}

.input:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.input::placeholder {
  color: var(--text-muted);
}

textarea.input {
  resize: vertical;
  min-height: 60px;
}

.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.divider span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Goal Options */
.goal-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.goal-option {
  padding: var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.goal-option:hover {
  border-color: var(--border-light);
}

.goal-option.selected {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.1);
}

.goal-option input {
  display: none;
}

.goal-option span {
  font-size: 0.9rem;
}

/* Spacing fix for template dropdown and generate button */
.form-section:last-of-type .input-group:last-child {
  margin-bottom: var(--space-xl);
}

#generate-btn {
  margin-top: var(--space-2xl);
}

/* Generator Output */
.generator-output {
  padding: var(--space-xl);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.output-placeholder {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
}

.output-placeholder h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-sm);
}

.output-placeholder p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.output-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
  gap: var(--space-md);
}

.output-section {
  margin-bottom: var(--space-xl);
}

.output-section h3 {
  font-size: 1rem;
  margin-bottom: var(--space-md);
}

/* Subject Lines */
.subject-lines {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.subject-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.subject-line button {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.subject-line button:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Variant Tabs */
.variant-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.variant-tab {
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.variant-tab:hover {
  border-color: var(--border-light);
  color: var(--text-secondary);
}

.variant-tab.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
}

/* Email Output */
.email-output {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.email-content {
  padding: var(--space-lg);
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.7;
  min-height: 200px;
}

.copy-btn {
  width: 100%;
  border-radius: 0;
  border-top: 1px solid var(--border-color);
  border-left: none;
  border-right: none;
  border-bottom: none;
}

/* Delete Confirmation Modal */
.delete-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.delete-modal.active {
  opacity: 1;
  visibility: visible;
}

.delete-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.delete-modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  max-width: 400px;
  width: 90%;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.delete-modal.active .delete-modal-content {
  transform: scale(1);
}

.delete-modal-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.delete-modal-content h3 {
  font-size: 1.25rem;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.delete-modal-content p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-xl);
}

.delete-modal-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
}

.delete-modal-buttons .btn {
  min-width: 100px;
}

.btn-danger {
  background: #ef4444;
  color: white;
  border: none;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Generator Tips Sidebar */
.generator-tips {
  position: fixed;
  right: 40px;
  top: 140px;
  width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.generator-layout + .generator-tips {
  margin-left: var(--space-xl);
}

.tips-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-muted);
}

.tips-placeholder span {
  font-size: 2rem;
}

.tips-header h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-xs);
}

.tips-header p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-md);
}

.tips-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.tip-card {
  padding: var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
}

.tip-card h4 {
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
}

.tip-card p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

@media (max-width: 1200px) {
  .generator-layout {
    grid-template-columns: 1fr;
  }
  .generator-tips {
    position: static;
    width: 100%;
    margin-top: var(--space-xl);
  }
}

/* Responsive */
@media (max-width: 1024px) {
  .generator-layout {
    grid-template-columns: 1fr;
  }

  .generator-output {
    position: static;
    max-height: none;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }
}

/* === Ultra-Premium Subscription Modal (Vercel/Stripe Style) === */
#subscription-modal .modal-content.glass-panel {
  background: #000000 !important;
  border: 1px solid #333 !important;
  box-shadow: 0 0 100px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 255, 255, 0.05) !important;
  max-width: 480px;
  border-radius: 16px !important;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  position: relative;
  color: #fff;
}

/* Header Styling */
#subscription-modal .modal-header {
  border-bottom: 1px solid #222 !important;
  padding: 24px !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #050505;
}

#subscription-modal .modal-header h2 {
  font-size: 18px !important;
  font-weight: 600 !important;
  color: #ededed !important;
  margin: 0;
  letter-spacing: -0.02em;
}

#subscription-modal .modal-close {
  background: transparent;
  border: none;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

#subscription-modal .modal-close:hover {
  background: #222;
  color: #fff;
}

/* Body Styling */
.sub-card-container {
  padding: 0;
}

.sub-card {
  background: linear-gradient(180deg, #111 0%, #0a0a0a 100%) !important;
  border: 1px solid #333 !important;
  border-radius: 12px !important;
  padding: 24px !important;
  margin-bottom: 24px !important;
  position: relative;
  overflow: hidden;
}

/* Active Plan Glow */
.sub-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 200px;
  background: radial-gradient(
    circle at top right,
    rgba(120, 120, 120, 0.1),
    transparent 70%
  );
  pointer-events: none;
}

.sub-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sub-label-tiny {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #888;
  font-weight: 600;
}

.sub-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
  letter-spacing: 0.05em;
  background: #ededed;
  color: #000;
  border: 1px solid #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.gradient-text {
  background: #fff;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 28px !important;
  font-weight: 700 !important;
  margin: 0;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.sub-limits {
  font-size: 13px;
  color: #888;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* Details List */
.sub-details-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 8px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #222;
}

.detail-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail-label {
  color: #666;
}

.detail-value {
  color: #ddd;
  font-weight: 500;
}

/* Actions Section */
.sub-actions {
  margin-top: 24px;
}

#cancel-sub-btn {
  width: 100%;
  background: #111 !important; /* Dark background */
  color: #ff4d4d !important; /* Red text */
  border: 1px solid #332222 !important;
  padding: 14px !important;
  border-radius: 8px !important;
  font-weight: 500 !important;
  font-size: 14px !important;
  cursor: pointer !important;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#cancel-sub-btn:hover {
  background: #1a0505 !important;
  border-color: #441111 !important;
  color: #ff6666 !important;
}

#cancel-sub-btn .btn-icon {
  font-size: 16px;
  line-height: 1;
}

.text-muted.small {
  color: #555 !important;
  font-size: 12px !important;
  margin-top: 16px !important;
  text-align: center;
}

.link-gradient {
  color: #fff;
  text-decoration: underline;
  text-decoration-color: #444;
  text-underline-offset: 4px;
  transition: all 0.2s;
  font-weight: 500;
}

.link-gradient:hover {
  color: #fff;
  text-decoration-color: #fff;
}

/* ================================================
   FIX: Template Select Dropdown Styling - Remove white line
   ================================================ */
#template-select {
  background-color: var(--bg-tertiary) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  
  /* Remove native appearance completely */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  
  /* Add custom arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  
  /* Fix for Windows High Contrast / Default styles */
  color-scheme: dark;
}

/* Fix specific for Webkit/Blink browsers to allow background color overrides */
#template-select:-internal-autofill-selected {
  background-color: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

#template-select option {
  background-color: #141416 !important; /* var(--bg-tertiary) */
  color: #fafafa !important;             /* var(--text-primary) */
  padding: 12px;
}

/* ================================================
   FULL RESPONSIVE DESIGN - Mobile, Tablet, iPad
   ================================================ */

/* Large Tablets and Small Laptops (max-width: 1200px) */
@media (max-width: 1200px) {
  .container {
    padding: 0 var(--space-md);
  }
  
  .generator-tips {
    display: none; /* Hide sidebar on smaller screens, show after email generation */
  }
}

/* Tablets (max-width: 1024px) */
@media (max-width: 1024px) {
  .nav-container {
    height: 60px;
    padding: 0 var(--space-md);
  }
  
  .app-main {
    padding-top: 80px;
  }
  
  .dashboard-header {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }
  
  .header-content h1 {
    font-size: 1.5rem;
  }
  
  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
  }
  
  .stat-card {
    padding: var(--space-md);
    flex-direction: column;
    text-align: center;
    gap: var(--space-sm);
  }
  
  .stat-icon {
    font-size: 1.5rem;
  }
  
  .stat-card .stat-value {
    font-size: 1.25rem;
  }
  
  .generator-form {
    padding: var(--space-lg);
  }
  
  .generator-form h1 {
    font-size: 1.25rem;
  }
  
  .input-row {
    grid-template-columns: 1fr;
  }
  
  .goal-options {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small Tablets and Large Phones (max-width: 768px) */
@media (max-width: 768px) {
  :root {
    --space-lg: 1rem;
    --space-xl: 1.5rem;
    --space-2xl: 2rem;
  }
  
  .nav-container {
    padding: 0 var(--space-sm);
  }
  
  .nav-logo .logo-text {
    font-size: 1rem;
  }
  
  .nav-user {
    gap: var(--space-xs);
  }
  
  .user-plan {
    font-size: 0.65rem;
    padding: 3px 8px;
  }
  
  .user-usage {
    font-size: 0.75rem;
    display: none; /* Hide usage on very small screens */
  }
  
  .lang-toggle {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }
  
  .app-main {
    padding-top: 70px;
  }
  
  .stats-row {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    flex-direction: row;
    text-align: left;
    padding: var(--space-md);
  }
  
  .goal-options {
    grid-template-columns: 1fr;
  }
  
  .goal-option {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    text-align: left;
    padding: var(--space-md);
  }
  
  .goal-option .goal-icon {
    font-size: 1.5rem;
  }
  
  .goal-option .goal-info {
    display: flex;
    flex-direction: column;
  }
  
  .goal-option .goal-label {
    font-weight: 600;
  }
  
  .goal-option .goal-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
  }
  
  /* Generator Output */
  .generator-output {
    padding: var(--space-md);
  }
  
  .variant-tabs {
    flex-wrap: wrap;
  }
  
  .variant-tab {
    flex: 1;
    min-width: 80px;
    text-align: center;
  }
  
  /* Modal Responsive */
  .modal-content {
    max-width: 95%;
    margin: var(--space-md);
    max-height: 90vh;
  }
  
  .modal-header {
    padding: var(--space-md);
  }
  
  .modal-body {
    padding: var(--space-md);
  }
  
  /* Subscription Modal */
  #subscription-modal .modal-content.glass-panel {
    max-width: 95%;
    margin: var(--space-sm);
  }
  
  .sub-card {
    padding: var(--space-md) !important;
  }
  
  .gradient-text {
    font-size: 22px !important;
  }
  
  /* Email Cards */
  .email-card {
    padding: var(--space-md);
  }
  
  .email-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
  
  .email-card-actions {
    width: 100%;
    justify-content: space-between;
  }
  
  /* Buttons */
  .btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }
  
  /* Actions Row */
  .actions-row {
    justify-content: center;
  }
}

/* Mobile Phones (max-width: 480px) */
@media (max-width: 480px) {
  .nav-logo .logo-text {
    display: none;
  }
  
  .nav-logo .logo-icon {
    font-size: 1.75rem;
  }
  
  .lang-wrapper {
    display: none; /* Hide language selector on very small phones */
  }
  
  .user-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
  
  .user-dropdown {
    right: -10px;
    min-width: 160px;
  }
  
  .app-main {
    padding-top: 65px;
  }
  
  .container {
    padding: 0 var(--space-sm);
  }
  
  .dashboard-header {
    margin-bottom: var(--space-md);
  }
  
  .header-content h1 {
    font-size: 1.25rem;
  }
  
  .header-content p {
    font-size: 0.8rem;
  }
  
  .btn {
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
  }
  
  .generator-form {
    padding: var(--space-md);
    border-radius: var(--radius-lg);
  }
  
  .generator-form h1 {
    font-size: 1.1rem;
  }
  
  .form-subtitle {
    font-size: 0.8rem;
  }
  
  .form-section h3 {
    font-size: 0.9rem;
  }
  
  .input {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
  }
  
  .input-group label {
    font-size: 0.8rem;
  }
  
  .input-hint {
    font-size: 0.7rem;
  }
  
  /* Subject Lines */
  .subject-line {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
  
  .subject-line span {
    width: 100%;
    word-break: break-word;
  }
  
  .subject-line button {
    align-self: flex-end;
  }
  
  /* Email output */
  .email-content {
    font-size: 0.85rem;
    padding: var(--space-md);
    min-height: 150px;
  }
  
  /* Confirmation Modals */
  #cancel-confirm-modal .modal-content,
  #cancel-success-modal .modal-content {
    max-width: 95%;
    padding: var(--space-md);
  }
  
  #cancel-confirm-modal .modal-body,
  #cancel-success-modal .modal-body {
    padding: var(--space-md) !important;
  }
  
  #cancel-confirm-modal h2,
  #cancel-success-modal h2 {
    font-size: 1.1rem;
  }
  
  #cancel-confirm-modal p,
  #cancel-success-modal p {
    font-size: 0.85rem;
  }
  
  /* Stats page adjustments */
  .stat-card .stat-value {
    font-size: 1.1rem;
  }
  
  .stat-card .stat-label {
    font-size: 0.75rem;
  }
}

/* iPhone SE and very small devices (max-width: 375px) */
@media (max-width: 375px) {
  .nav-container {
    height: 55px;
  }
  
  .user-plan {
    display: none;
  }
  
  .generator-form {
    padding: var(--space-sm);
  }
  
  .form-section {
    padding-bottom: var(--space-md);
    margin-bottom: var(--space-md);
  }
  
  .goal-option {
    padding: var(--space-sm);
  }
  
  .btn-block {
    padding: 0.6rem;
    font-size: 0.8rem;
  }
  
  .variant-tab {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.75rem;
  }
}

/* Landscape Mode for Mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .app-main {
    padding-top: 60px;
  }
  
  .modal-content {
    max-height: 95vh;
    margin: var(--space-xs);
  }
  
  .generator-output {
    max-height: none;
  }
}

/* iPad Pro and Large Tablets (min-width: 1024px) and (max-width: 1366px) */
@media (min-width: 1024px) and (max-width: 1366px) {
  .generator-layout {
    grid-template-columns: 1.2fr 1fr;
    gap: var(--space-lg);
  }
  
  .generator-tips {
    width: 280px;
    right: 20px;
  }
}

/* Print Styles */
@media print {
  .nav, .app-nav, .generator-tips, .modal {
    display: none !important;
  }
  
  .app-main {
    padding-top: 0;
  }
  
  .generator-layout {
    grid-template-columns: 1fr;
  }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .input, .btn, select {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/* Dark mode preference - already dark, but ensure consistency */
@media (prefers-color-scheme: dark) {
  #template-select option {
    background-color: #1a1a1e;
  }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Touch devices - larger touch targets */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 44px;
  }
  
  .input {
    min-height: 44px;
  }
  
  .goal-option {
    min-height: 60px;
  }
  
  .variant-tab {
    min-height: 40px;
  }
  
  .user-avatar {
    min-width: 40px;
    min-height: 40px;
  }
}

/* Generator Header with Import Button */
.generator-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-xl);
  gap: var(--space-md);
}

.generator-header h1 {
  margin-bottom: var(--space-xs);
}

#import-csv-btn {
  white-space: nowrap;
  flex-shrink: 0;
}

/* CSV Import Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  padding: var(--space-lg);
}

.modal-overlay .modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay .modal-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 32px;
  height: 32px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-overlay .modal-close:hover {
  background: var(--error);
  color: white;
}

/* Upload Zone */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-2xl);
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-tertiary);
}

.upload-zone:hover {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.05);
}

.upload-zone.dragover {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.1);
}

/* CSV Preview */
.csv-preview {
  margin-top: var(--space-xl);
}

.csv-preview h4 {
  margin-bottom: var(--space-md);
}

.csv-table-wrap {
  overflow-x: auto;
  max-height: 200px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.csv-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.csv-table-wrap th,
.csv-table-wrap td {
  padding: var(--space-sm);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.csv-table-wrap th {
  background: var(--bg-tertiary);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.csv-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-md);
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   Based on Reddit User Feedback (OG_Romes)
   ============================================ */

@media (max-width: 768px) {
  /* App Main - Less top padding on mobile */
  .app-main {
    padding-top: 80px;
  }

  /* Generator Layout - Stack columns vertically */
  .generator-layout {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  /* Generator Form - Smaller padding */
  .generator-form {
    padding: var(--space-lg);
  }

  .generator-form h1 {
    font-size: 1.25rem;
  }

  /* Generator Header - Stack on mobile */
  .generator-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-md);
  }

  .generator-header .btn {
    width: 100%;
  }

  /* Input Row - Stack side-by-side inputs */
  .input-row {
    grid-template-columns: 1fr;
  }

  /* Goal Options - 1 column on mobile */
  .goal-options {
    grid-template-columns: 1fr;
  }

  /* Stats Row - Stack vertically */
  .stats-row {
    grid-template-columns: 1fr;
  }

  /* Generator Output - Not sticky on mobile */
  .generator-output {
    position: relative;
    top: auto;
    max-height: none;
  }

  /* Tips Sidebar - Hide on mobile */
  .generator-tips {
    display: none;
  }

  /* Modal - Full screen on mobile */
  .modal {
    padding: var(--space-sm);
  }

  .modal-content {
    max-width: 100%;
    width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-lg);
  }

  .modal-overlay .modal-content {
    max-width: 100%;
    width: 100%;
    padding: var(--space-lg);
  }

  .modal-body {
    padding: var(--space-md);
  }

  /* CSV Table - Horizontal scroll */
  .csv-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .csv-table-wrap table {
    min-width: 500px;
  }

  /* Upload Zone - Smaller on mobile */
  .upload-zone {
    padding: var(--space-lg);
  }

  /* Dashboard Header - Stack */
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  /* Delete Modal - Smaller padding */
  .delete-modal-content {
    padding: var(--space-lg);
    width: 95%;
  }

  .delete-modal-buttons {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .delete-modal-buttons .btn {
    width: 100%;
  }

  /* Nav User - Adjust for mobile */
  .nav-user {
    gap: var(--space-sm);
  }

  .user-usage {
    display: none;
  }

  .user-plan {
    font-size: 0.65rem;
    padding: 3px 8px;
  }

  /* Variant Tabs - Smaller */
  .variant-tabs {
    flex-wrap: wrap;
  }

  .variant-tab {
    flex: 1;
    min-width: 80px;
    text-align: center;
    padding: var(--space-sm);
    font-size: 0.8rem;
  }

  /* Email Output - Smaller font */
  .email-content {
    font-size: 0.85rem;
    padding: var(--space-md);
  }

  /* Subject Lines - Stack */
  .subject-line {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .subject-line button {
    align-self: flex-end;
  }

  /* Force delete button visibility on mobile (no hover) */
  .delete-btn {
    opacity: 1 !important;
    width: 32px; /* Bigger touch target */
    height: 32px;
    background: rgba(255, 255, 255, 0.05); /* Slight background to spot it */
  }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
  .container {
    padding: 0 var(--space-md);
  }

  .generator-form h1 {
    font-size: 1.1rem;
  }

  .form-subtitle {
    font-size: 0.8rem;
  }

  .nav-container {
    padding: 0 var(--space-md);
  }

  .nav-logo .logo-text {
    display: none;
  }

  .modal-header h2 {
    font-size: 1rem;
  }
}

