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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* Site Header */
.site-header {
  background: #213F91;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 72px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.site-logo img {
  height: 40px;
  width: auto;
}

.site-nav {
  display: flex;
  gap: 20px;
  flex: 1;
}

.site-nav a {
  font-size: 0.85rem;
  color: #fff;
  text-decoration: none;
  font-weight: 500;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.site-nav a:hover {
  color: #FFC83D;
  border-bottom-color: #FFC83D;
}

.site-btn {
  font-size: 0.8rem;
  font-weight: 600;
  color: #213F91;
  background: #FFC83D;
  padding: 9px 18px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.site-btn:hover {
  background: #f5be2e;
}

@media (max-width: 768px) {
  .site-header-inner {
    padding: 10px 16px;
    height: 56px;
    justify-content: space-between;
  }
  .site-logo img {
    height: 32px;
  }
  .site-nav {
    display: none;
  }
  .site-btn {
    font-size: 0.72rem;
    padding: 7px 12px;
  }
}

/* App Wrapper */
.app-wrapper {
  flex: 1;
  min-height: 0;
}

/* Layout */
.app-layout {
  display: flex;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px;
  gap: 16px;
  height: calc(100vh - 88px);
}

@media (max-width: 768px) {
  .app-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0;
    height: auto;
    overflow: visible;
  }
}

/* Chat Panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.chat-panel-header {
  background: #213F91;
  color: #fff;
  padding: 14px 20px;
  flex-shrink: 0;
}

.chat-panel-header h1 {
  font-size: 1.05rem;
  font-weight: 600;
}

.chat-panel-header p {
  font-size: 0.78rem;
  opacity: 0.8;
  margin-top: 2px;
}

.order-banner {
  background: #FFC83D;
  color: #213F91;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 20px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .chat-panel {
    border-radius: 0;
    min-height: 70dvh;
  }
}

.chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  background: #fafbfc;
}

@media (max-width: 768px) {
  .chat-messages {
    max-height: calc(100dvh - 280px);
    min-height: 300px;
  }
}

.chat-composer {
  display: flex;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #e8eaed;
  gap: 8px;
  flex-shrink: 0;
  background: #fff;
}

.chat-composer input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #dde0e4;
  border-radius: 24px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.chat-composer input:focus {
  border-color: #213F91;
}

.chat-composer button {
  width: 40px;
  height: 40px;
  background: #213F91;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-composer button:hover:not(:disabled) {
  background: #1a3278;
}

.chat-composer button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Order Panel */
.order-panel {
  width: 300px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .order-panel {
    width: 100%;
    position: static;
    max-height: none;
    order: -1;
    flex-shrink: 0;
  }
}

.order-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

@media (max-width: 768px) {
  .order-card {
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid #e5e5e5;
  }
}

.order-card-header {
  background: #213F91;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px 8px;
}

@media (max-width: 768px) {
  .order-toggle-btn {
    display: inline-block;
  }
}

.order-card-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card-summary {
  padding: 12px 18px;
  display: none;
  gap: 6px;
  flex-direction: column;
  font-size: 0.82rem;
  color: #1a1a1a;
}

.order-card-summary .summary-product {
  font-weight: 700;
  font-size: 0.92rem;
}

.order-card-summary .summary-detail {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #555;
}

@media (max-width: 768px) {
  .order-panel.collapsed .order-card-body,
  .order-panel.collapsed .order-card-actions {
    display: none;
  }

  .order-panel.collapsed .order-card-summary {
    display: flex;
  }

  .order-panel:not(.collapsed) .order-card-summary {
    display: none;
  }

  .order-panel .order-card-body {
    padding: 12px 16px;
    gap: 8px;
  }

  .order-panel .order-card-actions {
    padding: 10px 16px;
  }
}

.order-product-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.3;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f0f0;
}

.order-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-detail-row .label {
  font-size: 0.72rem;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.order-detail-row .value {
  font-size: 0.82rem;
  font-weight: 500;
  color: #1a1a1a;
}

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #e8f5e9;
  color: #2e7d32;
}

.order-card-actions {
  padding: 14px 18px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.2s;
}

.action-btn:hover {
  opacity: 0.85;
}

.action-btn.primary {
  background: #213F91;
  color: #fff;
}

.action-btn.accent {
  background: #FFC83D;
  color: #213F91;
}

.action-btn.outline {
  background: transparent;
  border: 1.5px solid #213F91;
  color: #213F91;
}

.action-btn.ghost {
  background: transparent;
  color: #213F91;
  font-weight: 500;
  padding: 8px 14px;
}

.action-btn.ghost:hover {
  background: #f5f7fb;
}

/* Message Bubbles */
.msg-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

@media (max-width: 768px) {
  .msg-bubble {
    max-width: 82%;
  }
}

.msg-bubble.customer {
  align-self: flex-end;
  background: #FFF3D0;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}

.msg-bubble.admin {
  align-self: flex-start;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #e8eaed;
  border-bottom-left-radius: 4px;
}

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.62rem;
  opacity: 0.6;
}

.msg-tick {
  display: inline-flex;
  align-items: center;
}

.msg-tick.sent svg,
.msg-tick.delivered svg {
  stroke: #999;
}

.msg-tick.read svg {
  stroke: #53bdeb;
}

.msg-tick.sending svg,
.msg-tick.queued svg {
  stroke: #999;
}

.msg-tick.failed svg {
  stroke: #c0392b;
}

.retry-btn {
  margin-left: 6px;
  padding: 2px 8px;
  font-size: 0.62rem;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.system-notice {
  align-self: center;
  text-align: center;
  color: #888;
  font-size: 0.82rem;
  padding: 8px 14px;
  background: #f8f9fb;
  border-radius: 12px;
}

.system-notice.error {
  color: #c0392b;
  background: #fdecea;
}

/* Upload Button */
.composer-icon-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  color: #213F91;
  border: 1.5px solid #dde0e4;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.composer-icon-btn:hover:not(:disabled) {
  background: #f5f7fb;
  border-color: #213F91;
}

.composer-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Upload Attachment Previews */
.msg-attachment-img {
  max-width: 220px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  cursor: pointer;
}

.msg-attachment-link {
  display: inline-block;
  padding: 6px 12px;
  background: #f0f2f5;
  border-radius: 8px;
  color: #213F91;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  word-break: break-all;
}

.msg-attachment-link:hover {
  background: #e3e7ef;
}

.msg-upload-progress {
  font-size: 0.82rem;
  color: #666;
}

.msg-upload-error {
  font-size: 0.82rem;
  color: #c0392b;
}

/* Support Guest Form */
.support-guest-form {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.guest-form-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px 28px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.guest-form-card h2 {
  font-size: 1.2rem;
  color: #213F91;
  margin-bottom: 6px;
}

.guest-form-card > p {
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 20px;
}

.guest-form-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.guest-form-card label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #333;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.guest-form-card input[type="text"],
.guest-form-card input[type="email"] {
  padding: 10px 14px;
  border: 1px solid #dde0e4;
  border-radius: 8px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.guest-form-card input[type="text"]:focus,
.guest-form-card input[type="email"]:focus {
  border-color: #213F91;
}

.guest-form-card .action-btn {
  margin-top: 8px;
}

.guest-form-signin {
  margin-top: 14px;
  font-size: 0.8rem;
  color: #555;
  text-align: center;
}

.guest-form-signin a {
  color: #213F91;
  font-weight: 600;
  text-decoration: none;
}

.guest-form-signin a:hover {
  text-decoration: underline;
}

.guest-form-privacy {
  margin-top: 10px;
  font-size: 0.72rem;
  color: #999;
  text-align: center;
}

.guest-form-error {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #c0392b;
}
