/* ==========================================================================
   GrowthCanvas Print & Responsive Styles
   ========================================================================== */

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  /* Reset zoom and margins for full page usage */
  body {
    zoom: 1;
    margin: 0;
    padding: 0;
  }

  /* Hide the entire right-hand tool panels */
  .side-panels { display: none !important; }
  .panel-toggles { display: none !important; }

  /* Hide UI controls that shouldn't be in PDF */
  header .controls { display: none !important; }
  .header-left .partner-selector { display: none !important; }
  .manage-distributors-btn { display: none !important; }
  .footer { display: none !important; }
  #debugSection { display: none !important; }
  .focus-exit-btn { display: none !important; }
  .icons { display: none !important; }
  .export-dropdown { display: none !important; }
  .theme-toggle { display: none !important; }
  .autosave-indicator { display: none !important; }

  /* Make main content take full width */
  .wrap {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 12px !important;
    display: block !important;
  }

  .main-content {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Canvas grid - ensure proper layout without overlap */
  .grid {
    display: grid !important;
    grid-template-columns: repeat(12, 1fr) !important;
    gap: 10px !important;
    page-break-inside: avoid;
  }

  /* Cards - remove transitions, ensure visibility */
  .card {
    transition: none !important;
    transform: none !important;
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }

  /* Ensure focus-hidden cards stay hidden in print */
  .card.focus-hidden {
    display: none !important;
  }

  /* Ensure proper column spans are respected */
  .col-12 { grid-column: span 12 !important; }
  .col-8 { grid-column: span 8 !important; }
  .col-6 { grid-column: span 6 !important; }
  .col-4 { grid-column: span 4 !important; }
  .col-3 { grid-column: span 3 !important; }

  /* Hide modals and popups */
  .modal { display: none !important; }
  .distributor-modal { display: none !important; }
  .distributor-form-modal { display: none !important; }

  /* Clean header for print */
  header {
    margin-bottom: 12px !important;
    padding-bottom: 8px !important;
    border-bottom: 1px solid #ccc !important;
  }

  .brand {
    margin-bottom: 0 !important;
  }
}

/* ==========================================================================
   Responsive Modal Styles
   ========================================================================== */

/* Medium screens (laptops 1366x768, small desktops) */
@media (max-width: 1400px) and (max-height: 800px) {
  .modal.with-listen .panel { max-height: 88vh; }
  .waveform-container { height: 60px; margin-bottom: 8px; }
  .transcript-display { height: 160px; min-height: 120px; }
  .suggested-questions-sticky { max-height: 140px; }
  .modal .field textarea { min-height: 70px; }
  .split-layout { gap: 14px; }
  .questions-side { padding-right: 8px; }
  .ai-insights-side { padding-left: 8px; }
  .insight-card { padding: 10px; margin-bottom: 10px; }
}

/* Shorter screens (height constraint regardless of width) */
@media (max-height: 700px) {
  .modal .panel { max-height: 92vh; }
  .modal.with-listen .panel { max-height: 94vh; }
  .waveform-container { height: 50px; }
  .transcript-display { height: 120px; min-height: 100px; }
  .suggested-questions-sticky { max-height: 100px; font-size: 12px; }
  .modal .field label { padding: 3px 8px; font-size: 12px; }
  .modal .field textarea { min-height: 60px; }
  .modal-header { margin-bottom: 8px; }
  .modal-header h3 { font-size: 15px; }
}

/* Tablet - modals adapt to smaller width */
@media (max-width: 900px) {
  .modal .panel { width: 95vw; padding: 14px; max-height: 90vh; overflow-y: auto; }
  .modal.with-listen .panel { width: 98vw; max-height: 92vh; }
  .split-layout { flex-direction: column; gap: 16px; }
  .questions-side, .ai-insights-side { padding: 0; border: none; max-height: none; overflow: visible; }
  .ai-insights-side { border-top: 2px solid var(--line); padding-top: 16px; border-left: none; }
  .row { grid-template-columns: 1fr; }
  .modal .field { margin-bottom: 12px; }
  .modal .field label { font-size: 12px; padding: 6px 10px; }
  .modal .field textarea { min-height: 80px; }
  .modal-header { flex-wrap: wrap; gap: 10px; }
  .modal-header h3 { font-size: 16px; flex: 1 1 100%; }
  #listenBtn { padding: 10px 14px; font-size: 13px; }
  .waveform-container { height: 60px; }
  .transcript-display { height: 150px; min-height: 100px; }
  .suggested-questions-sticky { max-height: 140px; }
}

/* Mobile - stack everything vertically */
@media (max-width: 600px) {
  .modal .panel { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; padding: 12px; }
  .modal.with-listen .panel { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .modal-header { position: sticky; top: 0; background: var(--card); z-index: 5; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
  .modal-header h3 { font-size: 15px; margin-bottom: 8px; }
  #listenBtn { width: 100%; justify-content: center; padding: 12px; }
  .modal .field label { font-size: 11px; padding: 5px 8px; }
  .modal .field textarea { min-height: 100px; font-size: 14px; padding: 10px; }
  .modal .actions { position: sticky; bottom: 0; background: var(--card); padding: 12px 0; margin-top: auto; border-top: 1px solid var(--line); flex-wrap: wrap; }
  .modal .actions button { flex: 1; min-width: 120px; padding: 12px; }
  .split-layout { gap: 12px; }
  .questions-side-content { max-height: none; }
  .waveform-container { height: 50px; margin-bottom: 8px; }
  .transcript-display { height: 120px; font-size: 12px; }
  .suggested-questions-sticky { max-height: 120px; padding: 8px 0; }
  .insight-card { padding: 10px; }
  .insight-question { font-size: 11px; }
  .insight-answer { font-size: 13px; }
  .use-answer-btn { width: 100%; padding: 10px; }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  .modal .field textarea { min-height: 90px; font-size: 16px; }
  .modal .field label { padding: 8px 10px; }
  .modal .actions button { min-height: 44px; }
  #listenBtn { min-height: 44px; }
}

/* ==========================================================================
   Split Layout (Modal with AI Insights)
   ========================================================================== */
.split-layout {
  display: flex;
  gap: 20px;
  flex: 1;
  overflow: hidden;
}

.questions-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-right: 10px;
}

.questions-side-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.suggested-questions-sticky {
  flex-shrink: 0;
  background: var(--card);
  padding: 12px 0 0 0;
  max-height: 180px;
  overflow-y: auto;
}

/* Suggested Questions Callout - positioned in AI insights panel */
.suggested-questions-callout {
  background: linear-gradient(135deg, rgba(255, 106, 0, 0.08), rgba(255, 106, 0, 0.02));
  border: 1px solid var(--accent);
  border-radius: 10px;
  margin-bottom: 14px;
  flex-shrink: 0;
  overflow: hidden;
}

.suggested-questions-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.suggested-questions-header:hover {
  background: rgba(255, 106, 0, 0.05);
}

.suggested-questions-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  flex: 1;
}

.suggested-questions-icon {
  font-size: 16px;
}

.suggested-questions-toggle {
  font-size: 10px;
  color: var(--accent);
  transition: transform 0.2s;
}

.suggested-questions-collapsible {
  padding: 0 14px 14px 14px;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.2s ease;
  max-height: 200px;
  opacity: 1;
}

.suggested-questions-callout.collapsed .suggested-questions-collapsible {
  max-height: 0;
  opacity: 0;
  padding: 0 14px;
}

.suggested-questions-callout.collapsed .suggested-questions-toggle {
  transform: rotate(-90deg);
}

.suggested-questions-list {
  font-size: 12px;
  color: var(--text);
  line-height: 1.7;
}

.suggested-questions-list p {
  margin: 0 0 6px 0;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.suggested-questions-list p:hover {
  background: var(--card);
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}

.suggested-questions-list p:last-child {
  margin-bottom: 0;
}

/* Theme variations for suggested questions */
.theme-light .suggested-questions-callout {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), rgba(37, 99, 235, 0.01));
  border-color: #2563eb;
}

.theme-light .suggested-questions-header h4 {
  color: #2563eb;
}

.theme-ocean .suggested-questions-callout {
  background: linear-gradient(135deg, rgba(17, 181, 228, 0.1), rgba(17, 181, 228, 0.02));
  border-color: #11b5e4;
}

.theme-ocean .suggested-questions-header h4 {
  color: #11b5e4;
}

.ai-insights-side {
  flex: 1;
  overflow-y: auto;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  display: none;
}

.ai-insights-side.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Waveform & Transcript
   ========================================================================== */
.waveform-container {
  height: 80px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.waveform-placeholder {
  position: absolute;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  opacity: 0.5;
}

.transcript-display {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 120px;
  max-height: 600px;
  height: 220px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  position: relative;
  resize: vertical;
}

.transcript-display.empty {
  display: none;
}

.transcript-display p {
  margin: 0;
}

.clear-transcript-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
  z-index: 10;
}

.clear-transcript-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Collapsible Transcript Section */
.transcript-section {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card);
}

.transcript-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.transcript-header:hover {
  background: var(--bg);
}

.transcript-icon {
  font-size: 16px;
}

.transcript-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.transcript-toggle-icon {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--muted);
}

.transcript-badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 8px;
}

.transcript-collapsible {
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
  max-height: 500px;
  opacity: 1;
  padding: 0 12px 12px 12px;
}

.transcript-section.collapsed .transcript-collapsible {
  max-height: 0;
  opacity: 0;
  padding: 0 12px;
}

.transcript-section.collapsed .transcript-toggle-icon {
  transform: rotate(-90deg);
}

.transcript-section.collapsed .transcript-display {
  display: none;
}

/* When collapsed, remove margin from section */
.transcript-section.collapsed {
  margin-bottom: 8px;
}

/* Adjust transcript-display when inside collapsible */
.transcript-collapsible .transcript-display {
  margin-bottom: 0;
  border-radius: 6px;
}

.transcript-collapsible .transcript-display.empty {
  display: block;
  min-height: 60px;
  height: auto;
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* Transcript Session Styles */
.transcript-session {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.transcript-session.active-session {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255, 106, 0, 0.05), transparent);
}

.session-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--line);
}

.session-header:hover {
  background: var(--line);
}

.session-toggle {
  font-size: 10px;
  transition: transform 0.2s;
  width: 12px;
  text-align: center;
}

.session-title {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.recording-indicator {
  animation: pulse 1.5s infinite;
}

.paused-indicator {
  opacity: 0.8;
}

.delete-session-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s;
}

.delete-session-btn:hover {
  background: var(--bad);
  color: white;
}

.session-content {
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.session-content.collapsed {
  max-height: 0;
  padding: 0 12px;
  overflow: hidden;
}

.session-content p {
  margin: 0;
  line-height: 1.6;
  color: var(--text);
}

/* ==========================================================================
   AI Insights
   ========================================================================== */
.insights-container {
  flex: 1;
  overflow-y: auto;
}

.insight-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.insight-card:hover {
  border-color: var(--accent);
}

.insight-question {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}

.insight-answer {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 10px;
}

.insight-confidence {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.insight-confidence.high { color: #27ae60; }
.insight-confidence.medium { color: #f39c12; }
.insight-confidence.low { color: #e74c3c; }

.use-answer-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  width: auto;
  display: inline-block;
}

.use-answer-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* ==========================================================================
   Listen Button
   ========================================================================== */
#listenBtn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

#listenBtn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

#listenBtn.listening {
  background: #e74c3c;
  animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(0.98); }
}

#listenBtn.paused {
  background: #f39c12;
}
