/* =====================================================================
   POS Multi Usaha - Stylesheet utama (Vanilla CSS, tanpa framework)
   ===================================================================== */

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-light: #dbeafe;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-danger: #dc2626;
  --color-danger-light: #fee2e2;
  --color-warning: #d97706;
  --color-warning-light: #fef3c7;
  --color-info: #0891b2;

  --color-bg: #f4f6fb;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-sidebar-bg: #111827;
  --color-sidebar-text: #cbd5e1;
  --color-sidebar-active: #2563eb;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --sidebar-width: 250px;
  --header-height: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 600; }
p { margin: 0 0 .75rem; }

/* -------------------- Layout Aplikasi -------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 40;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.2rem;
  font-weight: 700; font-size: 1.05rem;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--color-primary); }

.sidebar-section { padding: .75rem 1.2rem .25rem; font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: #64748b; }

.sidebar-nav { list-style: none; margin: 0; padding: .5rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1.2rem;
  color: var(--color-sidebar-text);
  font-size: .88rem;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar-nav a.active {
  background: rgba(37,99,235,.15);
  border-left-color: var(--color-sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar-nav .icon { width: 18px; text-align: center; }

.main-wrap {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky; top: 0; z-index: 30;
}
.topbar .menu-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--color-text); }
.topbar-title { font-weight: 600; font-size: 1rem; }
.topbar-user { display: flex; align-items: center; gap: .8rem; }
.topbar-user .badge-role { font-size: .72rem; }
.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: .5rem; background: none; border: none; cursor: pointer; font: inherit; color: var(--color-text); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.user-menu-dropdown {
  position: absolute; right: 0; top: 42px; background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); min-width: 180px; display: none; overflow: hidden;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown a, .user-menu-dropdown button {
  display: block; width: 100%; text-align: left; padding: .6rem 1rem; background: none; border: none; cursor: pointer;
  font: inherit; color: var(--color-text);
}
.user-menu-dropdown a:hover, .user-menu-dropdown button:hover { background: var(--color-bg); text-decoration: none; }

.content { padding: 1.5rem; flex: 1; }
.content-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.content-header h1 { font-size: 1.35rem; }
.breadcrumb { font-size: .8rem; color: var(--color-text-muted); margin-bottom: .25rem; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }

/* -------------------- Kartu & Grid -------------------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
}
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; }
.card-body { padding: 1.25rem; }
.card-footer { padding: .9rem 1.25rem; border-top: 1px solid var(--color-border); }

.grid { display: grid; gap: 1.25rem; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px) { .grid-cols-4 { grid-template-columns: repeat(2, 1fr); } .grid-cols-3 { grid-template-columns: repeat(2,1fr);} }
@media (max-width: 640px) { .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; } }

.stat-card { display: flex; flex-direction: column; gap: .35rem; padding: 1.25rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-bottom: .25rem; }
.stat-icon.blue { background: var(--color-primary-light); color: var(--color-primary-dark); }
.stat-icon.green { background: var(--color-success-light); color: var(--color-success); }
.stat-icon.amber { background: var(--color-warning-light); color: var(--color-warning); }
.stat-icon.red { background: var(--color-danger-light); color: var(--color-danger); }

/* -------------------- Form -------------------- */
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
label { display: block; font-weight: 600; font-size: .82rem; margin-bottom: .35rem; }
label .req { color: var(--color-danger); }

input[type=text], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], input[type=email], input[type=tel],
select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff;
  color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea { resize: vertical; min-height: 80px; }
.field-error { display: block; color: var(--color-danger); font-size: .78rem; margin-top: .3rem; }
.form-hint { font-size: .78rem; color: var(--color-text-muted); margin-top: .3rem; }
.input-group { display: flex; }
.input-group input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* -------------------- Tombol -------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .85rem;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(.92); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: .35rem .65rem; font-size: .78rem; }
.btn-lg { padding: .75rem 1.4rem; font-size: .95rem; }
.btn-secondary { background: #64748b; }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary-light); }
.btn-success { background: var(--color-success); }
.btn-danger { background: var(--color-danger); }
.btn-warning { background: var(--color-warning); }
.btn-block { width: 100%; }
.btn-icon { padding: .45rem .55rem; }

/* -------------------- Tabel -------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead th {
  text-align: left; padding: .7rem .85rem; background: #f8fafc;
  border-bottom: 2px solid var(--color-border); font-size: .74rem;
  text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted);
  white-space: nowrap;
}
tbody td { padding: .7rem .85rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.table-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* -------------------- Badge & Alert -------------------- */
.badge { display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-info { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-gray { background: #e2e8f0; color: #475569; }

.alert { padding: .85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .87rem; border: 1px solid transparent; }
.alert-success { background: var(--color-success-light); color: #14532d; border-color: #bbf7d0; }
.alert-error { background: var(--color-danger-light); color: #7f1d1d; border-color: #fecaca; }
.alert-warning { background: var(--color-warning-light); color: #78350f; border-color: #fde68a; }
.alert-info { background: var(--color-primary-light); color: #1e3a8a; border-color: #bfdbfe; }

/* -------------------- Login -------------------- */
.guest-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e293b,#0f172a); padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2rem; }
.login-card h1 { text-align: center; font-size: 1.3rem; margin-bottom: .1rem; }
.login-card .sub { text-align: center; color: var(--color-text-muted); font-size: .85rem; margin-bottom: 1.5rem; }
.login-logo { width: 56px; height: 56px; border-radius: var(--radius-md); background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; margin: 0 auto 1rem; }

/* -------------------- POS Kasir -------------------- */
.pos-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 1024px) { .pos-layout { grid-template-columns: 1fr; } }
.pos-search { margin-bottom: 1rem; }
.pos-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: .75rem; max-height: 65vh; overflow-y: auto; padding-right: .25rem; }
.pos-product-card { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: .8rem; cursor: pointer; background: #fff; text-align: left; }
.pos-product-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.pos-product-card .p-name { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.pos-product-card .p-price { color: var(--color-primary-dark); font-weight: 700; font-size: .85rem; }
.pos-product-card .p-stock { font-size: .72rem; color: var(--color-text-muted); }
.pos-cart-items { max-height: 40vh; overflow-y: auto; }
.pos-cart-row { display: flex; align-items: center; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--color-border); }
.pos-cart-row .name { flex: 1; font-size: .82rem; }
.pos-cart-row .qty-input { width: 55px; text-align: center; }
.pos-summary-row { display: flex; justify-content: space-between; padding: .3rem 0; font-size: .88rem; }
.pos-summary-row.total { font-size: 1.15rem; font-weight: 700; border-top: 1px dashed var(--color-border); margin-top: .5rem; padding-top: .6rem; }
.qty-btn { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--color-border); background: #fff; cursor: pointer; font-weight: 700; }

/* -------------------- Receipt (Struk) -------------------- */
.receipt { width: 300px; margin: 0 auto; font-family: 'Courier New', monospace; font-size: 12px; color: #000; background: #fff; padding: 1rem; }
.receipt h2 { text-align: center; font-size: 14px; margin-bottom: .1rem; }
.receipt .center { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: .5rem 0; }
.receipt table { width: 100%; font-size: 11px; }
.receipt td { padding: 2px 0; border: none; }

/* -------------------- Utilitas -------------------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: .5rem; } .gap-md { gap: 1rem; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.font-mono { font-family: 'Courier New', monospace; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--color-text-muted); }
.filter-bar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filter-bar .form-group { margin-bottom: 0; min-width: 160px; }
.pagination { display: flex; gap: .35rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .4rem .7rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: .82rem; }
.pagination a:hover { background: var(--color-bg); text-decoration: none; }
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 60; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius-md); max-width: 480px; width: 100%; box-shadow: var(--shadow-md); }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: .5rem; }

/* -------------------- Responsive Sidebar -------------------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .topbar .menu-toggle { display: inline-flex; }
  .sidebar-backdrop.open { display: block; }
}

/* -------------------- Cetak -------------------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
}
