/* Enhanced Chart Sharing Modal Styles */

.share-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;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease-out;
}

.share-modal {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease-out;
}

.share-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.share-modal-header h3 {
  margin: 0;
  color: #1f2937;
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  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 ease;
}

.close-btn:hover {
  background: #f3f4f6;
  color: #374151;
}

.share-modal-content {
  padding: 20px 24px 24px;
}

/* Chart Preview */
.chart-preview {
  position: relative;
  margin-bottom: 24px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #e5e7eb;
}

.preview-image {
  width: 100%;
  height: auto;
  display: block;
}

.chart-info {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
}

.symbol-tag, .chart-type-tag {
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #1f2937;
  backdrop-filter: blur(4px);
}

.symbol-tag {
  background: rgba(59, 130, 246, 0.95);
  color: white;
}

/* Share Text Section */
.share-text-section {
  margin-bottom: 24px;
}

.share-text-section label {
  display: block;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  font-size: 14px;
}

.share-text-input {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  transition: border-color 0.2s ease;
}

.share-text-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.character-count {
  text-align: right;
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
}

/* Analysis Summary */
.analysis-summary {
  margin-bottom: 24px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.analysis-summary h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.analysis-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-tag {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #e5e7eb;
  color: #374151;
}

.analysis-tag.sentiment-bullish {
  background: #dcfce7;
  color: #166534;
}

.analysis-tag.sentiment-bearish {
  background: #fee2e2;
  color: #991b1b;
}

.analysis-tag.sentiment-neutral {
  background: #f3f4f6;
  color: #4b5563;
}

.analysis-tag.price-change.positive {
  background: #dcfce7;
  color: #166534;
}

.analysis-tag.price-change.negative {
  background: #fee2e2;
  color: #991b1b;
}

.analysis-tag.volume {
  background: #ddd6fe;
  color: #5b21b6;
}

/* Platform Options */
.platform-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.platform-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.platform-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.twitter-btn {
  background: #1da1f2;
  color: white;
}

.twitter-btn:hover {
  background: #1a91da;
}

.linkedin-btn {
  background: #0077b5;
  color: white;
}

.linkedin-btn:hover {
  background: #006399;
}

.copy-btn {
  background: #6b7280;
  color: white;
}

.copy-btn:hover {
  background: #4b5563;
}

.platform-icon {
  font-size: 16px;
}

/* Success Message */
.success-message {
  text-align: center;
  padding: 12px;
  background: #dcfce7;
  color: #166534;
  border-radius: 8px;
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  /* Force visibility of all modal elements */
  .share-modal-overlay * {
    visibility: visible !important;
  }
  
  /* Debug border for mobile troubleshooting */
  .chart-preview {
    border: 3px solid red !important;
  }
  
  .analysis-summary {
    border: 3px solid blue !important;
  }
  
  .share-modal-overlay {
    padding: 10px;
    align-items: flex-start;
    padding-top: 20px;
  }
  
  .share-modal {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 12px;
    min-height: auto;
    max-height: calc(100vh - 40px);
  }
  
  .share-modal-header {
    padding: 16px 20px 12px;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
  }
  
  .share-modal-header h3 {
    font-size: 16px;
  }
  
  .close-btn {
    width: 28px;
    height: 28px;
    font-size: 20px;
  }
  
  .share-modal-content {
    padding: 16px 20px 20px;
    display: block !important;
    visibility: visible !important;
  }
  
  /* Ensure all sections are visible on mobile */
  .share-text-section,
  .platform-options {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Chart Preview Mobile */
  .chart-preview {
    margin-bottom: 20px;
    border-radius: 8px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative;
    overflow: hidden;
    border: 2px solid #e5e7eb;
  }
  
  .preview-image {
    width: 100%;
    height: auto;
    display: block !important;
    max-height: 300px;
    object-fit: contain;
  }
  
  .chart-info {
    top: 8px;
    left: 8px;
    gap: 6px;
    flex-wrap: wrap;
    position: absolute;
    display: flex !important;
  }
  
  .symbol-tag, .chart-type-tag {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 12px;
    display: inline-block !important;
  }
  
  /* Platform Buttons Mobile Optimized */
  .platform-options {
    gap: 12px;
    margin-bottom: 16px;
  }
  
  .platform-btn {
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    min-height: 56px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
  }
  
  .platform-btn:active {
    transform: scale(0.98);
  }
  
  .platform-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  
  .platform-btn:active::before {
    transform: translateX(0);
  }
  
  /* Mobile-specific platform styling */
  .twitter-btn {
    background: linear-gradient(135deg, #1da1f2 0%, #1a91da 100%);
    box-shadow: 0 4px 15px rgba(29, 161, 242, 0.3);
  }
  
  .linkedin-btn {
    background: linear-gradient(135deg, #0077b5 0%, #006399 100%);
    box-shadow: 0 4px 15px rgba(0, 119, 181, 0.3);
  }
  
  .copy-btn {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
  }
  
  .platform-icon {
    font-size: 18px;
    margin-right: 2px;
  }
  
  /* Share Text Input Mobile */
  .share-text-input {
    min-height: 100px;
    padding: 16px;
    font-size: 16px; /* Prevents zoom on iOS */
    border-radius: 12px;
    line-height: 1.6;
  }
  
  .share-text-input:focus {
    border-width: 2px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  }
  
  /* Analysis Tags Mobile */
  .analysis-summary {
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: 12px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
  }
  
  .analysis-summary h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    display: block !important;
  }
  
  .analysis-tags {
    justify-content: center;
    gap: 6px;
    display: flex !important;
    flex-wrap: wrap;
  }
  
  .analysis-tag {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 16px;
    display: inline-block !important;
  }
  
  /* Character Count Mobile */
  .character-count {
    font-size: 13px;
    margin-top: 6px;
  }
  
  /* Success Message Mobile */
  .success-message {
    padding: 16px;
    font-size: 15px;
    border-radius: 12px;
    margin-top: 12px;
  }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
  .share-modal-overlay {
    padding: 5px;
    padding-top: 10px;
  }
  
  .share-modal {
    border-radius: 8px;
    max-height: calc(100vh - 20px);
  }
  
  .share-modal-header {
    padding: 12px 16px 8px;
  }
  
  .share-modal-content {
    padding: 12px 16px 16px;
  }
  
  .platform-btn {
    padding: 14px 16px;
    font-size: 15px;
    min-height: 52px;
  }
  
  .share-text-input {
    min-height: 90px;
    padding: 12px;
    font-size: 16px;
  }
  
  .analysis-summary {
    padding: 10px 12px;
    display: block !important;
    visibility: visible !important;
  }
  
  .chart-preview {
    display: block !important;
    visibility: visible !important;
  }
  
  .chart-info {
    top: 6px;
    left: 6px;
    display: flex !important;
  }
  
  .symbol-tag, .chart-type-tag {
    padding: 3px 6px;
    font-size: 10px;
    display: inline-block !important;
  }
}

/* Large mobile devices and tablets */
@media (min-width: 769px) and (max-width: 1024px) {
  .share-modal {
    max-width: 600px;
  }
  
  .platform-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  
  .copy-btn {
    grid-column: 1 / -1;
  }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  .platform-btn {
    -webkit-appearance: none;
    appearance: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
  
  .share-text-input {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 12px;
  }
}

/* Android specific optimizations */
@media screen and (-webkit-min-device-pixel-ratio: 1.5) {
  .platform-btn {
    will-change: transform;
  }
  
  .platform-btn:active {
    transition: transform 0.1s ease;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .share-modal {
    background: #1f2937;
    color: #f9fafb;
  }
  
  .share-modal-header {
    border-bottom-color: #374151;
  }
  
  .share-modal-header h3 {
    color: #f9fafb;
  }
  
  .close-btn {
    color: #9ca3af;
  }
  
  .close-btn:hover {
    background: #374151;
    color: #f3f4f6;
  }
  
  .share-text-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
  
  .share-text-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
  }
  
  .analysis-summary {
    background: #374151;
    border-color: #4b5563;
  }
  
  .analysis-summary h4 {
    color: #f9fafb;
  }
  
  .chart-preview {
    border-color: #4b5563;
  }
}
