/* ========================================
   kaufAInhorn AI Assistant Unified Styles
   ======================================== */

/* Overlay for modal effect */
.ai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  z-index: 2550;
}

.ai-overlay.open {
  display: block;
}

/* Main chat panel */
.ai-panel {
  position: fixed;
  right: 16px;
  bottom: calc(var(--bottom-nav-height, 60px) + 64px);
  width: min(92vw, 420px);
  max-height: 60vh;
  display: none;
  flex-direction: column;
  background: #000;
  color: #eee;
  border: 1px solid #1f1f1f;
  border-radius: 12px;
  z-index: 2600;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.ai-panel.open {
  display: flex;
}

.ai-panel .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #1f1f1f;
}

.ai-panel .body {
  padding: 10px 12px;
  overflow: auto;
  flex: 1 1 auto;
}

.ai-panel .msg {
  background: #0e0e0e;
  border: 1px solid #1f1f1f;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 6px 0;
  white-space: pre-wrap;
}

.ai-panel .msg.me {
  background: #0a2236;
  border-color: #123a56;
}

.ai-panel form {
  display: flex;
  gap: 8px;
  border-top: 1px solid #1f1f1f;
  padding: 8px;
}

.ai-panel input[type="text"] {
  flex: 1 1 auto;
  background: #0e0e0e;
  color: #fff;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px;
  font-family: inherit;
  font-size: 14px;
}

.ai-panel input[type="text"]:focus {
  outline: none;
  border-color: #1e88e5;
}

/* ========================================
   Unified Button System
   ======================================== */

.ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ke-btn-height-sm, 36px);
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.ai-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.ai-btn:active {
  transform: translateY(0);
}

.ai-btn:focus {
  outline: 2px solid #1e88e5;
  outline-offset: 2px;
}

.ai-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Primary button (blue, main action) */
.ai-btn-primary {
  background-color: #1e88e5;
  color: #fff;
  border-color: #1e88e5;
}

.ai-btn-primary:hover {
  background-color: #1565c0;
  border-color: #1565c0;
}

/* Success button (green, add/accept) */
.ai-btn-success {
  background-color: #2e7d32;
  color: #fff;
  border-color: #2e7d32;
}

.ai-btn-success:hover {
  background-color: #1b5e20;
  border-color: #1b5e20;
}

/* Secondary button (dark, alternative action) */
.ai-btn-secondary {
  background-color: #2a3a5a;
  color: #fff;
  border-color: #3a4a7a;
}

.ai-btn-secondary:hover {
  background-color: #3a4a7a;
  border-color: #4a5a8a;
}

/* Outline button (transparent, dismiss/skip) */
.ai-btn-outline {
  background-color: transparent;
  color: #fff;
  border: 1px solid #444;
}

.ai-btn-outline:hover {
  background-color: #222;
  border-color: #666;
}

/* Send button (primary action in form) */
.ai-btn-send {
  background-color: #1e88e5;
  color: #fff;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
}

.ai-btn-send:hover {
  background-color: #1565c0;
}

/* ========================================
   Rich Content Components
   ======================================== */

.ai-ingredient-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  background: #0a0a0a;
  border: 1px solid #1a1a1a;
  border-radius: 8px;
}

.ai-ingredient-info {
  flex: 1 1 auto;
  min-width: 0;
}

.ai-ingredient-name {
  font-weight: 700;
  color: #fff;
  font-size: 14px;
}

.ai-ingredient-detail {
  color: #aaa;
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.3;
}

.ai-ingredient-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  min-width: 90px;
}

.ai-ingredient-actions .ai-btn {
  width: 100%;
  font-size: 12px;
  padding: 6px 8px;
  height: auto;
}

.ai-ingredient-image {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  border: 1px solid #222;
  flex-shrink: 0;
}

/* Badge/chip styles for status indicators */
.ai-badge {
  display: inline-block;
  background: #333;
  color: #ddd;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 11px;
  margin-right: 4px;
  margin-bottom: 2px;
}

.ai-badge.always-in-stock {
  background: #1b5e20;
  color: #fff;
}

.ai-badge.missing {
  background: #7b1fa2;
  color: #fff;
}

.ai-badge.complete {
  background: #0d47a1;
  color: #fff;
}

/* Suggestion chips container */
.ai-suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ai-suggestion-chip {
  display: inline-block;
}

/* ========================================
   Mobile Responsive
   ======================================== */

@media (max-width: 680px) {
  .ai-panel {
    left: 8px;
    right: 8px;
    width: auto;
    max-height: 70vh;
  }
  
  .ai-ingredient-row {
    flex-wrap: wrap;
  }
  
  .ai-ingredient-actions {
    width: 100%;
    flex-direction: row;
    justify-content: flex-end;
  }
  
  .ai-ingredient-actions .ai-btn {
    flex: 0 1 auto;
    min-width: 80px;
  }
}

/* ========================================
   Accessibility & Focus States
   ======================================== */

.ai-btn:focus-visible {
  outline: 2px solid #1e88e5;
  outline-offset: 2px;
}

/* Ensure sufficient color contrast for readability */
.ai-panel {
  --foreground: #eee;
  --background: #000;
  --border: #1f1f1f;
  --accent: #1e88e5;
}

/* Link styling within AI messages */
.ai-panel a {
  color: #8ab4ff;
  text-decoration: none;
  transition: color 0.2s ease;
}

.ai-panel a:hover {
  color: #b0d4ff;
  text-decoration: underline;
}

.ai-panel a:focus {
  outline: 2px solid #1e88e5;
  outline-offset: 2px;
}
