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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

/* Fruit Result Image Styles */
.fruit-image-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.fruit-result-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 20px;
}

.fruit-emoji {
    font-size: 5rem;
    line-height: 150px;
    text-align: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #ff6b6b, #4ecdc4);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 300;
    margin-bottom: 15px;
    opacity: 0.9;
}

.privacy-notice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
}

.privacy-notice i {
    color: #4ade80;
}

/* Main Content */
.main {
    flex: 1;
    background: white;
    border-radius: 20px;
    padding: 30px 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* Upload Section */
.upload-section {
    text-align: center;
}

.upload-area {
    border: 2px dashed #e0e0e0;
    border-radius: 16px;
    padding: 40px 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.upload-area:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.upload-area.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.upload-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 16px;
}

.upload-area h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: #333;
}

.upload-area p {
    color: #666;
    margin-bottom: 20px;
}

.upload-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

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

/* Preview Section */
.preview-section {
    text-align: center;
}

.analysis-header {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.back-btn {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-btn:hover {
    background: #667eea;
    color: white;
}

.analysis-header h2 {
    margin: 0;
    font-size: 20px;
    color: #333;
    flex: 1;
    text-align: left;
}

.preview-container {
    margin-bottom: 30px;
    text-align: center;
}

.preview-container canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

.image-info {
    margin-top: 12px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    display: inline-block;
}

.face-crop-preview {
    margin-top: 16px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e5e7eb;
}

.face-crop-preview canvas {
    width: 112px;
    height: 112px;
    margin-top: 8px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    transition: transform 0.2s ease;
}

.face-crop-preview canvas:hover {
    transform: scale(1.05);
}

.face-crop-preview small {
    color: #666;
    font-weight: 500;
}

/* AI Status Indicator Styles */
.ai-status-indicator {
    margin-top: 12px;
    text-align: center;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.normal {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.status-badge.low-power {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.package-info {
    display: block;
    margin-top: 4px;
    color: #9ca3af;
    font-size: 10px;
    font-weight: 400;
}

.analysis-controls {
    display: flex;
    justify-content: center;
}

.analyze-btn {
    background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3);
}

.analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
}

.analyze-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 40px 20px;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h3 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    color: #333;
}

.loading-progress {
    margin-bottom: 16px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
}

.loading-description {
    font-size: 0.9rem;
    color: #666;
    margin-top: 16px;
}

/* Results Section - Dummy Card Frame */
.results-section {
    text-align: center;
}

.result-header h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
}

.result-card-frame {
    width: 100%;
    max-width: 300px;
    height: 300px;
    margin: 0 auto 20px;
    border: 2px dashed #e0e0e0;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
}

.result-card-frame .placeholder-icon {
    font-size: 3rem;
    color: #ccc;
    margin-bottom: 10px;
}

.result-card-frame .placeholder-text {
    color: #666;
    font-size: 1rem;
}

.dummy-result {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 20px;
}

.dummy-result .fruit-emoji {
    font-size: 3rem;
    margin-bottom: 10px;
}

.dummy-result h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #333;
}

.dummy-result .confidence-score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.score-label {
    font-size: 0.9rem;
    color: #666;
}

.score-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #667eea;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.action-buttons button {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.6;
    pointer-events: none;
}

.download-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
}

.copy-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
}

.share-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

/* Error Section */
.error-section {
    text-align: center;
    padding: 40px 20px;
}

.error-icon {
    font-size: 3rem;
    color: #ef4444;
    margin-bottom: 16px;
}

.error-content h3 {
    font-size: 1.25rem;
    margin-bottom: 12px;
    color: #333;
}

.error-content p {
    color: #666;
    margin-bottom: 20px;
}

.retry-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

/* Footer */
.footer {
    text-align: center;
    color: white;
    opacity: 0.8;
    font-size: 0.9rem;
}

.tech-info {
    margin-top: 8px;
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast i {
    color: #4ade80;
}

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

/* Responsive Design */
@media (min-width: 768px) {
    .container {
        max-width: 600px;
        padding: 40px;
    }
    
    .title {
        font-size: 2.5rem;
    }
    
    .main {
        padding: 40px 30px;
    }
    
    .action-buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .action-buttons button {
        flex: 1;
        max-width: 160px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px;
    }
    
    .main {
        padding: 24px 16px;
    }
    
    .upload-area {
        padding: 30px 16px;
    }
    
    .analysis-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .analysis-header h2 {
        text-align: center;
        width: 100%;
    }
    
    .back-btn {
        align-self: flex-start;
    }
    
    .preview-container {
        margin-bottom: 24px;
    }
    
    .analyze-btn {
        width: 100%;
        justify-content: center;
    }
    
    .image-info {
        font-size: 11px;
        padding: 6px 10px;
    }
}

/* Results Display Styles */
.results-display {
    text-align: center;
    padding: 30px 20px;
}

.results-display.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 60px 20px;
}

.results-display.error {
    padding: 40px 20px;
}

.results-display.empty {
    padding: 40px 20px;
    color: #666;
}

.top-result {
    margin-bottom: 40px;
}

.fruit-emoji {
    font-size: 4rem;
    margin-bottom: 16px;
}

.fruit-name {
    font-size: 2.2rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.confidence-score {
    font-size: 2rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 12px;
}

.fruit-description {
    font-size: 1.1rem;
    color: #666;
    line-height: 1.5;
}

.chart-section {
    margin-bottom: 40px;
}

.chart-section h3 {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 16px;
}

.results-chart {
    display: block;
    margin: 0 auto;
    border-radius: 8px;
    background: #fafafa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.share-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.share-btn, .save-btn, .retest-btn, .retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.share-btn.primary {
    background: #667eea;
    color: white;
    min-width: 180px;
}

.share-btn.primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.save-btn.secondary, .retest-btn.secondary, .retry-btn {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.save-btn.secondary:hover, .retest-btn.secondary:hover, .retry-btn:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.error-icon, .empty-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.error-icon {
    color: #ef4444;
}

.empty-icon {
    color: #9ca3af;
}

.error-message {
    color: #666;
    margin-bottom: 20px;
    font-size: 1rem;
}

/* Loading Spinner */
.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .share-actions {
        width: 100%;
    }
    
    .share-btn.primary, .save-btn.secondary, .retest-btn.secondary, .retry-btn {
        width: 100%;
        justify-content: center;
    }
    
    .fruit-emoji {
        font-size: 3.5rem;
    }
    
    .fruit-name {
        font-size: 1.8rem;
    }
    
    .confidence-score {
        font-size: 1.6rem;
    }
    
    .results-chart {
        width: 100%;
        max-width: 280px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

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

button:focus,
input:focus,
textarea:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .upload-area {
        border-color: #000;
    }
    
    .privacy-notice {
        background: rgba(255,255,255,0.9);
        color: #000;
    }
}

/* Background Progress */
.background-progress {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid #e5e7eb;
  z-index: 1000;
  min-width: 280px;
  transition: all 0.3s ease;
}

.background-progress.hidden {
  transform: translateX(320px);
  opacity: 0;
  pointer-events: none;
}

.progress-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-icon {
  color: #667eea;
  font-size: 18px;
  animation: downloadPulse 1.5s ease-in-out infinite;
}

@keyframes downloadPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.progress-info {
  flex: 1;
}

.progress-text {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 8px;
}

.progress-bar {
  height: 6px;
  background: #f3f4f6;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-percent {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

/* Status indicator updates */
.status-badge.ready {
  background: #10b981;
  color: white;
}

.status-badge.ready i {
  color: white;
}

/* Share Components */
.result-card-section, .share-text-section {
  margin-top: 30px;
  padding: 24px;
  background: #f8fafc;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
}

.card-header, .text-header {
  text-align: center;
  margin-bottom: 24px;
}

.card-header h3, .text-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 8px;
}

.card-subtitle, .text-subtitle {
  color: #64748b;
  font-size: 0.9rem;
}

.card-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 320px;
  margin-bottom: 24px;
  background: white;
  border-radius: 12px;
  border: 2px dashed #cbd5e1;
}

.card-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #64748b;
}

.card-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #ef4444;
}

.card-error i {
  font-size: 2rem;
}

.card-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 20px;
}

.card-actions.vertical {
  flex-direction: column;
  align-items: center;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 140px;
  justify-content: center;
}

.share-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.share-btn.primary {
  background: #667eea;
  color: white;
}

.share-btn.primary:hover:not(:disabled) {
  background: #5a67d8;
  transform: translateY(-1px);
}

.share-btn.secondary {
  background: white;
  color: #374151;
  border: 1px solid #d1d5db;
}

.share-btn.secondary:hover:not(:disabled) {
  background: #f9fafb;
  transform: translateY(-1px);
}

.privacy-notice-card {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 12px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(34, 197, 94, 0.2);
  font-size: 0.85rem;
  color: #166534;
}

.privacy-notice-card i {
  color: #22c55e;
}

/* Share Text Box */
.share-text-box {
  position: relative;
  background: white;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
  margin-bottom: 20px;
}

.share-text-content {
  padding: 20px;
  font-family: 'Noto Sans KR', -apple-system, sans-serif;
  line-height: 1.6;
  min-height: 120px;
}

.main-line {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1e293b;
  display: block;
  margin-bottom: 12px;
}

.hashtag-line {
  color: #667eea;
  font-weight: 500;
  display: block;
  margin: 8px 0;
}

.copy-line {
  color: #64748b;
  font-size: 0.95rem;
  display: block;
  margin-top: 8px;
}

.copy-text-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-text-btn:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

.share-tips {
  padding: 16px;
  background: rgba(99, 102, 241, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.tip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #4338ca;
  font-size: 0.9rem;
}

.tip-item i {
  color: #8b5cf6;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .result-card-section, .share-text-section {
    padding: 16px;
    margin-top: 20px;
  }
  
  .card-actions {
    flex-direction: column;
  }
  
  .share-btn {
    width: 100%;
  }
  
  .copy-text-btn {
    position: static;
    width: 100%;
    justify-content: center;
    margin-top: 12px;
  }
}

/* Share Section Styles */
.share-section {
  margin-top: 2rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.share-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1rem;
  text-align: center;
}

.share-card-container,
.share-text-container {
  margin-bottom: 1.5rem;
}

.loading-placeholder {
  text-align: center;
  padding: 2rem;
  color: #666;
  font-style: italic;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  border: 1px dashed #ddd;
}

.no-image-message {
  text-align: center;
  padding: 2rem;
  color: #666;
  background: rgba(255, 193, 7, 0.1);
  border-radius: 10px;
  border: 1px dashed #ffc107;
}

.no-image-message i {
  font-size: 2rem;
  color: #ffc107;
  margin-bottom: 1rem;
  display: block;
}

.no-image-message p {
  margin: 0;
  line-height: 1.5;
}
