@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --bg-body: #0a0e1a;
  --bg-sidebar: #0d1221;
  --bg-card: #131a2b;
  --bg-card-hover: #1a2340;
  --bg-input: #0f1629;
  --bg-modal: rgba(5, 8, 18, 0.85);
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 260px;
  --transition: 0.2s ease;
}

html {
  font-size: 15px;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ═══════ AUTH PAGE ═══════ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 60%),
    var(--bg-body);
  padding: 2rem;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.8rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  animation: fadeUp 0.5s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-card .logo h1 {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-card .logo p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 2rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  transition: var(--transition);
}

.auth-tab.active {
  background: var(--accent);
  color: #fff;
}

.auth-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

/* ═══════ FORMS ═══════ */
.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

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

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ═══════ BUTTONS ═══════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

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

.btn-success:hover {
  background: #0d9668;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
}

/* ═══════ LAYOUT ═══════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ═══════ SIDEBAR ═══════ */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 1.5rem 1.3rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h2 {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-brand .tenant-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.8rem;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
  display: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-hover);
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.nav-section {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 1.2rem 1rem 0.5rem;
}

.sidebar-footer {
  padding: 1rem 1.3rem;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}

.user-details .user-name {
  font-size: 0.88rem;
  font-weight: 600;
}

.user-details .user-role {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.btn-logout {
  width: 100%;
  padding: 0.55rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  transition: var(--transition);
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-bg);
}

/* ═══════ MAIN CONTENT ═══════ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem 2.5rem;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

/* ═══════ STAT CARDS ═══════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.stat-full-width {
  grid-column: 1 / -1;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.stat-card .stat-icon {
  font-size: 1.8rem;
  margin-bottom: 0.8rem;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.2rem;
}

.stat-card .stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ═══════ TABLE ═══════ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrapper th {
  padding: 0.85rem 1.2rem;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}

.table-wrapper td {
  padding: 0.85rem 1.2rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.table-wrapper tr:last-child td {
  border-bottom: none;
}

.table-wrapper tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ═══════ BADGES ═══════ */
.badge {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-accent {
  background: var(--accent-glow);
  color: var(--accent-hover);
}

/* ═══════ MODAL ═══════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-modal);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeUp 0.3s ease;
}

.modal::-webkit-scrollbar {
  display: none;
}

.modal h2 {
  font-size: 1.2rem;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ═══════ POS / CREATE ORDER ═══════ */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  height: calc(100vh - 130px);
}

.pos-products {
  overflow-y: auto;
  padding-right: 0.5rem;
}

.pos-products::-webkit-scrollbar {
  display: none;
}

.pos-cart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-cart-header {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.05rem;
}

.pos-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem;

}

.pos-cart-items::-webkit-scrollbar {
  display: none;
}

.pos-cart-footer {
  padding: 1.2rem 1.4rem;
  border-top: 1px solid var(--border);
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.15);
}

.product-card .p-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
}

.product-card .p-price {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

.product-card .p-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
  background: rgba(255, 255, 255, 0.02);
}

.cart-item .ci-info {
  flex: 1;
}

.cart-item .ci-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.cart-item .ci-price {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cart-item .ci-qty {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.cart-item .ci-qty button {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.cart-item .ci-qty button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cart-item .ci-qty span {
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  font-size: 0.85rem;
}

.cart-item .ci-subtotal {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 65px;
  text-align: right;
}

.cart-item .ci-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem;
  transition: var(--transition);
}

.cart-item .ci-remove:hover {
  color: var(--danger);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-top: 0.8rem;
}

.cart-total .total-amount {
  color: var(--accent);
  font-size: 1.3rem;
}

.search-bar {
  position: relative;
  margin-bottom: 1.2rem;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.8rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
}

/* ═══════ RECEIPT MODAL ═══════ */
.receipt {
  background: #fff;
  color: #1e293b;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  margin: 0 auto;
}

.receipt h2 {
  text-align: center;
  color: #6366f1;
  margin-bottom: 0.3rem;
}

.receipt .receipt-subtitle {
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
  margin-bottom: 1.2rem;
}

.receipt table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.receipt th {
  text-align: left;
  font-size: 0.78rem;
  color: #64748b;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e2e8f0;
}

.receipt td {
  padding: 0.5rem 0;
  font-size: 0.88rem;
  border-bottom: 1px solid #f1f5f9;
}

.receipt .receipt-total {
  text-align: right;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 0.8rem;
  color: #6366f1;
}

.receipt .receipt-footer {
  text-align: center;
  margin-top: 1.2rem;
  color: #94a3b8;
  font-size: 0.8rem;
}

/* ═══════ TOAST ═══════ */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.toast {
  padding: 0.85rem 1.3rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.toast-success {
  background: var(--success);
  color: #fff;
}

.toast-error {
  background: var(--danger);
  color: #fff;
}

.toast-info {
  background: var(--info);
  color: #fff;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* ═══════ MISC ═══════ */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.95rem;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 1rem;
}

.mb-1 {
  margin-bottom: 1rem;
}

/* ═══════ MOBILE HEADER & OVERLAY ═══════ */
.mobile-header {
  display: none;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-header h2 {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.btn-menu {
  background: transparent;
  border: none;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 95;
  opacity: 0;
  transition: opacity var(--transition);
}

.sidebar-overlay.show {
  opacity: 1;
}

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 1024px) {
  .pos-layout {
    display: flex;
    flex-direction: column-reverse;
    height: auto;
  }

  .pos-cart {
    max-height: 100vh;
  }

  .table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrapper table {
    min-width: 900px;
  }
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

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

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.show {
    pointer-events: auto;
  }

  .main-content {
    margin-left: 0;
    padding: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .pos-cart-items {
    min-height: 27vh;
    max-height: 27vh;
  }

  .table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrapper table {
    min-width: 700px;
    /* chỉnh theo số cột */
  }
}