/* USTIA SMB Chat Widget — MICO Theme */
/* Pure CSS, no dependencies */

:root {
  --ustia-primary: #1a1a2e;
  --ustia-secondary: #16213e;
  --ustia-accent: #e94560;
  --ustia-accent-soft: #ff6b6b;
  --ustia-text: #ffffff;
  --ustia-text-muted: #a0a0a0;
  --ustia-bg: #0f0f1a;
  --ustia-input-bg: #1a1a2e;
  --ustia-message-user: #e94560;
  --ustia-message-agent: #2a2a4a;
  --ustia-border: #2a2a4a;
  --ustia-radius: 12px;
  --ustia-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--ustia-font);
  background: var(--ustia-bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Widget Container */
.ustia-widget {
  width: 380px;
  max-width: 100vw;
  height: 600px;
  max-height: 90vh;
  background: var(--ustia-bg);
  border-radius: var(--ustia-radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.ustia-widget.minimized {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Header */
.ustia-header {
  background: linear-gradient(135deg, var(--ustia-primary) 0%, var(--ustia-secondary) 100%);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--ustia-border);
}

.ustia-header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ustia-logo {
  font-size: 28px;
}

.ustia-header-text {
  display: flex;
  flex-direction: column;
}

.ustia-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--ustia-text);
  letter-spacing: 0.5px;
}

.ustia-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ustia-text-muted);
}

.ustia-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #888;
}

.ustia-status-dot.online {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.ustia-status-dot.sleeping {
  background: #f59e0b;
  animation: pulse 2s infinite;
}

.ustia-status-dot.busy {
  background: #ef4444;
}

.ustia-status-dot.offline {
  background: #6b7280;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.ustia-minimize {
  background: transparent;
  border: none;
  color: var(--ustia-text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.ustia-minimize:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Messages Area */
.ustia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ustia-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--ustia-text);
}

.ustia-welcome-emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

.ustia-welcome-text {
  font-size: 16px;
  margin-bottom: 8px;
}

.ustia-welcome-sub {
  font-size: 14px;
  color: var(--ustia-text-muted);
}

/* Message Bubbles */
.ustia-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--ustia-radius);
  line-height: 1.5;
  font-size: 14px;
  word-wrap: break-word;
}

.ustia-message.agent {
  background: var(--ustia-message-agent);
  color: var(--ustia-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.ustia-message.user {
  background: var(--ustia-message-user);
  color: var(--ustia-text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ustia-message-time {
  font-size: 10px;
  color: var(--ustia-text-muted);
  margin-top: 4px;
}

/* Typing Indicator */
.ustia-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--ustia-message-agent);
  border-radius: var(--ustia-radius);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.ustia-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--ustia-text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.ustia-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ustia-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input Area */
.ustia-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--ustia-primary);
  border-top: 1px solid var(--ustia-border);
}

.ustia-file-hidden {
  display: none;
}

.ustia-attach,
.ustia-send {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.ustia-attach:hover,
.ustia-send:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ustia-send {
  color: var(--ustia-accent);
}

.ustia-input {
  flex: 1;
  background: var(--ustia-input-bg);
  border: 1px solid var(--ustia-border);
  border-radius: 20px;
  padding: 12px 16px;
  color: var(--ustia-text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.ustia-input::placeholder {
  color: var(--ustia-text-muted);
}

.ustia-input:focus {
  border-color: var(--ustia-accent);
}

/* File Preview */
.ustia-file-preview {
  padding: 8px 16px;
  background: var(--ustia-primary);
  border-top: 1px solid var(--ustia-border);
}

.ustia-file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ustia-file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--ustia-input-bg);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  color: var(--ustia-text);
}

.ustia-file-remove {
  background: transparent;
  border: none;
  color: var(--ustia-accent);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}

/* Powered By */
.ustia-powered {
  text-align: center;
  padding: 8px;
  font-size: 10px;
  color: var(--ustia-text-muted);
  background: var(--ustia-primary);
}

.ustia-powered a {
  color: var(--ustia-accent);
  text-decoration: none;
}

.ustia-powered a:hover {
  text-decoration: underline;
}

/* Minimized Chat Button */
.ustia-chat-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ustia-accent) 0%, var(--ustia-accent-soft) 100%);
  border: none;
  box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.3s, box-shadow 0.3s;
}

.ustia-chat-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(233, 69, 96, 0.5);
}

.ustia-chat-button-icon {
  font-size: 28px;
}

.ustia-unread {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* Mobile Responsive */
@media (max-width: 420px) {
  .ustia-widget {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    bottom: 0;
    right: 0;
    border-radius: 0;
  }
  
  .ustia-chat-button {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
  }
}

/* Scrollbar Styling */
.ustia-messages::-webkit-scrollbar {
  width: 6px;
}

.ustia-messages::-webkit-scrollbar-track {
  background: var(--ustia-bg);
}

.ustia-messages::-webkit-scrollbar-thumb {
  background: var(--ustia-border);
  border-radius: 3px;
}

.ustia-messages::-webkit-scrollbar-thumb:hover {
  background: var(--ustia-text-muted);
}

/* Image in messages */
.ustia-message img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
}

/* Error state */
.ustia-error {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #ef4444;
  padding: 12px;
  border-radius: var(--ustia-radius);
  text-align: center;
  font-size: 14px;
}
