/* ── AI Chat Result Cards — структурированные карточки tool results ────── */

.rcard {
  background: var(--surface-2, #f8f9fa);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 8px 0;
  font-size: 13px;
  max-width: 680px;
  overflow: hidden;
}

.rcard__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.rcard__icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.rcard__icon--price     { background: #e3f2fd; color: #1565c0; }
.rcard__icon--margin    { background: #fff3e0; color: #e65100; }
.rcard__icon--position  { background: #e8f5e9; color: #2e7d32; }
.rcard__icon--norm      { background: #f3e5f5; color: #7b1fa2; }
.rcard__icon--estimate  { background: #e0f2f1; color: #00695c; }
.rcard__icon--supplier  { background: #fce4ec; color: #c62828; }
.rcard__icon--file      { background: #e8eaf6; color: #283593; }
.rcard__icon--rfq       { background: #fff8e1; color: #f57f17; }
.rcard__icon--mail      { background: #e1f5fe; color: #0277bd; }
.rcard__icon--compliance{ background: #fbe9e7; color: #bf360c; }
.rcard__icon--calibrate { background: #f1f8e9; color: #558b2f; }

.rcard__title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary, #222);
}

.rcard__subtitle {
  font-size: 12px;
  color: var(--text-secondary, #888);
  margin-left: auto;
}

.rcard__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.rcard__metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rcard__metric-label {
  font-size: 11px;
  color: var(--text-secondary, #999);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.rcard__metric-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #222);
}

.rcard__badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.rcard__badge--info     { background: #e3f2fd; color: #1565c0; }
.rcard__badge--success  { background: #e8f5e9; color: #2e7d32; }
.rcard__badge--warning  { background: #fff3e0; color: #e65100; }
.rcard__badge--danger   { background: #ffebee; color: #c62828; }
.rcard__badge--neutral  { background: #f5f5f5; color: #666; }

.rcard__verdict {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  margin-top: 4px;
}

.rcard__verdict--success { background: #e8f5e9; color: #2e7d32; }
.rcard__verdict--warning { background: #fff3e0; color: #e65100; }
.rcard__verdict--danger  { background: #ffebee; color: #c62828; }

.rcard__table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 12px;
}

.rcard__table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary, #888);
  border-bottom: 1px solid var(--border, #e0e0e0);
  padding: 5px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.rcard__table th[align="right"],
.rcard__table td[align="right"] {
  text-align: right;
}

.rcard__table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
  color: var(--text-primary, #333);
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rcard__table tr:last-child td {
  border-bottom: none;
}

.rcard__empty {
  color: var(--text-secondary, #999);
  font-style: italic;
  padding: 12px 0;
  text-align: center;
}

.rcard__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.rcard__action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border, #ddd);
  background: var(--surface-1, #fff);
  color: var(--text-primary, #333);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.rcard__action-btn:hover {
  background: var(--primary-bg, #e3f2fd);
  border-color: var(--primary, #1976d2);
  color: var(--primary, #1976d2);
}

@media (max-width: 480px) {
  .rcard { padding: 10px 12px; }
  .rcard__metrics { gap: 6px; }
  .rcard__metric-value { font-size: 13px; }
  .rcard__table { font-size: 11px; }
  .rcard__table td { max-width: 160px; }
}

/* ── Phase 3: Inline Panels (раскрывающиеся панели в чате) ─────────────── */

.ipanel {
  background: var(--surface-2, #f8f9fa);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 10px;
  margin: 8px 0;
  max-width: 680px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.ipanel[open] {
  border-color: var(--primary, #1976d2);
}

.ipanel__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary, #222);
  list-style: none;
  transition: background 0.15s;
}

.ipanel__summary::-webkit-details-marker {
  display: none;
}

.ipanel__summary::marker {
  content: '';
}

.ipanel__summary:hover {
  background: var(--primary-bg, #e3f2fd);
}

.ipanel__chevron {
  transition: transform 0.2s;
  flex-shrink: 0;
  color: var(--text-secondary, #888);
}

.ipanel[open] > .ipanel__summary .ipanel__chevron {
  transform: rotate(90deg);
}

.ipanel__title {
  font-weight: 600;
  font-size: 13px;
}

.ipanel__subtitle {
  font-size: 11px;
  color: var(--text-secondary, #888);
  margin-left: auto;
}

.ipanel__body {
  padding: 0 14px 14px;
  font-size: 13px;
  color: var(--text-primary, #333);
  line-height: 1.5;
}

.ipanel__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.ipanel__metric {
  font-size: 11px;
  color: var(--text-secondary, #999);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ipanel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ── Dropzone (для UBD upload / converter) ── */

.ipanel-dropzone {
  border: 2px dashed var(--border, #ccc);
  border-radius: 8px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.ipanel-dropzone:hover {
  border-color: var(--primary, #1976d2);
  background: var(--primary-bg, #e3f2fd);
}

.ipanel-dropzone__icon {
  font-size: 28px;
  color: var(--text-secondary, #888);
  margin-bottom: 6px;
}

.ipanel-dropzone__text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #333);
}

.ipanel-dropzone__hint {
  font-size: 11px;
  color: var(--text-secondary, #999);
  margin-top: 4px;
}

/* ── Converter formats ── */

.ipanel-converter__formats {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

/* ── Mail compose ── */

.ipanel-compose__recipients {
  font-size: 12px;
  color: var(--text-secondary, #666);
  margin-bottom: 8px;
}

.ipanel-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.ipanel-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 8px;
  resize: vertical;
  box-sizing: border-box;
  font-family: inherit;
}

/* ── Shared buttons ── */

.ipanel-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border, #ddd);
  background: var(--surface-1, #fff);
  color: var(--text-primary, #333);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.ipanel-btn:hover {
  background: var(--primary-bg, #e3f2fd);
  border-color: var(--primary, #1976d2);
  color: var(--primary, #1976d2);
}

.ipanel-btn--primary {
  background: var(--primary, #1976d2);
  border-color: var(--primary, #1976d2);
  color: #fff;
}

.ipanel-btn--primary:hover {
  background: var(--primary-dark, #1565c0);
  border-color: var(--primary-dark, #1565c0);
  color: #fff;
}

/* ── Table inside panel ── */

.ipanel-table-wrap {
  overflow-x: auto;
}

.ipanel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ipanel-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary, #888);
  border-bottom: 1px solid var(--border, #e0e0e0);
  padding: 5px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.ipanel-table th[align="right"],
.ipanel-table td[align="right"] {
  text-align: right;
}

.ipanel-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
  color: var(--text-primary, #333);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ipanel-table tr:last-child td {
  border-bottom: none;
}

/* ── Phase 4: Chain Progress Milestone ── */

.rcard--chain {
  border-left: 3px solid var(--primary, #1976d2);
}

.rcard-progress {
  width: 100%;
  height: 6px;
  background: var(--border, #e0e0e0);
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}

.rcard-progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary, #1976d2), var(--primary-dark, #1565c0));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.rcard__icon--chain {
  background: #e8eaf6;
  color: #283593;
}

/* ── Mobile adjustments ── */

@media (max-width: 480px) {
  .ipanel { margin: 6px 0; }
  .ipanel__summary { padding: 8px 12px; font-size: 12px; }
  .ipanel__body { padding: 0 12px 12px; }
  .ipanel-dropzone { padding: 16px 12px; }
  .ipanel-table { font-size: 11px; }
  .ipanel-table td { max-width: 140px; }
}

/* ── Free Timer — индикатор оставшегося бесплатного времени ──────────── */

.ai-chat-free-timer {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  margin-left: 12px;
  flex-shrink: 0;
}

.ai-chat-free-timer--ok {
  background: #e8f5e9;
  color: #2e7d32;
}

.ai-chat-free-timer--warning {
  background: #fff3e0;
  color: #e65100;
  animation: timer-pulse 2s ease-in-out infinite;
}

.ai-chat-free-timer--danger {
  background: #ffebee;
  color: #c62828;
  animation: timer-pulse 1s ease-in-out infinite;
}

.ai-chat-free-timer__icon {
  font-size: 14px;
}

.ai-chat-free-timer__time {
  font-weight: 700;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.ai-chat-free-timer__label {
  font-size: 11px;
  opacity: 0.8;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
