/**
 * ======================
 * COMMON.CSS - Styles dùng chung
 * ======================
 */

/* === CSS Variables === */
:root {
  --c-primary: #81CCF2;
  --c-accent: #FFE454;
  --c-dark: #45494C;
  --c-bg: #f7f8f9;
  --c-border: #e5e7eb;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(0,0,0,.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* === Reset & Base === */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto;
  color: #0f172a;
  background: var(--c-bg);
  line-height: 1.35;
}

/* === Layout === */
.container {
  width: 100%;
  max-width: 1080px;
  padding: 12px 14px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .container {
    padding: 16px;
  }
}

.row {
  display: flex;
  gap: 12px;
}

.center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* === Card === */
.card {
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* === Buttons === */
.btn {
  border-radius: 14px;
  border: 1px solid var(--c-border);
  padding: 12px 16px;
  cursor: pointer;
  background: #fff;
  font-weight: 600;
  min-height: 44px;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: var(--c-primary);
  color: #0b2236;
  border-color: transparent;
}

.btn.accent {
  background: var(--c-accent);
  color: #111827;
  border-color: transparent;
}

.btn.ghost {
  background: #fff;
}

/* === Form Elements === */
.pill {
  display: inline-flex;
  align-items: center;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  background: #fff;
  min-height: 44px;
  font-size: 16px;
}

input.pill,
select.pill,
textarea.pill {
  width: 100%;
}

label {
  display: block;
  font-size: 13px;
  color: #475569;
  margin-bottom: 6px;
}

/* === Grid === */
.grid {
  display: grid;
  gap: 12px;
}

/* === Typography === */
.section-title {
  font-weight: 800;
  font-size: 16px;
}

.section-subtitle {
  font-weight: 700;
  font-size: 14px;
  color: #334155;
}

.section {
  padding: 12px;
}

.divider {
  margin: 12px 0;
  border: none;
  border-top: 1px solid var(--c-border);
}

/* === Quantity Control === */
.qty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.qty button {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--c-border);
  background: #fff;
  font-weight: bold;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.qty div {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
}

/* === Toast Notification === */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  font-size: 14px;
  font-weight: 500;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  max-width: 90vw;
  text-align: center;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.warning { background: #d97706; }
.toast.info { background: #0284c7; }

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

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* === Confirm Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  max-width: 90vw;
  width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  transform: scale(0.9);
  transition: transform 0.2s ease;
}

.modal-overlay.show .modal-box {
  transform: scale(1);
}

.modal-title {
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 12px;
}

.modal-body {
  font-size: 14px;
  color: #374151;
  margin-bottom: 16px;
  white-space: pre-line;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* === Success Order Modal === */
.success-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px;
  box-sizing: border-box;
}

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

.success-modal {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.25s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.success-modal-overlay.show .success-modal {
  transform: scale(1) translateY(0);
}

.success-modal-header {
  background: linear-gradient(135deg, var(--c-primary) 0%, #5eb8e8 100%);
  padding: 24px 20px;
  text-align: center;
  color: #0b2236;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.success-icon svg {
  width: 36px;
  height: 36px;
  color: #059669;
}

.success-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.success-modal-header .order-id {
  font-size: 14px;
  margin-top: 6px;
  opacity: 0.85;
  font-weight: 600;
}

.success-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.success-info-row {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: 14px;
}

.success-info-row:last-child {
  border-bottom: none;
}

.success-info-label {
  color: #64748b;
  min-width: 90px;
  flex-shrink: 0;
}

.success-info-value {
  color: #0f172a;
  font-weight: 600;
  word-break: break-word;
}

.success-section-title {
  font-weight: 700;
  font-size: 13px;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
  padding-top: 8px;
  border-top: 1px solid var(--c-border);
}

.success-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.success-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  font-size: 14px;
}

.success-item-name {
  color: #0f172a;
}

.success-item-qty {
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
  margin-left: 12px;
}

.success-total-row {
  display: flex;
  justify-content: space-between;
  padding: 12px 0 0;
  margin-top: 8px;
  border-top: 2px solid var(--c-dark);
  font-weight: 800;
  font-size: 16px;
}

.success-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--c-border);
  background: #f8fafc;
}

.success-modal-footer .btn {
  width: 100%;
  padding: 14px;
  font-size: 15px;
}

@media (max-width: 480px) {
  .success-modal-header {
    padding: 20px 16px;
  }
  
  .success-icon {
    width: 56px;
    height: 56px;
  }
  
  .success-icon svg {
    width: 32px;
    height: 32px;
  }
  
  .success-modal-header h2 {
    font-size: 18px;
  }
  
  .success-modal-body {
    padding: 14px 16px;
  }
  
  .success-info-row {
    flex-direction: column;
    gap: 2px;
  }
  
  .success-info-label {
    font-size: 12px;
  }
  
  .success-modal-footer {
    padding: 14px 16px calc(14px + var(--safe-bottom));
  }
}

/* === Backdrop === */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 40;
}

.backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* === Bottom Sheet === */
.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--c-border);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  transform: translateY(100%);
  transition: transform .25s ease;
  z-index: 65;
  max-height: 92vh;
  overflow: auto;
}

.bottom-sheet.show {
  transform: translateY(0);
}

/* === Drawer === */
.drawer {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-left: 1px solid var(--c-border);
  transform: translateX(100%);
  transition: transform .25s ease;
  z-index: 50;
}

@media (min-width: 520px) {
  .drawer {
    width: 92vw;
  }
}

@media (min-width: 980px) {
  .drawer {
    width: 420px;
  }
}

.drawer.open {
  transform: translateX(0);
}
