/* Components: Buttons, Inputs, Cards, Navigation, Timeline, Chat, Toasts */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-secondary {
  background: var(--secondary);
  color: #ffffff;
}
.btn-secondary:hover {
  background: #1e293b;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--border-subtle);
  border-color: var(--border-strong);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}
.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}
.btn-lg {
  padding: 16px 24px;
  font-size: 1.05rem;
  border-radius: var(--radius-lg);
}
.btn-block {
  width: 100%;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--border-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-icon:hover {
  background: #e2e8f0;
}

/* --- Form Inputs --- */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: var(--space-2);
}

.form-label .required-star {
  color: var(--danger);
  margin-right: 4px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
}

.input-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Radio Tiles --- */
.radio-tile-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
}

.radio-tile {
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  transition: all var(--transition-fast);
  background: var(--bg-card);
  color: var(--text-main);
}

.radio-tile:hover {
  border-color: var(--border-strong);
  background: var(--border-subtle);
}

.radio-tile.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* --- Status Badges & Chips --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  line-height: 1.2;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #d97706; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-secondary { background: #f1f5f9; color: var(--text-muted); }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* --- Service Card (Grid & Vertical Cards) --- */
.service-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.service-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.service-card:hover {
  border-color: var(--primary);
  box-shadow: 0 12px 30px -4px rgba(2, 132, 199, 0.18);
  transform: translateY(-4px);
}

.service-card:hover::before {
  opacity: 1;
}

.service-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.service-icon-box {
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #e0f2fe, #ede9fe);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12);
}

.service-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.service-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 6px;
}

.service-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
}

.service-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.service-price {
  font-size: 1rem;
  font-weight: 900;
  color: var(--primary);
}

.service-sla {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* FAQ Accordion */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.faq-item:hover {
  border-color: var(--primary);
}

.faq-question {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.faq-answer {
  padding: 0 20px 16px;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.7;
  display: none;
}

.faq-item.active .faq-answer {
  display: block;
}

.faq-icon {
  font-size: 1.2rem;
  color: var(--primary);
  transition: transform var(--transition-fast);
}

.faq-item.active .faq-icon {
  transform: rotate(180deg);
}

/* --- Bottom Navigation (Mobile Bar) --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  z-index: 900;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.04);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 4px 14px;
  border-radius: var(--radius-md);
  position: relative;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

.nav-badge {
  position: absolute;
  top: 2px;
  left: 12px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: bold;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* --- Modals & Sheets --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-elevated);
  color: var(--text-main);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-success { background: #065f46; color: #ffffff; }
.toast-error { background: #991b1b; color: #ffffff; }
.toast-info { background: #1e3a8a; color: #ffffff; }
.toast-warning { background: #92400e; color: #ffffff; }

/* --- Order Lifecycle Timeline --- */
.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
  margin: var(--space-4) 0;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 12px;
  bottom: 12px;
  right: 15px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  position: relative;
}

.timeline-dot {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 1;
}

.timeline-item.active .timeline-dot {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.timeline-content {
  flex: 1;
  background: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.timeline-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.timeline-time {
  font-size: 0.74rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* --- Realtime Chat Bubbles --- */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-bubble {
  max-width: 82%;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  font-size: 0.92rem;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}

.chat-bubble-user {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-right-radius: var(--radius-xs);
}

.chat-bubble-operator {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
  border-bottom-left-radius: var(--radius-xs);
}

.chat-bubble-internal {
  align-self: center;
  background: #fef3c7;
  border: 1.5px dashed #f59e0b;
  color: #78350f;
  width: 90%;
  border-radius: var(--radius-md);
}

.internal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: bold;
  color: #b45309;
  margin-bottom: 4px;
}

.chat-event-pill {
  align-self: center;
  background: #e2e8f0;
  color: #475569;
  font-size: 0.76rem;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin: 6px 0;
}

.chat-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 4px;
  text-align: left;
}

.chat-input-bar {
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeletonLoad 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeletonLoad {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Empty State Box */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-icon {
  font-size: 3rem;
  color: var(--text-dim);
  margin-bottom: var(--space-2);
}

/* ==========================================================================
   Dark Theme Component Enhancements
   ========================================================================== */
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
  border-color: var(--primary);
  background: #0f172a;
}

[data-theme="dark"] .radio-tile {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

[data-theme="dark"] .radio-tile:hover {
  background: #334155;
}

[data-theme="dark"] .modal-content {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.85);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .chat-bubble-user {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}

[data-theme="dark"] .chat-input-bar {
  background: #0f172a;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .timeline-content {
  background: #1e293b;
}

[data-theme="dark"] .timeline-dot {
  background: #0f172a;
  border-color: #475569;
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}

[data-theme="dark"] .badge-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

/* Staff Header Button */
.header-staff-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .header-staff-btn {
    padding: 3px 8px;
    font-size: 11px;
  }
}

