/* Widget — mobile-first, dark theme */
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

.widget-fullscreen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.hidden { display: none !important; }

/* Pre-chat */
.prechat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.prechat-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.prechat-inner h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.prechat-inner input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
}
.btn-primary {
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  min-height: var(--tap-min);
  cursor: pointer;
}

/* Chat panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  min-height: var(--tap-min);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.online { background: var(--accent2); }
.status-dot.away { background: var(--warning); }
.header-agent-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  flex-shrink: 0;
}
.header-agent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.header-title { flex: 1; font-weight: 600; font-size: 1rem; min-width: 0; }
.btn-icon {
  width: var(--tap-min);
  height: var(--tap-min);
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

/* Messages */
.messages-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.messages { display: flex; flex-direction: column; gap: 0.5rem; }

.msg {
  max-width: 85%;
  padding: 0;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.msg .msg-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--panel2);
  overflow: hidden;
  flex-shrink: 0;
}
.msg .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg .msg-avatar .initial { font-size: 0.75rem; font-weight: 600; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--text-muted); }
.msg .msg-body { flex: 1; min-width: 0; padding: 0.6rem 0.9rem; border-radius: var(--radius); }
.msg.visitor { align-self: flex-end; flex-direction: row; }
.msg.visitor .msg-body { background: var(--bubble-user); }
.msg.consultant { align-self: flex-start; flex-direction: row-reverse; }
.msg.consultant .msg-body { background: var(--bubble-agent); }
.msg.system { align-self: center; flex-direction: column; align-items: center; background: transparent; }
.msg.system .msg-avatar { display: none; }
.msg.system .msg-body { background: var(--panel2); color: var(--text-muted); font-size: 0.85rem; }
.msg .time { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }

.typing-indicator {
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Quick actions */
.quick-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem 0.5rem;
  flex-wrap: wrap;
}
.quick-actions button {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

/* Composer */
.composer-wrap {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  padding-bottom: calc(0.5rem + var(--safe-bottom));
  background: var(--panel);
  border-top: 1px solid var(--border);
}
#message-input {
  flex: 1;
  min-height: var(--tap-min);
  max-height: 120px;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel2);
  color: var(--text);
  font-size: 1rem;
  resize: none;
  font-family: inherit;
}
.btn-send {
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  min-height: var(--tap-min);
  min-width: 56px;
  cursor: pointer;
}

/* Offline */
.offline-panel {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.offline-panel textarea {
  width: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  resize: vertical;
}

/* Ticket Panel */
.ticket-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.ticket-form-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.ticket-form-wrap form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.ticket-form-wrap label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.ticket-form-wrap input,
.ticket-form-wrap select,
.ticket-form-wrap textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
}
.ticket-form-wrap select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.ticket-form-wrap textarea {
  resize: vertical;
  min-height: 100px;
}
.ticket-form-wrap .btn-primary {
  margin-top: 1rem;
}

