/* MISS N MAAM POS – Global Styles
   Scope: All pages (Login, POS, Receipts, Products, Admin Users)
   Notes:
   - Keep selectors generic; pages share a single stylesheet.
   - Includes print styles for 80mm receipts.
*/

/* ========== CSS Variables ========== */
:root{
  --bg: #f5f8fb;
  --panel: #ffffff;
  --border: #e5edf1;
  --muted: #667085;
  --text: #1f2937;
  --brand: #0ea5e9;
  --brand-700: #0284c7;
  --accent: #22c55e;
  --danger: #ef4444;
  --ring: #cfe3ea;

  --font: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

/* ========== Reset / Base ========== */
*{ box-sizing: border-box; }
html, body{ height: 100%; }
html{ -webkit-text-size-adjust: 100%; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img{ max-width:100%; height:auto; display:block; }
a{ color: var(--brand); text-decoration: none; }
a:hover{ text-decoration: underline; }
hr{ border:0; border-top:1px solid var(--border); margin:12px 0; }

.hide{ display: none !important; }
.no-print{}

/* ========== Layout Shell ========== */
.page-body{ min-height: 100vh; display:flex; flex-direction: column; }
.page-container{ width: 100%; max-width: 1100px; margin: 16px auto; padding: 0 16px; flex:1; }

/* ========== Top Bar ========== */
.topbar{
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display:flex; align-items:center; gap:12px; justify-content: space-between;
  position: sticky; top:0; z-index: 20;
}
.topbar .logo, .topbar .logo-wrap{
  display:flex; align-items:center; gap:10px; font-weight:700; letter-spacing:.4px;
}
.logo-img{
  width:38px; height:38px; border-radius:50%; border:1px solid #eee; object-fit:cover; background:#fff;
}
.topbar .clock{ color: var(--muted); font-variant-numeric: tabular-nums; }
.topbar .top-actions{ display:flex; align-items:center; gap:8px; flex-wrap: wrap; }
.topbar .user{ color: var(--muted); }

/* ========== Cards / Sections ========== */
.card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 8px 28px rgba(16,24,40,.06);
}
.section-title{
  display:flex; align-items:center; justify-content: space-between;
  font-weight:700; margin: 6px 0 12px;
}
.section-title .brand-text{ letter-spacing:.4px; }
.tag{
  display:inline-block; font-size:12px; color: var(--muted);
  background:#f3f7fa; border:1px solid var(--border); border-radius: 999px;
  padding:2px 8px; margin-left:8px;
}

/* ========== Buttons ========== */
.btn{
  --bg: #f5f8fb; --fg: #111827; --bd: var(--border);
  appearance:none; border:1px solid var(--bd);
  background: var(--bg); color: var(--fg);
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
  font-weight:600; font-size: 14px; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:hover{ background:#eef6fb; }
.btn:disabled{ opacity:.6; cursor:not-allowed; }
.btn.primary{ --bg: var(--brand); --fg:#fff; --bd: transparent; }
.btn.primary:hover{ background: var(--brand-700); }
.btn.danger{ --bg:#fee2e2; --fg:#991b1b; --bd:#fecaca; }
.btn.danger:hover{ background:#fecaca; }
.btn.sm{ padding:6px 10px; font-size: 13px; border-radius: 8px; }

.icon-btn{
  background:transparent; border:0; padding:6px 8px; cursor:pointer;
  border-radius:8px; font-size: 16px;
}
.icon-btn:hover{ background:#f2f6f9; }
.icon-btn.delete{ color: var(--danger); }
.icon-btn.whatsapp{ color:#22c55e; }
.icon-btn.print{ color:#0ea5e9; }

/* ========== Forms ========== */
label{ font-size: 13px; color:#374151; display:block; margin: 0 0 6px; }
input[type="text"], input[type="number"], input[type="password"], input[type="date"], select{
  width: 100%;
  border:1px solid var(--ring);
  background:#fff; color:#111827;
  border-radius: 10px;
  padding: 10px 12px;
  outline:0;
  font-size: 15px;
}
input::placeholder{ color:#9aa7b2; }
.form-grid{
  display:grid; grid-template-columns: repeat(12, 1fr); gap: 10px;
}
.form-item{ display:block; }

/* Toolbar inline helpers */
.toolbar{ display:flex; align-items:center; gap:10px; flex-wrap: wrap; margin-bottom: 8px; }

/* ========== Tables ========== */
.table{
  width:100%; border-collapse: collapse; border-spacing: 0;
  background:#fff; overflow: hidden; border-radius: 10px;
}
.table thead th{
  font-size: 13px; text-align:left; color:#4b5563; font-weight:700;
  border-bottom: 1px solid var(--border); background: #f7fbfe; padding: 10px;
}
.table tbody td{
  padding: 10px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tbody tr:hover{ background:#f9fbfd; }

/* ========== Grid utilities ========== */
.grid.two{ display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.mb-3{ margin-bottom: 14px; }

/* ========== Search dropdown (POS) ========== */
.search-results{
  position: absolute; background:#fff; border:1px solid var(--border);
  border-radius:10px; box-shadow: 0 8px 28px rgba(16,24,40,.08);
  z-index: 50; padding: 6px; display:none; max-height: 320px; overflow:auto;
}
.sr-item{
  padding:8px 10px; border-radius:8px; cursor:pointer; font-size: 14px;
}
.sr-item:hover, .sr-item:focus{ outline:0; background:#f2f7fb; }

/* ========== POS Layout ========== */
.pos-grid{
  display:grid; grid-template-columns: 1.25fr .9fr; gap: 14px;
  align-items: start; margin: 14px 0;
}
.left-pane{ position: relative; }
.receipt-pane{
  position: sticky; top: 76px; align-self: start;
  background: #fff; border:1px solid var(--border); border-radius: 12px; padding: 10px;
}
.pay-actions{
  display:grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start;
  margin-top: 10px;
}
.summary{ background:#fff; border:1px solid var(--border); border-radius: 12px; padding: 10px; }
.summary > div{ margin: 6px 0; }

.side-buttons{ display:flex; gap: 8px; margin-top: 10px; }

/* Receipt visuals */
.receipt-header{
  display:flex; flex-direction: column; align-items:center;
  gap: 4px; margin-bottom:6px; text-align:center;
}
.brand-circle{
  width: 58px; height: 58px; border-radius:50%;
  border:1px solid #eee; overflow:hidden; background:#fff;
  display:flex; align-items:center; justify-content:center;
  margin: 0 auto 6px auto; /* top-center */
}
.brand-circle img{ max-width:100%; max-height:100%; height:auto; }
.shop-info h2{ margin:0 0 2px 0; font-size: 16px; }

/* Payment badge */
.receipt-paymode{ font-style: italic; color:#111; margin: 6px 0; }

/* Receipt table (narrow layout friendly) */
.receipt-table{ width:100%; border-collapse: collapse; }
.receipt-table th, .receipt-table td{
  padding: 6px 4px; border-bottom: 1px dashed #b9c7d4; font-size: 13px;
}
.receipt-table th{ text-align:left; color:#374151; }
.receipt-table .selected{ background:#f7fbff; }
.receipt-totals{ margin-top: 6px; padding-top: 6px; border-top: 1px dashed #b9c7d4; }
.receipt-totals .strong{ font-weight: 800; }

/* Delete button inside receipt rows */
.row-del{
  appearance:none; border:0; background:#fee2e2; color:#991b1b;
  padding: 0 6px; border-radius: 6px; margin-right: 6px; cursor: pointer;
}
.row-del:hover{ background:#fecaca; }

/* ========== Modals ========== */
.modal-backdrop{
  position: fixed; inset: 0; background: rgba(17,24,39,.45);
  display: grid; place-items: center; z-index: 60;
}
.modal-backdrop[hidden]{ display:none !important; }
.modal-backdrop.show{ animation: fadeIn .12s ease-out both; }
@keyframes fadeIn { from{ opacity:0 } to{ opacity:1 } }

.modal{
  width: 640px; max-width: calc(100vw - 24px);
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(16,24,40,.18);
  overflow: hidden;
}
.modal-header{
  display:flex; align-items:center; justify-content: space-between;
  padding: 10px 12px; border-bottom:1px solid var(--border); background:#f7fbfe;
}
.modal-body{ padding: 12px; }
.modal-toolbar{
  display:flex; align-items:center; gap:8px; padding:8px 12px; border-bottom:1px solid var(--border);
}

/* ========== Receipts page tweaks ========== */
.page-container .text-muted{ color: var(--muted); }

/* ========== Print (80mm receipt) ========== */
@media print {
  /* Hide site chrome */
  .topbar, .left-pane, .side-buttons, .no-print, .modal-backdrop { display: none !important; }
  body{ background: #fff !important; margin: 0; }
  .page-container{ margin: 0; padding: 0; }

  /* Constrain page width and center everything for thermal printers */
  @page { size: 80mm auto; margin: 0; }
  html, body{
    width: 80mm !important;
    margin-left: auto !important;
    margin-right: auto !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Expand and center receipt area on ALL hosts (POS + Receipts) */
  .receipt-pane,
  #receiptPane,
  #receiptRenderHost,
  #receiptRenderHost > .receipt-pane,
  #receiptRenderHost > *{
    width: 80mm !important;
    max-width: 80mm !important;
    margin-left: auto !important;
    margin-right: auto !important;
    display: block !important;
    float: none !important;
    clear: both !important;
    transform: none !important;
  }

  /* Unhide hidden hosts during print */
  .hide, [hidden]{
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Center header/logo and tighten fonts for receipt */
  .receipt-header, .receipt-header .shop-info, .receipt-header .brand-title{ text-align:center !important; }
  .brand-circle{
    width: 48px !important; height: 48px !important;
    margin: 2mm auto 2mm auto !important;
    display:flex !important; align-items:center !important; justify-content:center !important;
  }
  .brand-circle img{ max-width:100% !important; max-height:100% !important; }

  .receipt-table th, .receipt-table td{ font-size: 11.5px !important; padding: 4px 2px !important; }
  .shop-info h2{ font-size: 14px !important; }
  .receipt-paymode, .receipt-totals{ font-size: 12px !important; }

  /* Typical column alignment */
  .receipt-table th:first-child,
  .receipt-table td:first-child { text-align: left !important; }
  .receipt-table th:not(:first-child),
  .receipt-table td:not(:first-child) { text-align: right !important; }

  /* Avoid page breaks within receipt blocks */
  .receipt-header, .receipt-table, .receipt-totals{ break-inside: avoid; page-break-inside: avoid; }
}

/* ========== Small screens ========== */
@media (max-width: 980px){
  .pos-grid{ grid-template-columns: 1fr; }
  .receipt-pane{ position: static; }
}
@media (max-width: 640px){
  .topbar{ flex-wrap: wrap; gap: 8px; }
  .form-grid{ grid-template-columns: repeat(6, 1fr); }
  .grid.two{ grid-template-columns: 1fr; }
}

/* ========== Utility helpers ========== */
.text-muted{ color: var(--muted); }
.text-right{ text-align:right; }
.text-center{ text-align:center; }

/* ========== Legacy compatibility ========== */
/* Older pages used .logo without wrap – preserve spacing */
.logo{ font-weight:700; }

/* Searchbar style used on products.php */
.searchbar{
  display:flex; gap:8px; align-items:center;
  background:#fff; border:1px solid var(--ring); border-radius:12px;
  padding:6px 10px; width:100%; max-width:520px;
  box-shadow:0 4px 10px rgba(0,0,0,.03);
}
.searchbar input{ flex:1; border:none; outline:none; padding:8px 6px; border-radius:8px; }
.searchbar .icon{ color:#6b7c8a; }