/* ⚠️ MOBILE-FIRST: Base rules = mobile. Use @media(min-width: X) for desktop. Do NOT use @media(max-width) for layout.
   ==========================================
   CHAT INTERVIEW - Conversational AI Flow
   ========================================== */

.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height, 60px) - 60px); /* full viewport minus topbar and progress bar */
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: var(--card-bg);
  overflow: hidden;
}

@media(min-width: 768px) {
  .chat-container {
    height: 500px;
  }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

@media(min-width: 640px) {
  .chat-messages {
    padding: 20px;
    gap: 16px;
  }
}

.chat-message {
  display: flex;
  gap: 8px;
  max-width: 100%;
  animation: messageIn 0.3s ease;
}

@media(min-width: 640px) {
  .chat-message {
    gap: 10px;
  }
}

@media(min-width: 768px) {
  .chat-message {
    max-width: 85%;
  }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message.ai {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

@media(min-width: 640px) {
  .chat-avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
}

.chat-avatar.ai {
  background: var(--brand-navy);
  color: white;
}

.chat-avatar.user {
  background: var(--brand-gold);
  color: white;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  position: relative;
}

@media(min-width: 640px) {
  .chat-bubble {
    padding: 12px 16px;
    font-size: 0.9rem;
    line-height: 1.6;
  }
}

.chat-message.ai .chat-bubble {
  background: #F1F5F9;
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.chat-message.user .chat-bubble {
  background: var(--brand-navy);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble .bullet-result {
  margin-top: 8px;
  padding: 10px 14px;
  background: #F0FDF4;
  border-left: 3px solid var(--success-green);
  border-radius: 6px;
  font-size: 0.85rem;
  color: #166534;
  line-height: 1.5;
}

.chat-bubble .section-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* --- Chat Input Area --- */
.chat-input-area {
  border-top: 1px solid var(--border-light);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #FAFAFA;
  position: sticky;
  bottom: 0;
}

@media(min-width: 640px) {
  .chat-input-area {
    padding: 12px 16px;
    gap: 10px;
  }
}

.chat-input-area textarea {
  flex: 1;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 0.9rem;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  transition: border 0.2s;
}

.chat-input-area textarea:focus {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 2px rgba(175, 144, 91, 0.1);
}

.chat-send-btn {
  background: var(--brand-navy);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  font-size: 0.85rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media(min-width: 640px) {
  .chat-send-btn {
    padding: 10px 18px;
  }
}

.chat-send-btn:hover {
  background: var(--brand-navy-light);
}

.chat-send-btn:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
}

.chat-send-btn .spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* --- Question Cards (within AI messages) --- */
.chat-question {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--card-bg);
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  border-left: 3px solid var(--brand-gold);
}

@media(min-width: 640px) {
  .chat-question {
    padding: 12px;
  }
}

.chat-question:last-child {
  margin-bottom: 0;
}

.chat-question .q-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brand-gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.chat-question .q-text {
  font-size: 0.88rem;
  color: var(--text-main);
  line-height: 1.5;
}

.chat-question .answer-preview {
  margin-top: 8px;
  padding: 8px 12px;
  background: #F8FAFC;
  border: 1px dashed #CBD5E1;
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.chat-question .answer-preview.has-answer {
  border-style: solid;
  border-color: var(--success-green);
  background: #F0FDF4;
  color: #166534;
  font-style: normal;
}

/* --- Progress indicator --- */
.chat-progress {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  background: #FAFAFA;
  flex-wrap: wrap;
}

@media(min-width: 640px) {
  .chat-progress {
    gap: 8px;
    padding: 12px 16px;
  }
}

.chat-progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #E2E8F0;
  transition: all 0.3s;
}

@media(min-width: 640px) {
  .chat-progress-dot {
    width: 10px;
    height: 10px;
  }
}

.chat-progress-dot.done {
  background: var(--success-green);
}

.chat-progress-dot.active {
  background: var(--brand-gold);
  box-shadow: 0 0 0 3px rgba(175, 144, 91, 0.2);
}

/* --- Generate Button --- */
.chat-generate-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  text-align: center;
  background: #FAFAFA;
}

@media(min-width: 640px) {
  .chat-generate-area {
    padding: 12px 16px;
  }
}

.chat-generate-btn {
  background: var(--brand-gold);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  min-height: 44px;
}

@media(min-width: 640px) {
  .chat-generate-btn {
    padding: 14px 32px;
    font-size: 1rem;
  }
}

.chat-generate-btn:hover {
  background: #C4952E;
  transform: translateY(-1px);
}

.chat-generate-btn:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
  transform: none;
}

/* --- Locked Section Overlay --- */
.chat-locked-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  text-align: center;
  border: 2px dashed var(--brand-gold);
  border-radius: 12px;
  background: var(--bg-cream);
}

@media(min-width: 640px) {
  .chat-locked-overlay {
    padding: 60px 20px;
  }
}

.chat-locked-overlay .lock-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

@media(min-width: 640px) {
  .chat-locked-overlay .lock-icon {
    font-size: 3rem;
    margin-bottom: 16px;
  }
}

.chat-locked-overlay h4 {
  color: var(--brand-navy);
  font-size: 1.1rem;
  margin-bottom: 8px;
}

@media(min-width: 640px) {
  .chat-locked-overlay h4 {
    font-size: 1.2rem;
  }
}

.chat-locked-overlay p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
  max-width: 400px;
}

/* --- Structured Cards (Work Section) --- */
.work-card {
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  animation: messageIn 0.3s ease;
}

.work-card-critique {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-left: 4px solid #EF4444;
}

.work-card-critique .card-title {
  color: #DC2626;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.work-card-critique .card-text {
  color: #7F1D1D;
  font-size: 0.88rem;
  line-height: 1.6;
}

.work-card-draft {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-left: 4px solid #22C55E;
}

.work-card-draft .card-title {
  color: #15803D;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.work-card-draft .work-experience-block {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed #BBF7D0;
}

.work-card-draft .work-experience-block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.work-card-draft .work-meta {
  font-size: 0.82rem;
  font-weight: 600;
  color: #166534;
  margin-bottom: 6px;
  line-height: 1.4;
}

.work-card-draft .work-bullet {
  font-size: 0.85rem;
  color: #14532D;
  line-height: 1.5;
  padding: 3px 0;
  padding-left: 16px;
  position: relative;
}

.work-card-draft .work-bullet::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: #22C55E;
  font-weight: 700;
}

.work-card-draft .placeholder-bracket {
  background: #FEF9C3;
  color: #92400E;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 0.82rem;
}

.work-card-questions {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-left: 4px solid #F59E0B;
}

.work-card-questions .card-title {
  color: #B45309;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.work-card-questions .question-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.6);
  border-radius: 6px;
  font-size: 0.88rem;
  color: #78350F;
  line-height: 1.5;
}

.work-card-questions .question-item:last-child {
  margin-bottom: 0;
}

.work-card-questions .question-number {
  font-weight: 700;
  color: #D97706;
  margin-right: 4px;
}

/* --- Work Section Review Panel (replaces chat paradigm) --- */
.work-review-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
}

/* Fix: review panel and skeleton span all columns of the outer split-section-ui grid */
.split-section-ui > .work-review-panel,
.split-section-ui > .review-skeleton {
  grid-column: 1 / -1;
}

/* Desktop: 2-column layout (critique+draft left, questions right) */
.work-review-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media(min-width: 768px) {
  .work-review-columns {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }
}

.work-review-left,
.work-review-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.work-greeting-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: #F1F5F9;
  border-radius: 10px;
  margin-bottom: 4px;
}

.work-greeting-card .greeting-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.work-greeting-card .greeting-body p {
  margin: 0 0 6px 0;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-main);
}

.work-form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0;
}

.work-form-section .work-input {
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 0.9rem;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  transition: border 0.2s;
  width: 100%;
  box-sizing: border-box;
}

.work-form-section .work-input:focus {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 2px rgba(175, 144, 91, 0.1);
}

.work-loading-state,
.work-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  text-align: center;
}

/* Progress bar */
.work-progress-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  flex-wrap: wrap;
}

.work-progress-segment {
  flex: 1;
  height: 4px;
  background: #E2E8F0;
  border-radius: 2px;
  position: relative;
  max-width: 60px;
}

.work-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E2E8F0;
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  transition: all 0.3s;
}

.work-progress-dot.done {
  background: var(--success-green);
}

.work-progress-dot.active {
  background: var(--brand-gold);
  box-shadow: 0 0 0 3px rgba(175, 144, 91, 0.2);
}

.work-progress-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 4px;
  white-space: nowrap;
}

/* Per-question inputs */
.work-question-block {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed #FDE68A;
}

.work-question-block:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.work-question-block .question-text {
  font-size: 0.88rem;
  color: #78350F;
  line-height: 1.5;
  margin-bottom: 8px;
}

.work-question-block .question-number {
  font-weight: 700;
  color: #D97706;
  margin-right: 4px;
}

.work-answer-input {
  border: 1px solid #D97706;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 0.88rem;
  resize: none;
  min-height: 44px;
  max-height: 100px;
  outline: none;
  transition: border 0.2s;
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.7);
}

.work-answer-input:focus {
  border-color: #B45309;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
  background: white;
}

/* Action bar */
.work-action-bar {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  flex-wrap: wrap;
}

.work-action-link-wrap {
  text-align: center;
  padding: 4px 0 0 0;
}

.work-action-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}

.work-action-link:hover {
  color: var(--brand-gold);
}

/* Start button (Lanjut) — improved CTA design */
.work-btn-start {
  min-height: 48px;
  font-size: 1rem;
  padding: 12px 24px;
  box-shadow: 0 2px 8px rgba(175, 144, 91, 0.25);
  transition: all 0.25s ease;
  position: relative;
}

.work-btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(175, 144, 91, 0.35);
}

.work-btn-start::after {
  content: "→";
  display: inline-block;
  margin-left: 6px;
  transition: transform 0.25s ease;
}

.work-btn-start:hover::after {
  transform: translateX(4px);
}

.work-action-bar .work-btn {
  flex: 1;
  min-width: 140px;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  padding: 10px 16px;
}

.work-btn-primary {
  background: var(--brand-gold);
  color: white;
}

.work-btn-primary:hover {
  background: #C4952E;
  transform: translateY(-1px);
}

.work-btn-success {
  background: #16A34A;
  color: white;
}

.work-btn-success:hover {
  background: #15803D;
  transform: translateY(-1px);
}

.work-btn:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
  transform: none;
}

/* Collapsible history */
.work-history-section {
  margin-top: 4px;
}

.work-history-accordion {
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  overflow: hidden;
}

.work-history-accordion summary {
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: #FAFAFA;
  user-select: none;
}

.work-history-accordion summary:hover {
  background: #F1F5F9;
}

.work-history-item {
  padding: 8px 14px;
  border-top: 1px solid #F1F5F9;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.work-history-item .history-header {
  font-weight: 600;
  color: var(--brand-navy);
  margin-bottom: 4px;
}

.work-history-item .history-label {
  font-weight: 600;
  color: #64748B;
}

.work-date {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.82rem;
}

@media(min-width: 640px) {
  .work-question-block .question-text {
    font-size: 0.9rem;
  }
  .work-action-bar .work-btn {
    font-size: 0.9rem;
  }
}

/* --- Legacy Work Section Specific Controls --- */
.work-controls {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  background: #FAFAFA;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.work-controls .work-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.work-controls .work-btn-row .work-btn {
  flex: 1;
  min-width: 140px;
  min-height: 44px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  padding: 10px 16px;
}

.work-btn-primary {
  background: var(--brand-gold);
  color: white;
}

.work-btn-primary:hover {
  background: #C4952E;
  transform: translateY(-1px);
}

.work-btn-secondary {
  background: var(--brand-navy);
  color: white;
}

.work-btn-secondary:hover {
  background: var(--brand-navy-light);
}

.work-btn-success {
  background: #16A34A;
  color: white;
}

.work-btn-success:hover {
  background: #15803D;
  transform: translateY(-1px);
}

.work-btn:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
  transform: none;
}

.work-textarea-area {
  padding: 10px 12px;
  border-top: 1px solid var(--border-light);
  background: #FAFAFA;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.work-textarea-area textarea {
  flex: 1;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--sans);
  font-size: 0.9rem;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  outline: none;
  transition: border 0.2s;
}

.work-textarea-area textarea:focus {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 2px rgba(175, 144, 91, 0.1);
}

/* --- Typing Indicator --- */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
  align-items: center;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #CBD5E1;
  animation: typing 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* --- Review Panel Skeleton --- */
@keyframes skeletonShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.review-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.review-skeleton .skeleton-loading-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-muted);
  padding: 8px 0;
}

.review-skeleton .skeleton-progress-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0;
  margin-bottom: 4px;
}

.review-skeleton .skeleton-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.review-skeleton .skeleton-line {
  width: 24px;
  height: 2px;
  background: #E2E8F0;
  border-radius: 1px;
}

/* Skeleton columns: matches .work-review-columns layout */
.review-skeleton .skeleton-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media(min-width: 768px) {
  .review-skeleton .skeleton-columns {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }
}

.review-skeleton .skeleton-left,
.review-skeleton .skeleton-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.review-skeleton .skeleton-card {
  border-radius: 10px;
  padding: 16px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
}

.review-skeleton .skeleton-critique {
  border-left: 4px solid #FECACA;
}

.review-skeleton .skeleton-draft {
  border-left: 4px solid #BBF7D0;
}

.review-skeleton .skeleton-questions {
  border-left: 4px solid #FDE68A;
}

.review-skeleton .skeleton-action {
  padding: 4px 0;
}

.review-skeleton .skeleton-bar {
  border-radius: 4px;
  background: linear-gradient(90deg, #E2E8F0 25%, #F1F5F9 50%, #E2E8F0 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
}

.review-skeleton .skeleton-bar:nth-child(1) { animation-delay: 0s; }
.review-skeleton .skeleton-bar:nth-child(2) { animation-delay: 0.05s; }
.review-skeleton .skeleton-bar:nth-child(3) { animation-delay: 0.1s; }
.review-skeleton .skeleton-bar:nth-child(4) { animation-delay: 0.15s; }
.review-skeleton .skeleton-bar:nth-child(5) { animation-delay: 0.2s; }
.review-skeleton .skeleton-bar:nth-child(6) { animation-delay: 0.25s; }
.review-skeleton .skeleton-bar:nth-child(7) { animation-delay: 0.3s; }
