/**
 * Cross-Stitch Pattern Converter - Stylesheet
 * 100% Fluid, Needlework Studio UI with Print-Friendly Styles
 */

/* Viewport Stage */
.pattern-stage-wrapper {
  position: relative;
  width: 100%;
  min-height: 480px;
  max-height: 640px;
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  scrollbar-width: thin;
}

#patternCanvas {
  max-width: none;
  display: block;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
}

/* Mode Switcher Tabs */
.view-tabs-bar {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 4px;
  overflow-x: auto;
}

.view-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.view-tab-btn:hover {
  color: #fff;
}

.view-tab-btn.active {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

/* Metrics Grid Cards */
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 14px;
  margin-bottom: 20px;
}

.metric-badge-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.metric-badge-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.metric-badge-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

/* Legend Table */
.legend-table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 24px;
}

.legend-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 12px;
}

.table-scroll-wrap {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.stitch-legend-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.stitch-legend-table th {
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-secondary);
  padding: 10px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border-subtle);
}

.stitch-legend-table td {
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.stitch-legend-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Print Optimization */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .pic-header, .tool-hero, .demo-bar, .tool-controls-panel, .tool-content-guide, .pic-footer, .zoom-btn-group, .view-tabs-bar {
    display: none !important;
  }
  .tool-grid {
    display: block !important;
  }
  .pattern-stage-wrapper {
    background: #fff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  #patternCanvas {
    box-shadow: none !important;
    max-width: 100% !important;
  }
  .legend-table-container {
    border: 1px solid #ccc !important;
    background: #fff !important;
    color: #000 !important;
  }
  .table-scroll-wrap {
    max-height: none !important;
    overflow: visible !important;
  }
  .stitch-legend-table th, .stitch-legend-table td {
    color: #000 !important;
    border-bottom: 1px solid #ccc !important;
  }
}

/* Mobile & Tablet Responsiveness */
@media (max-width: 768px) {
  .pattern-stage-wrapper {
    min-height: 340px;
    max-height: 440px;
    padding: 12px;
  }
}

/* Modern Glassmorphic Upload Card */
.cross-stitch-upload-section {
  position: relative;
}

.upload-badge-pill {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: #a5b4fc;
  padding: 2px 8px;
  border-radius: var(--radius-full, 9999px);
}

.stitch-upload-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 18px;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.8) 100%);
  backdrop-filter: blur(12px);
  border: 2px dashed rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-lg, 12px);
  cursor: pointer;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  user-select: none;
  margin-bottom: 12px;
}

.stitch-upload-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(99, 102, 241, 0.12) 0%, transparent 70%);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.stitch-upload-card:hover,
.stitch-upload-card.drag-over {
  border-color: #818cf8;
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.85) 0%, rgba(15, 23, 42, 0.95) 100%);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(99, 102, 241, 0.25), 0 0 0 1px rgba(99, 102, 241, 0.4);
}

.stitch-upload-card:hover .stitch-upload-svg {
  transform: translateY(-2px);
  color: #a5b4fc;
}

.upload-icon-wrapper {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.stitch-upload-card:hover .upload-icon-wrapper {
  background: rgba(99, 102, 241, 0.22);
  border-color: #818cf8;
  box-shadow: 0 0 18px rgba(99, 102, 241, 0.45);
}

.stitch-upload-svg {
  color: #818cf8;
  transition: transform 0.25s ease, color 0.25s ease;
}

.upload-glow-effect {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  filter: blur(10px);
  background: rgba(99, 102, 241, 0.25);
  pointer-events: none;
}

.upload-card-heading {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  margin-bottom: 4px;
  letter-spacing: -0.2px;
}

.upload-card-sub {
  font-size: 0.74rem;
  color: var(--text-secondary, #94a3b8);
  max-width: 250px;
  margin: 0 auto 14px;
  line-height: 1.35;
}

.upload-btn-styled {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  border-radius: var(--radius-full, 9999px);
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: all 0.2s ease;
}

.stitch-upload-card:hover .upload-btn-styled {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  transform: scale(1.03);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.upload-formats-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.format-pill {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  transition: all 0.2s ease;
}

.stitch-upload-card:hover .format-pill {
  border-color: rgba(99, 102, 241, 0.25);
  color: var(--text-secondary, #94a3b8);
}

/* Active Loaded Artwork Card */
.stitch-active-preview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.85) 100%);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-md, 10px);
  padding: 12px;
  margin-top: 10px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  animation: fadeInUpload 0.3s ease-out;
}

@keyframes fadeInUpload {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.active-thumb-col {
  position: relative;
  flex-shrink: 0;
}

.stitch-active-thumb-img {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #000;
  display: block;
}

.active-thumb-glow {
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.4), transparent);
  z-index: -1;
}

.active-thumb-details {
  flex: 1;
  min-width: 0;
}

.active-thumb-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary, #ffffff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.active-thumb-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.thumb-stat-pill {
  font-size: 0.68rem;
  font-family: var(--font-mono, monospace);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary, #94a3b8);
  padding: 2px 6px;
  border-radius: 4px;
}

.thumb-stat-pill.status-ready {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
  font-weight: 700;
}

.active-thumb-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-change-photo {
  font-size: 0.72rem;
  font-weight: 700;
  color: #818cf8;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  text-decoration: none;
}

.btn-change-photo:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #ffffff;
}

.btn-remove-photo {
  font-size: 0.72rem;
  font-weight: 600;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-remove-photo:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
}

/* Toast Pill */
.toast-pill {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #fff;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100000;
}

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

.toast-pill.success {
  border-color: #10b981;
}

.toast-pill.error {
  border-color: #ef4444;
  color: #fca5a5;
}
