/*
 * Wantable Buying Intelligence — Application Styles
 *
 * Propshaft serves these directly. Tailwind handles most styling via utility classes.
 * This file contains non-Tailwind overrides and animations.
 */

/* Turbo loading progress bar — bold copper bar, highly visible */
.turbo-progress-bar {
  background: linear-gradient(90deg, #B45309, #D97706, #B45309);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  height: 6px;
  box-shadow: 0 0 12px rgba(180, 83, 9, 0.5), 0 2px 4px rgba(180, 83, 9, 0.3);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Disabled button state for form submissions */
button[disabled],
input[type="submit"][disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Smooth transitions for Turbo Frame loads */
turbo-frame {
  display: block;
}

/* Flash message fade animation */
@keyframes flashFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-message {
  animation: flashFadeIn 0.3s ease-out;
}

/* Modern tooltip — dark floating bubble on hover */
.tip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  z-index: 1;
}

.tip-trigger {
  font-weight: 600;
  border-bottom: 1.5px dashed currentColor;
  cursor: help;
  opacity: 0.85;
}

.tip-trigger:hover {
  opacity: 1;
}

.tip-bubble {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #1f2937;
  color: #f9fafb;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: normal;
  max-width: 280px;
  text-align: left;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

/* Arrow */
.tip-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
}

.tip-wrapper:hover .tip-bubble {
  visibility: visible;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Row states for reorder toggle (skipped rows dim) */
tr.row-skipped {
  background-color: #f9fafb !important;
  opacity: 0.5;
}
tr.row-skipped td {
  text-decoration: line-through;
  color: #9ca3af;
}

/* Row states for PO cancel (cancelled rows) */
tr.row-cancelled {
  background-color: #fef2f2 !important;
  opacity: 0.6;
}
tr.row-cancelled td {
  text-decoration: line-through;
  color: #b91c1c;
}

/* Admin dropdown menu */
.admin-dropdown {
  position: relative;
}
.admin-dropdown-menu {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 200px;
  background: #1f2937;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 50;
  transition: opacity 0.15s ease, visibility 0.15s;
  padding: 4px 0;
}
.admin-dropdown:hover .admin-dropdown-menu {
  visibility: visible;
  opacity: 1;
}
.admin-dropdown-menu a {
  display: block;
  padding: 8px 16px;
  font-size: 14px;
  color: #f9fafb;
  transition: background-color 0.15s;
}
.admin-dropdown-menu a:hover {
  background-color: #374151;
}
/* button_to forms inside dropdown menus (e.g. Sign Out in the account menu) */
.admin-dropdown-menu form {
  margin: 0;
}
.admin-dropdown-menu form button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 16px;
  font-size: 14px;
  color: #f9fafb;
  background: none;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s;
}
.admin-dropdown-menu form button:hover {
  background-color: #374151;
}

/* Login page — fashion image slideshow (35s cycle, 5 images) */
@keyframes loginSlideshow {
  0%   { opacity: 0; }
  4%   { opacity: 1; }
  20%  { opacity: 1; }
  24%  { opacity: 0; }
  100% { opacity: 0; }
}

.login-slide {
  animation: loginSlideshow 35s infinite;
  opacity: 0;
}
.login-slide:nth-child(1) { animation-delay: 0s; }
.login-slide:nth-child(2) { animation-delay: 7s; }
.login-slide:nth-child(3) { animation-delay: 14s; }
.login-slide:nth-child(4) { animation-delay: 21s; }
.login-slide:nth-child(5) { animation-delay: 28s; }

/* ── Sidebar structure ── */
#assistant-sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; z-index: 40;
  pointer-events: none;
}

.sidebar-tab {
  pointer-events: auto; position: fixed; top: 50%; left: 0; z-index: 41;
  transform: translateY(-50%);
  width: 20px; min-height: 48px; padding: 10px 0; background: #292524; color: rgba(255,255,255,0.7);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border-radius: 0 8px 8px 0; cursor: pointer;
  transition: all 0.2s; box-shadow: 2px 0 8px rgba(0,0,0,0.1);
}
.sidebar-tab:hover { background: #3a3836; color: #fff; width: 24px; }
.sidebar-tab svg { transition: transform 0.2s; }

.sidebar-tab-label {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 9px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  user-select: none; white-space: nowrap;
}

/* Welcome-back badge — visible only while a greeting is waiting */
.sidebar-tab-badge {
  display: none; position: absolute; top: -4px; right: -4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #B45309; box-shadow: 0 0 0 2px #fafafa;
}
.sidebar-tab.has-greeting .sidebar-tab-badge { display: block; animation: wb-badge-pulse 2s ease-in-out infinite; }
@keyframes wb-badge-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.7; }
}

/* Welcome-back rail callout — greeting sits on the rail, "Chat" opens the sidebar */
.sidebar-greeting-callout {
  pointer-events: auto; position: fixed; left: 32px; top: 50%; z-index: 41;
  transform: translateY(-50%);
  width: 250px; background: #fff; border: 1px solid #e5e5e5; border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 12px 14px;
}
.sidebar-greeting-text { font-size: 12px; line-height: 1.5; color: #292524; margin-bottom: 8px; padding-right: 14px; }
.sidebar-greeting-chat {
  font-size: 11px; font-weight: 600; padding: 5px 14px; border-radius: 14px;
  background: #292524; color: #fff; border: none; cursor: pointer; transition: background 0.15s;
}
.sidebar-greeting-chat:hover { background: #B45309; }
.sidebar-greeting-dismiss {
  position: absolute; top: 6px; right: 8px; background: none; border: none;
  color: #a3a3a3; font-size: 14px; line-height: 1; cursor: pointer; padding: 2px;
}
.sidebar-greeting-dismiss:hover { color: #525252; }

.sidebar-panel {
  pointer-events: auto; position: fixed; top: 0; left: 0; height: 100vh;
  width: 340px; background: #fafafa; border-right: 1px solid #e5e7eb;
  display: flex; flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 2px 0 16px rgba(0,0,0,0.08);
}
.sidebar-panel.visible { transform: translateX(0); }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; min-height: 64px; background: #292524; color: #fff; flex-shrink: 0;
}
.sidebar-close-btn {
  color: rgba(255,255,255,0.5); background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: 6px; transition: all 0.15s;
}
.sidebar-close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Chat messages: Google Chat style ── */
.chat-msg { margin-bottom: 2px; padding: 0 12px; }
.chat-msg-row { display: flex; align-items: flex-start; gap: 8px; }
.chat-msg-user .chat-msg-row { flex-direction: row-reverse; }
.chat-avatar-slot { width: 28px; flex-shrink: 0; padding-top: 2px; }
.chat-bubble-wrap { max-width: 260px; min-width: 0; }
.chat-sender { display: flex; align-items: baseline; gap: 6px; margin-bottom: 1px; padding: 6px 2px 0; }
.chat-msg-user .chat-sender { flex-direction: row-reverse; }
.chat-sender-name { font-size: 12px; font-weight: 600; color: #292524; }
.chat-sender-time { font-size: 10px; color: #9ca3af; }
.chat-bubble {
  padding: 8px 12px; font-size: 13px; line-height: 1.5;
  word-wrap: break-word; overflow-wrap: break-word;
}
.chat-bubble-user {
  background: #292524; color: #fff; border-radius: 18px 18px 4px 18px;
}
.chat-bubble-assistant {
  background: #fff; border: 1px solid #e8e8e8; color: #1f2937;
  border-radius: 18px 18px 18px 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.chat-bubble-assistant strong { font-weight: 600; }
.chat-bubble-assistant code { background: #f3f4f6; padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.chat-bubble-assistant a { color: #B45309; text-decoration: underline; }
.chat-bubble-assistant ul, .chat-bubble-assistant ol { margin: 4px 0; padding-left: 16px; }
.chat-bubble-assistant li { margin: 2px 0; }
.chat-avatar-user {
  width: 28px; height: 28px; border-radius: 50%; background: #6b7280; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.chat-avatar-bot {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
}
.chat-suggestions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chat-chip {
  font-size: 11px; padding: 5px 12px; border-radius: 14px; border: 1px solid #d4d4d4;
  color: #525252; background: #fff; cursor: pointer; transition: all 0.15s;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.chat-chip:hover { border-color: #B45309; color: #B45309; box-shadow: 0 1px 4px rgba(180,83,9,0.12); }

/* ── Sidebar body push ── */
body { transition: padding-left 0.2s cubic-bezier(0.4,0,0.2,1); }
body.sidebar-open { padding-left: 340px; }
