/* =========================================================
   CUSTOMERS LIST – Naleng AutoPOS
   ERP-grade | Modal-safe | Dashboard-integrated
========================================================= */

/* =========================
   HEADER
========================= */
.customers-header{
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap:14px;
}

/* =========================
   SEARCH BAR
========================= */
.pos-customer-search{
  margin: 12px 0 14px;
  padding: 14px 16px;

  display:flex;
  align-items:center;
  gap:12px;

  border-radius: 18px;
  border:1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.pos-customer-search i{
  color: var(--muted);
}

.pos-customer-search input{
  border:0;
  outline:0;
  width:100%;
  font-size:1rem;
  font-weight:750;
  background: transparent;
}

/* =========================
   TABLE
========================= */
.pos-table-wrap{
  overflow:auto;
  border-radius:18px;
  border:1px solid var(--line);
}

.pos-table{
  width:100%;
  min-width:720px;
  border-collapse:collapse;
}

.pos-table th,
.pos-table td{
  padding:14px;
  border-bottom:1px solid rgba(12,28,55,.08);
  font-weight:750;
  text-align:left;
}

.pos-table th{
  font-size:.85rem;
  font-weight:900;
  color:var(--muted);
}

.pos-table tr:hover{
  background:rgba(255,122,24,.04);
}

/* =========================
   CUSTOMER TYPE BADGE
========================= */
.customer-type{
  display:inline-block;
  padding:6px 10px;
  border-radius:999px;
  font-size:.8rem;
  font-weight:900;
}

.customer-type.walkin{
  background:rgba(12,28,55,.08);
  color:var(--text);
}

.customer-type.partner{
  background:rgba(255,122,24,.14);
  color:var(--orange);
}

/* =========================
   ROW ACTIONS
========================= */
.pos-row-actions{
  display:flex;
  gap:10px;
}

.pos-row-actions button{
  border:0;
  background:none;
  cursor:pointer;
  color:var(--deep2);
  font-size:1rem;
}

.pos-row-actions button:hover{
  color:var(--orange);
}

/* =========================
   EMPTY STATE
========================= */
.pos-empty{
  padding:40px 12px;
  text-align:center;
  color:var(--muted);
  font-weight:850;
}

.pos-empty i{
  font-size:2rem;
  margin-bottom:10px;
}

/* =========================
   PAGINATION
========================= */
.pos-pagination{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:16px;
  margin-top:14px;
}

.page-btn{
  border:1px solid var(--line);
  background:var(--panel);
  padding:8px 12px;
  border-radius:10px;
  cursor:pointer;
  font-weight:900;
}

.page-btn:disabled{
  opacity:.4;
  cursor:not-allowed;
}

.page-info{
  font-weight:850;
  color:var(--muted);
}

/* =========================
   DUPLICATE FIELD HIGHLIGHT
========================= */
.pos-duplicate{
  border-color:rgba(220,38,38,.6)!important;
  box-shadow:0 0 0 3px rgba(220,38,38,.15);
}

/* =========================================================
   🔥 MODAL SYSTEM (CRITICAL FIX)
========================================================= */

/* BACKDROP */
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(5,10,25,.45);
  backdrop-filter:blur(2px);
  z-index:1100;
}

/* MODAL WRAPPER */
.modal{
  position:fixed;
  inset:0;
  z-index:1200;

  display:flex;
  align-items:center;
  justify-content:center;

  pointer-events:auto;
}

/* HIDDEN STATE */
.modal[aria-hidden="true"]{
  display:none;
}

/* MODAL CARD */
.modal-card{
  width:min(520px,92vw);
  max-height:90vh;
  overflow-y:auto;

  background:var(--panel);
  border-radius:18px;
  box-shadow:var(--shadow);

  animation:modalIn .18s ease;
}

/* ANIMATION */
@keyframes modalIn{
  from{opacity:0; transform:translateY(6px) scale(.98)}
  to{opacity:1; transform:none}
}

/* =========================================================
   VIEW CUSTOMER MODAL – FINAL FIX
   Matches corrected HTML structure
========================================================= */

/* Backdrop (shared) */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 25, 0.45);
  backdrop-filter: blur(3px);
  z-index: 1100;
}

/* Modal wrapper */
.modal{
  position: fixed;
  inset: 0;
  z-index: 1200;

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

/* Proper hide */
.modal[aria-hidden="true"]{
  display: none;
}

/* Modal card (base) */
.modal-card{
  width: min(520px, 92vw);
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  animation: modalIn 0.18s ease;
  overflow: hidden;
}

/* View modal width override */
.modal.modal-view .modal-card{
  max-width: 420px;
}

/* Entry animation */
@keyframes modalIn{
  from{
    opacity: 0;
    transform: translateY(8px) scale(.97);
  }
  to{
    opacity: 1;
    transform: none;
  }
}

/* =========================================================
   MODAL HEADER / FOOTER
========================================================= */

.modal-head,
.modal-foot{
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head{
  border-bottom: 1px solid var(--line);
}

.modal-foot{
  border-top: 1px solid var(--line);
}

.modal-title{
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title i{
  color: var(--orange);
}

.modal-body{
  padding: 16px;
}

/* Close button */
.icon-btn{
  border: 0;
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
}

.icon-btn:hover{
  color: var(--orange);
}

/* =========================================================
   VIEW CUSTOMER CARD
========================================================= */

.customer-view-card{
  text-align: center;
}

/* Avatar */
.customer-avatar{
  width: 72px;
  height: 72px;
  margin: 0 auto 10px;

  display: grid;
  place-items: center;

  border-radius: 50%;
  background: linear-gradient(135deg, var(--deep), var(--deep2));
  color: #fff;
  font-size: 1.8rem;
}

/* Name */
.customer-view-card h3{
  margin: 6px 0 6px;
  font-size: 1.2rem;
  font-weight: 900;
}

/* Type badge spacing */
.customer-view-card .customer-type{
  margin: 6px auto 10px;
}

/* Info grid */
.customer-view-grid{
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.view-row{
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: var(--text);
}

.view-row i{
  width: 18px;
  text-align: center;
  color: var(--orange);
}

/* Hint box */
.view-hint{
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(6,42,87,.06);

  font-size: .85rem;
  font-weight: 750;
  color: var(--muted);

  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* =========================================================
   BUTTONS INSIDE MODAL
========================================================= */

.modal-foot .btn{
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
  border: 0;
}

.modal-foot .btn.ghost{
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.modal-foot .btn{
  background: linear-gradient(135deg, var(--deep), var(--deep2));
  color: #fff;
}

/* =========================================================
   SAFETY OVERRIDE
   Prevent browser alert-like appearance
========================================================= */

.modal *{
  box-sizing: border-box;
  font-family: inherit;
}

/* =========================
   USER MESSAGES / TOAST
========================= */
.pos-message{
  position:fixed;
  bottom:22px;
  right:22px;
  z-index:9999;

  display:flex;
  align-items:center;
  gap:10px;

  padding:14px 16px;
  border-radius:16px;
  font-weight:900;

  background:var(--panel);
  border:1px solid var(--line);
  box-shadow:var(--shadow);

  animation:msgIn .25s ease;
}

.pos-message.success{
  border-color:rgba(22,163,74,.35);
  background:rgba(22,163,74,.12);
  color:#166534;
}

.pos-message.info{
  border-color:rgba(59,130,246,.35);
  background:rgba(59,130,246,.12);
  color:#1e40af;
}

@keyframes msgIn{
  from{opacity:0; transform:translateY(10px)}
  to{opacity:1; transform:none}
}

 /* =========================================================
   FONT AWESOME RENDER FIX (CRITICAL)
   Ensures icons render inside modals & buttons
========================================================= */

.fa-solid,
.fa-regular,
.fa-brands {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-style: normal;
}

/* Ensure icons inside buttons/modals never collapse */
button i,
.icon-btn i,
.modal-title i,
.view-row i {
  min-width: 1em;
  min-height: 1em;
}
/* =========================================================
   📱 MOBILE-FIRST TABLE RESPONSIVENESS
========================================================= */

@media (max-width: 820px){

  .pos-table-wrap{
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .pos-table{
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  .pos-table thead{
    display: none;
  }

  .pos-table tr{
    display: block;
    background: var(--panel);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 10px 12px;
  }

  .pos-table td{
    display: flex;
    justify-content: space-between;
    align-items: center;

    padding: 10px 6px;
    border: none;
    font-size: .9rem;
  }

  .pos-table td::before{
    content: attr(data-label);
    font-weight: 900;
    color: var(--muted);
    font-size: .75rem;
    text-transform: uppercase;
  }

  /* Actions row */
  .pos-row-actions{
    justify-content: flex-end;
    gap: 14px;
  }

  .pos-row-actions button{
    font-size: 1.15rem;
  }
}

/* =========================================================
   📱 MOBILE CUSTOMER CARDS – RECTANGULAR, ERP STYLE
========================================================= */

@media (max-width: 820px){

  .pos-table-wrap{
    overflow: visible;
  }

  .pos-table{
    border-spacing: 0 12px;
  }

  .pos-table thead{
    display: none;
  }

  /* Each customer = rectangular card */
  .pos-table tr{
    display: block;
    background: var(--panel);
    border-radius: 14px;          /* rectangular, not pill */
    box-shadow: var(--shadow);
    padding: 14px 14px 10px;
  }

  /* Field rows */
  .pos-table td{
    display: flex;
    flex-direction: column;
    align-items: flex-start;

    padding: 8px 0;
    border: none;
    gap: 2px;
    font-size: .95rem;
  }

  /* Labels */
  .pos-table td::before{
    content: attr(data-label);
    font-size: .72rem;
    font-weight: 900;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  /* Values */
  .pos-table td span,
  .pos-table td{
    text-align: left;
  }

  /* =========================
     ACTIONS – BOTTOM CENTER
  ========================= */

  .pos-table td[data-label="Actions"]{
    margin-top: 10px;
    padding-top: 12px;

    border-top: 1px dashed var(--line);

    align-items: center;
  }

  .pos-row-actions{
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 22px;
  }

  .pos-row-actions button{
    font-size: 1.2rem;
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(14,117,194,.08);
  }

  .pos-row-actions button:hover{
    background: rgba(255,122,24,.16);
  }
}

/* end of mobile cards table view  */

/* =========================================================
   MOBILE & TABLET – CUSTOMER CARDS REFINEMENT
   Applies ONLY on small screens
========================================================= */
@media (max-width: 768px){

  /* Hide table header (mobile pattern) */
  .pos-table thead{
    display:none;
  }

  /* Stack rows as cards */
  .pos-table,
  .pos-table tbody,
  .pos-table tr{
    display:block;
    width:100%;
  }

  /* Individual customer card */
  .pos-table tr{
    background: var(--panel);
    border:1px solid var(--line);
    border-radius:14px;

    padding:12px 14px;
    margin-bottom:12px; /* 👈 gap between cards */

    box-shadow: var(--shadow-soft);
  }

  /* Cells behave like rows */
  .pos-table td{
    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:6px 0; /* 👈 reduced height */
    border:none;
    font-size:.9rem;
  }

  /* First cell (index) hidden */
  .pos-table td:first-child{
    display:none;
  }

  /* Labels using data-title */
  .pos-table td::before{
    content: attr(data-label);
    font-weight:900;
    color: var(--muted);
    font-size:.75rem;
    margin-right:12px;
    flex-shrink:0;
  }

  /* Customer name stronger */
  .pos-table td:nth-child(2){
    font-size:1rem;
    font-weight:900;
    padding-bottom:8px;
  }

  /* Action buttons at bottom center */
  .pos-row-actions{
    justify-content:center;
    margin-top:8px;
    gap:18px;
  }

  .pos-row-actions button{
    font-size:1.1rem;
  }
}

@media (max-width: 768px){

  /* Show index as badge instead of hiding */
  .pos-table td:first-child{
    display:flex;
    justify-content:flex-start;
    padding-bottom:4px;
  }

  /* Style customer number as subtle badge */
  .pos-table td:first-child::before{
    /* content: "No."; */
    margin-right:6px;
    font-size:.7rem;
    font-weight:800;
    color: var(--muted);
  }

  .pos-table td:first-child{
    font-size:.8rem;
    font-weight:900;
    color: var(--deep2);
  }

  /* Slightly tighter card now that number is visible */
  .pos-table tr{
    padding:10px 14px;
  }

  /* Keep number visually separated */
  .pos-table td:first-child{
    border-bottom:1px dashed rgba(12,28,55,.08);
    margin-bottom:6px;
  }
}
