/**
 * CaribeZyne Chat Widget Styles - WordPress Plugin Version
 */

:root {
  --primary-color: #019599;
  --primary-light: #4ECDC4;
  --surface: #ffffff;
  --background: #f8f9fa;
  --border: #e5e5e5;
  --text: #333333;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --shadow: rgba(0, 0, 0, 0.1);
  --error: #ff4444;
  --success: #4ECDC4;
}

/* Widget Container */
.chat-widget {
  position: fixed;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

.chat-widget.bottom-right {
  bottom: 20px;
  right: 20px;
}

.chat-widget.bottom-left {
  bottom: 20px;
  left: 20px;
}

.chat-widget.top-right {
  top: 20px;
  right: 20px;
}

.chat-widget.top-left {
  top: 20px;
  left: 20px;
}

/* Chat Trigger Button */
.chat-trigger {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 25px;
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  transition: all 0.3s ease;
  min-width: 60px;
  justify-content: center;
}

.chat-trigger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow);
  background: color-mix(in srgb, var(--primary-color) 90%, black);
}

.chat-trigger.active {
  border-radius: 12px 12px 0 0;
}

.chat-trigger-text {
  font-weight: 500;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .chat-trigger-text {
    display: none;
  }
  
  .chat-trigger {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    padding: 16px;
  }
}

/* Chat Window */
.chat-window {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 380px;
  height: 500px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 8px 32px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease-out;
}

@media (max-width: 480px) {
  .chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    animation: slideUpMobile 0.3s ease-out;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUpMobile {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chat Header */
.chat-header {
  background: var(--primary-color);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #666;
}

.status-dot.connected {
  background: #4ade80;
}

.status-dot.disconnected {
  background: #ef4444;
}

.chat-close {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.chat-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Chat Content */
.chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Room Selector */
.chat-room-selector {
  padding: 24px;
  text-align: center;
}

.chat-room-selector h4 {
  margin: 0 0 20px 0;
  color: var(--text);
  font-size: 18px;
}

.room-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.room-option {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  transition: all 0.2s;
  width: 100%;
}

.room-option:hover {
  border-color: var(--primary-color);
  background: color-mix(in srgb, var(--primary-color) 5%, white);
}

.room-option svg {
  color: var(--primary-color);
  flex-shrink: 0;
}

.option-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.option-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Login Prompt */
.login-prompt {
  text-align: center;
  padding: 20px;
}

.login-prompt h4 {
  margin: 0 0 12px 0;
  color: var(--text);
}

.login-prompt p {
  color: var(--text-secondary);
  margin: 0 0 20px 0;
}

.login-button {
  background: var(--primary-color);
  color: white;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 500;
  transition: background 0.2s;
}

.login-button:hover {
  background: color-mix(in srgb, var(--primary-color) 90%, black);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messages-container::-webkit-scrollbar {
  width: 6px;
}

.messages-container::-webkit-scrollbar-track {
  background: var(--background);
}

.messages-container::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
}

/* Messages */
.message {
  display: flex;
  margin-bottom: 8px;
}

.message.own {
  justify-content: flex-end;
}

.message.other {
  justify-content: flex-start;
}

.message.system {
  justify-content: center;
}

.message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  position: relative;
}

.message.own .message-content {
  background: var(--primary-color);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.other .message-content {
  background: var(--background);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.message.system .message-content {
  background: var(--background);
  color: var(--text-secondary);
  border-radius: 12px;
  max-width: 90%;
  text-align: center;
  font-style: italic;
  font-size: 13px;
}

.message-author {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--primary-color);
}

.message-text {
  margin-bottom: 4px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-time {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.message.own .message-time {
  color: rgba(255, 255, 255, 0.8);
}

.message.other .message-time {
  color: var(--text-tertiary);
}

.edited-indicator {
  font-style: italic;
  margin-left: 4px;
}

/* Message Media */
.message-media {
  margin-top: 8px;
}

.message-media img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.message-media img:hover {
  opacity: 0.9;
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 12px;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: typingPulse 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingPulse {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(1);
  }
  30% {
    opacity: 1;
    transform: scale(1.3);
  }
}

/* Chat Composer */
.chat-composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 16px;
}

.composer-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 12px;
}

.composer-input textarea {
  flex: 1;
  border: none;
  background: none;
  resize: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  min-height: 20px;
  max-height: 100px;
  line-height: 20px;
}

.composer-input textarea::placeholder {
  color: var(--text-tertiary);
}

.send-button {
  background: var(--primary-color);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary-color) 90%, black);
  transform: scale(1.05);
}

.send-button:disabled {
  background: var(--border);
  cursor: not-allowed;
  opacity: 0.6;
}

.send-button svg {
  color: white;
}

/* Error Messages */
.chat-error {
  background: var(--error);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 8px 0;
  font-size: 12px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .chat-widget.bottom-right,
  .chat-widget.bottom-left {
    bottom: 10px;
    right: 10px;
    left: 10px;
  }
  
  .chat-widget.top-right,
  .chat-widget.top-left {
    top: 10px;
    right: 10px;
    left: 10px;
  }
  
  .chat-window {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    bottom: 0 !important;
  }
  
  .chat-trigger {
    width: 100%;
    justify-content: center;
    border-radius: 12px;
  }
  
  .chat-trigger-text {
    display: block !important;
  }
}

/* WordPress Admin Styles */
.chat-admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

.stat-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stat-card h3 {
  margin: 0 0 10px 0;
  color: #666;
  font-size: 14px;
  text-transform: uppercase;
}

.stat-number {
  font-size: 32px;
  font-weight: bold;
  color: var(--primary-color);
}

/* Accessibility */
.chat-trigger:focus,
.chat-close:focus,
.send-button:focus,
.room-option:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.chat-trigger:focus-visible,
.chat-close:focus-visible,
.send-button:focus-visible,
.room-option:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .chat-trigger,
  .chat-window,
  .message-content,
  .room-option {
    transition: none;
    animation: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .chat-trigger {
    border: 2px solid white;
  }
  
  .message-content {
    border: 1px solid var(--text);
  }
}
