/* Shipu unified UI (dark-first)
   Goal: consistent look across all pages without touching backend logic.
*/

:root {
  --bg: #0b0b0c;
  --panel: #121214;
  --panel-2: #17171a;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: #27272a;

  /* keep existing accent used around the project */
  --accent: #667eea;
  --accent-2: #764ba2;
  --danger: #ff6b6b;

  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.shipu-ui {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, rgba(102, 126, 234, 0.20), transparent 55%),
              radial-gradient(900px 700px at 90% 10%, rgba(118, 75, 162, 0.18), transparent 52%),
              var(--bg);
  color: var(--text);
}

.shipu-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.shipu-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(18, 18, 20, 0.78);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(39, 39, 42, 0.8);
}

.shipu-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.shipu-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.shipu-brand-title {
  font-size: 18px;
  line-height: 1.2;
}

.shipu-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.shipu-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(244, 244, 245, 0.9);
  background: rgba(23, 23, 26, 0.75);
  border: 1px solid rgba(39, 39, 42, 0.9);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
  font-weight: 650;
  font-size: 13px;
}

.shipu-nav-link:hover {
  transform: translateY(-1px);
  background: rgba(23, 23, 26, 0.95);
  border-color: rgba(102, 126, 234, 0.55);
}

.shipu-nav-link.is-active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.20), rgba(118, 75, 162, 0.20));
  border-color: rgba(102, 126, 234, 0.65);
}

.shipu-nav-link.is-danger {
  color: rgba(255, 255, 255, 0.92);
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.08);
}

.shipu-nav-link.is-danger:hover {
  border-color: rgba(255, 107, 107, 0.8);
  background: rgba(255, 107, 107, 0.12);
}

.shipu-page-title {
  margin: 0 0 14px 0;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.shipu-subtitle {
  margin: 0 0 18px 0;
  color: rgba(161, 161, 170, 0.95);
  font-size: 13px;
}

.shipu-card,
.section,
.order-card,
.chat-card,
.orders-list,
.chat-area {
  background: rgba(18, 18, 20, 0.88);
  border: 1px solid rgba(39, 39, 42, 0.9);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.shipu-card {
  padding: 18px;
}

/* Tables */
.shipu-table,
.payments-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.shipu-table th,
.payments-table th {
  text-align: left;
  padding: 12px 12px;
  color: rgba(244, 244, 245, 0.9);
  background: rgba(23, 23, 26, 0.95);
  border-bottom: 1px solid rgba(39, 39, 42, 0.9);
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.shipu-table td,
.payments-table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(39, 39, 42, 0.7);
  vertical-align: top;
  color: rgba(244, 244, 245, 0.88);
}

.shipu-table tr:hover td,
.payments-table tr:hover td {
  background: rgba(102, 126, 234, 0.06);
}

.link-cell a,
.product-link {
  color: rgba(167, 182, 255, 0.95);
  text-decoration: none;
}

.link-cell a:hover,
.product-link:hover {
  text-decoration: underline;
}

.user-id-code,
code {
  background: rgba(23, 23, 26, 0.9);
  border: 1px solid rgba(39, 39, 42, 0.9);
  padding: 3px 8px;
  border-radius: 10px;
  color: rgba(244, 244, 245, 0.9);
}

.price { color: rgba(167, 182, 255, 0.95); font-weight: 800; }

/* Badges / statuses */
.status-badge,
.order-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2px;
  border: 1px solid rgba(39, 39, 42, 0.9);
  background: rgba(23, 23, 26, 0.85);
  color: rgba(244, 244, 245, 0.9);
}

.status-pending,
.status-waiting,
.status-confirming,
.status-partially_paid {
  border-color: rgba(255, 193, 7, 0.35);
  background: rgba(255, 193, 7, 0.10);
  color: rgba(255, 230, 160, 0.95);
}

.status-finished,
.status-approved,
.status-paid,
.status-shipped {
  border-color: rgba(40, 167, 69, 0.35);
  background: rgba(40, 167, 69, 0.10);
  color: rgba(170, 255, 206, 0.95);
}

.status-expired,
.status-failed,
.status-rejected {
  border-color: rgba(220, 53, 69, 0.35);
  background: rgba(220, 53, 69, 0.12);
  color: rgba(255, 190, 198, 0.95);
}

/* Buttons */
.action-btn,
.back-link,
.nav-link,
button,
.btn-approve,
.btn-reject,
.btn-close {
  border-radius: 12px;
}

.action-btn,
.btn-approve,
.btn-reject,
.btn-close {
  border: 1px solid rgba(39, 39, 42, 0.9);
  background: rgba(23, 23, 26, 0.85);
  color: rgba(244, 244, 245, 0.92);
  padding: 10px 14px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.action-btn:hover,
.btn-approve:hover,
.btn-reject:hover,
.btn-close:hover {
  transform: translateY(-1px);
  border-color: rgba(102, 126, 234, 0.55);
  background: rgba(23, 23, 26, 0.95);
}

.btn-approve { border-color: rgba(40, 167, 69, 0.45); background: rgba(40, 167, 69, 0.12); }
.btn-approve:hover { border-color: rgba(40, 167, 69, 0.7); background: rgba(40, 167, 69, 0.18); }

.btn-reject { border-color: rgba(220, 53, 69, 0.45); background: rgba(220, 53, 69, 0.12); }
.btn-reject:hover { border-color: rgba(220, 53, 69, 0.7); background: rgba(220, 53, 69, 0.18); }

.btn-close { border-color: rgba(161, 161, 170, 0.40); background: rgba(161, 161, 170, 0.10); }

.action-btn:disabled,
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Inputs */
input:not([type]),
input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="search"],
input[type="tel"],
select,
textarea {
  width: 100%;
  background: rgba(11, 11, 12, 0.75);
  border: 1px solid rgba(39, 39, 42, 0.95);
  color: rgba(244, 244, 245, 0.92);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
}

input:not([type])::placeholder,
input[type="text"]::placeholder,
input[type="number"]::placeholder,
input[type="password"]::placeholder,
input[type="email"]::placeholder,
input[type="url"]::placeholder,
input[type="search"]::placeholder,
input[type="tel"]::placeholder,
textarea::placeholder {
  color: rgba(161, 161, 170, 0.95);
}

/* Prevent WebKit autofill from forcing light backgrounds on dark UI */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: rgba(244, 244, 245, 0.92);
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0px 1000px rgba(11, 11, 12, 0.75) inset;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: rgba(11, 11, 12, 0.75);
  padding-right: 36px;
  cursor: pointer;
}

/* Keep native dropdown readable on dark UI (works in most browsers) */
select option {
  background: var(--panel);
  color: var(--text);
}

/* Simple chevron using existing border/text tokens */
select {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(244, 244, 245, 0.65) 50%),
    linear-gradient(135deg, rgba(244, 244, 245, 0.65) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 50%,
    calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(102, 126, 234, 0.75);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.18);
}

textarea { min-height: 90px; resize: vertical; }

label {
  display: block;
  margin-bottom: 7px;
  color: rgba(244, 244, 245, 0.88);
  font-size: 13px;
  font-weight: 700;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0;
}

.tab-btn {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(39, 39, 42, 0.9);
  background: rgba(23, 23, 26, 0.75);
  color: rgba(244, 244, 245, 0.86);
  font-weight: 800;
  cursor: pointer;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.20), rgba(118, 75, 162, 0.20));
  border-color: rgba(102, 126, 234, 0.65);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Layout helpers */
.orders-grid,
.chats-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.order-card,
.chat-card {
  padding: 16px;
  position: relative;
}

.card-link-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card-delete-form {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
}

.card-delete-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(39, 39, 42, 0.9);
  background: rgba(23, 23, 26, 0.75);
  color: rgba(244, 244, 245, 0.90);
  font-weight: 900;
  cursor: pointer;
  line-height: 1;
}

.card-delete-btn:hover {
  border-color: rgba(255, 107, 107, 0.55);
}

.table-delete-form {
  display: flex;
  justify-content: center;
}

.order-header,
.chat-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(39, 39, 42, 0.8);
  margin-bottom: 12px;
}

.order-id { font-weight: 900; color: rgba(167, 182, 255, 0.95); }

.order-info .info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}

.info-label { color: rgba(161, 161, 170, 0.95); font-weight: 700; }
.info-value { color: rgba(244, 244, 245, 0.90); word-break: break-word; }

.button-group { display: flex; gap: 10px; margin-top: 12px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: rgba(161, 161, 170, 0.9);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.active,
#trackingModal.show {
  display: flex;
}

.modal-content,
.shipu-modal-content {
  width: min(520px, 92vw);
  background: rgba(18, 18, 20, 0.96);
  border: 1px solid rgba(39, 39, 42, 0.95);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.modal-header {
  font-weight: 900;
  margin-bottom: 14px;
}

.error,
.success {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(39, 39, 42, 0.9);
  margin: 12px 0;
  font-weight: 700;
}

.error { border-color: rgba(220, 53, 69, 0.35); background: rgba(220, 53, 69, 0.10); color: rgba(255, 190, 198, 0.95); }
.success { border-color: rgba(40, 167, 69, 0.35); background: rgba(40, 167, 69, 0.10); color: rgba(170, 255, 206, 0.95); }

/* Toast */
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(39, 39, 42, 0.9);
  background: rgba(18, 18, 20, 0.96);
  color: rgba(244, 244, 245, 0.92);
  box-shadow: var(--shadow);
  z-index: 3000;
  animation: shipuSlideIn 0.18s ease-out;
  max-width: min(520px, 90vw);
}

.toast.success { border-color: rgba(40, 167, 69, 0.55); }
.toast.error { border-color: rgba(220, 53, 69, 0.55); }

@keyframes shipuSlideIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideOut {
  to { transform: translateY(12px); opacity: 0; }
}

/* Chat pages (admin + client) */
.chat-container { background: transparent !important; height: calc(100vh - 72px); }

/* Admin chat alignment (admin right, client left) */
.admin-chat-view .message-group {
  display: flex;
  margin-bottom: 12px;
}

.admin-chat-view .message-group.admin { justify-content: flex-end; }
.admin-chat-view .message-group.client { justify-content: flex-start; }

.chat-header {
  background: rgba(18, 18, 20, 0.88) !important;
  border: 1px solid rgba(39, 39, 42, 0.9);
  border-radius: 16px;
}

#messages,
#chatMessages {
  background: rgba(18, 18, 20, 0.65) !important;
  border: 1px solid rgba(39, 39, 42, 0.85);
  border-radius: 16px;
}

.message-group.admin .message-bubble {
  background: rgba(23, 23, 26, 0.92) !important;
  border: 1px solid rgba(39, 39, 42, 0.9);
  color: rgba(244, 244, 245, 0.92);
}

.message-group.client .message-bubble {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.35), rgba(118, 75, 162, 0.30)) !important;
  border: 1px solid rgba(102, 126, 234, 0.35);
  color: rgba(255, 255, 255, 0.96);
}

.chat-input-area {
  background: rgba(18, 18, 20, 0.88) !important;
  border: 1px solid rgba(39, 39, 42, 0.85);
  border-radius: 16px;
}

/* Mobile chat composer (keyboard-aware) */
.shipu-chat-page .shipu-chat-shell {
  height: 100dvh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shipu-chat-page .shipu-chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--shipu-composer-space, 96px);
}

.shipu-chat-page .shipu-chat-composer {
  position: fixed;
  z-index: 1200;
  bottom: var(--shipu-keyboard-offset, 0px);
}

.shipu-chat-page .shipu-chat-composer {
  padding-bottom: env(safe-area-inset-bottom);
}

@media (max-width: 768px) {
  .shipu-container { padding: 14px; }
  .shipu-header-inner { padding: 14px; }
}
