/**
 * Solie Chat Widget Styles
 * Solveit Frontend Refactoring - Phase 4
 * 
 * Extracted from base.html for better maintainability
 */

/* ───────── Solie 호출 버튼 ───────── */
#solie-toggle {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  -webkit-tap-highlight-color: transparent;
  border: none;
  outline: none;
  overflow: hidden;
  box-shadow: 
    0 8px 32px rgba(102, 126, 234, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.1),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* 홀로그램 효과 */
#solie-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 25%,
    transparent 75%,
    rgba(255, 255, 255, 0.1) 100%
  );
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#solie-toggle:hover::before {
  opacity: 1;
}

/* 펄싱 효과 */
#solie-toggle::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 50%;
  z-index: -1;
  opacity: 0;
  animation: pulse-ring 3s infinite;
}

@keyframes pulse-ring {
  0% {
    opacity: 0;
    transform: scale(1);
  }
  15% {
    opacity: 0.6;
    transform: scale(1.1);
  }
  30% {
    opacity: 0.3;
    transform: scale(1.2);
  }
  100% {
    opacity: 0;
    transform: scale(1.3);
  }
}

/* 아이콘 스타일 */
#solie-toggle img {
  width: 24px;
  height: 24px;
  filter: brightness(0) invert(1);
  opacity: 0.95;
  transition: all 0.3s ease;
  z-index: 1;
}

/* 호버 효과 */
#solie-toggle:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 
    0 12px 48px rgba(102, 126, 234, 0.6),
    0 4px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 2px rgba(255, 255, 255, 0.4);
}

#solie-toggle:hover img {
  transform: scale(1.1);
}

/* 클릭 효과 */
#solie-toggle:active {
  transform: translateY(-2px) scale(0.98);
  box-shadow: 
    0 6px 24px rgba(102, 126, 234, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 확장 애니메이션 */
#solie-toggle.expand {
  animation: solie-expand 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes solie-expand {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.3);
    filter: brightness(1.2);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

/* 반짝이는 효과 */
#solie-toggle .sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
  opacity: 0;
  animation: sparkle 2s infinite;
}

#solie-toggle .sparkle:nth-child(1) {
  top: 15%;
  left: 25%;
  animation-delay: 0s;
}

#solie-toggle .sparkle:nth-child(2) {
  top: 70%;
  right: 20%;
  animation-delay: 0.7s;
}

#solie-toggle .sparkle:nth-child(3) {
  bottom: 20%;
  left: 70%;
  animation-delay: 1.4s;
}

@keyframes sparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* 풀스크린 오버레이 */
#solie-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#solie-overlay.show {
  display: block;
  opacity: 1;
}

/* 모바일 전용 채팅창 */
#solie-chat {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70vh;
  max-height: 600px;
  background: white;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
#solie-chat.show {
  display: flex;
  transform: translateY(0);
}

/* 드래그 핸들 */
.chat-handle {
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 12px auto 8px;
  cursor: grab;
}
.chat-handle:active {
  cursor: grabbing;
}

/* 채팅 헤더 */
.solie-chat-header {
  padding: 16px 20px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid #f0f0f0;
}
.solie-chat-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.solie-chat-header .status-dot {
  width: 8px;
  height: 8px;
  background: #4caf50;
  border-radius: 50%;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

#solie-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: #f5f5f5;
  border: none;
  color: #666;
  font-size: 1.4rem;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#solie-close:active {
  background: #e0e0e0;
  transform: scale(0.95);
}

/* 메시지 영역 */
.solie-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #fafafa;
  -webkit-overflow-scrolling: touch;
}

/* 모바일 스크롤바 숨김 */
.solie-chat-messages::-webkit-scrollbar {
  display: none;
}
.solie-chat-messages {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.solie-chat-message {
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  max-width: 85%;
  position: relative;
  word-wrap: break-word;
  animation: messageSlide 0.3s ease-out;
}
@keyframes messageSlide {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.solie-chat-message.user {
  background: var(--color-primary);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.solie-chat-message.ai {
  background: white;
  color: var(--color-text);
  margin-right: auto;
  border-bottom-left-radius: 4px;
  border: 1px solid var(--color-border);
}

/* 타이핑 인디케이터 */
.solie-typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  margin-bottom: 12px;
  max-width: 85%;
  border: 1px solid var(--color-border);
}
.solie-typing-indicator .typing-text {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin-right: 8px;
}
.solie-typing-dot {
  width: 6px;
  height: 6px;
  background: #bbb;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}
.solie-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.solie-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
  40% { transform: scale(1.2); opacity: 1; }
}

/* 모바일 최적화 입력 영역 */
.solie-input-area {
  display: flex;
  gap: 8px;
  padding: 16px;
  background: white;
  border-top: 1px solid #f0f0f0;
  align-items: flex-end;
  position: relative;
}

.solie-input-container {
  flex: 1;
  position: relative;
}

.solie-input-area input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 20px;
  font-size: 16px; /* iOS 줌 방지 */
  font-family: inherit;
  background: #f8f9fa;
  outline: none;
  transition: all 0.2s;
  -webkit-appearance: none;
}
.solie-input-area input[type="text"]:focus {
  border-color: var(--color-primary);
  background: white;
}

.solie-file-upload-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 1.2rem;
  -webkit-tap-highlight-color: transparent;
}
.solie-file-upload-label:active {
  background: var(--color-primary);
  color: white;
  transform: scale(0.95);
}

.solie-send-button {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.solie-send-button:active {
  background: #1976d2;
  transform: scale(0.95);
}
.solie-send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 파일 미리보기 - 모바일 최적화 */
.solie-file-preview {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  display: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.solie-file-preview.show {
  display: block;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.solie-file-preview img {
  max-width: 80px;
  max-height: 80px;
  border-radius: 8px;
  object-fit: cover;
}
.solie-file-preview .file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.solie-file-preview .file-name {
  font-size: 0.85rem;
  color: var(--color-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.solie-file-preview .remove-file {
  background: #ff4757;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  -webkit-tap-highlight-color: transparent;
}

/* 모바일 세이프 에어리어 대응 */
@supports (bottom: env(safe-area-inset-bottom)) {
  .solie-input-area {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* 키보드 대응 */
@media (max-height: 500px) {
  #solie-chat {
    height: 100vh;
    max-height: none;
    border-radius: 0;
  }
  .chat-handle {
    display: none;
  }
}

/* 아주 작은 화면 대응 */
@media (max-width: 320px) {
  .solie-input-area {
    padding: 12px;
    gap: 6px;
  }
  .solie-file-upload-label,
  .solie-send-button {
    width: 40px;
    height: 40px;
  }
  .solie-input-area input[type="text"] {
    padding: 10px 14px;
  }
}
