@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Poppins', 'Segoe UI', sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: #1c4a95;
  display: flex;
  align-items: center;
  gap: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.15);
  height: 100%;
  flex-shrink: 0;
}

.topbar-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.topbar-nav {
  display: flex;
  align-items: center;
  flex: 1;
  overflow-x: auto;
  height: 100%;
  scrollbar-width: none;
  min-width: 0;
}
.topbar-nav::-webkit-scrollbar { display: none; }

.topbar-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px;
  height: 100%;
  color: #b8cfe8;
  text-decoration: none;
  font-size: 0.82rem;
  white-space: nowrap;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  flex-shrink: 0;
}

.topbar-link:hover { background: rgba(255,255,255,0.08); color: white; }
.topbar-link.active { color: white; border-bottom-color: #4a9eff; background: rgba(255,255,255,0.08); }

.topbar-icon { font-size: 0.95rem; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 100%;
  border-left: 1px solid rgba(255,255,255,0.15);
  color: white;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2e5f9e;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.topbar-logout {
  background: rgba(255,255,255,0.1);
  border: none;
  color: #f88;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
  flex-shrink: 0;
}
.topbar-logout:hover { background: #c0392b; color: white; }

/* Mobile menu toggle */
.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.3rem;
  padding: 0 14px;
  cursor: pointer;
  height: 100%;
}

/* Mobile dropdown nav */
.topbar-dropdown {
  display: none;
  position: fixed;
  top: 64px; left: 0; right: 0;
  background: #1c4a95;
  z-index: 199;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}
.topbar-dropdown.open { display: flex; }

.topbar-dropdown .topbar-link {
  height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  border-left: none;
}

.topbar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 64px;
  background: rgba(0,0,0,0.4);
  z-index: 198;
}
.topbar-overlay.open { display: block; }

/* ===== MAIN CONTENT ===== */
.page-wrap {
  padding-top: 64px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* CONTAINER */
.container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 20px;
  width: 100%;
  box-sizing: border-box;
}

/* CARD */
.card {
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  margin-bottom: 20px;
  align-self: start;
}
.card h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: #1e3a5f;
  border-bottom: 2px solid #e8edf3;
  padding-bottom: 10px;
}

/* FORM */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #555;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d0d7e2;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: border 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #2e5f9e; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* BUTTONS */
.btn {
  padding: 9px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #2e5f9e; color: white; }
.btn-success { background: #27ae60; color: white; }
.btn-warning { background: #f39c12; color: white; }
.btn-danger { background: #e74c3c; color: white; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th { background: #1e3a5f; color: white; padding: 10px 12px; text-align: left; }
tbody tr:nth-child(even) { background: #f7f9fc; }
tbody td { padding: 9px 12px; border-bottom: 1px solid #eee; vertical-align: middle; }
tbody tr:hover { background: #eef3fb; }

/* BADGE */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }
.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: white;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-left: 4px solid #2e5f9e;
  align-self: start;
}
.stat-card.green { border-left-color: #27ae60; }
.stat-card.red { border-left-color: #e74c3c; }
.stat-card.orange { border-left-color: #f39c12; }
.stat-card .label { font-size: 0.8rem; color: #888; margin-bottom: 6px; }
.stat-card .value { font-size: 1.4rem; font-weight: 700; color: #1e3a5f; }

/* PRODUCT GRID */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px;
}
.product-card {
  background: #f7f9fc;
  border: 2px solid #e0e7f0;
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.product-card:hover { border-color: #2e5f9e; background: #eef3fb; transform: translateY(-2px); }
.product-card.selected { border-color: #27ae60; background: #eafaf1; }
.product-card.out-of-stock { opacity: 0.5; cursor: not-allowed; }
.product-card .prod-icon { font-size: 2rem; margin-bottom: 8px; }
.product-card .prod-name { font-size: 0.82rem; font-weight: 600; color: #333; margin-bottom: 4px; }
.product-card .prod-price { font-size: 0.8rem; color: #2e5f9e; font-weight: 700; }
.product-card .prod-stock { font-size: 0.72rem; color: #888; margin-top: 3px; }
.product-card .qty-badge {
  position: absolute; top: -8px; right: -8px;
  background: #27ae60; color: white;
  border-radius: 50%; width: 22px; height: 22px;
  font-size: 0.75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* SEARCH */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search-bar input {
  flex: 1; padding: 9px 12px;
  border: 1px solid #d0d7e2; border-radius: 6px;
  font-size: 0.9rem; min-width: 200px;
}
.search-bar select { padding: 9px 12px; border: 1px solid #d0d7e2; border-radius: 6px; font-size: 0.9rem; }

/* CART */
.cart-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #eee; font-size: 0.88rem; }
.cart-item .item-name { flex: 1; }
.cart-item .item-qty { display: flex; align-items: center; gap: 6px; }
.cart-item .item-qty button { width: 24px; height: 24px; border: 1px solid #ccc; background: white; border-radius: 4px; cursor: pointer; font-size: 0.9rem; font-weight: 700; }
.cart-item .item-total { min-width: 90px; text-align: right; font-weight: 600; }
.cart-total { font-size: 1.1rem; font-weight: 700; text-align: right; padding-top: 12px; color: #1e3a5f; }

/* LOGIN */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a5f, #2e5f9e); width: 100%; }
.login-box { background: white; border-radius: 14px; padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.login-box h1 { text-align: center; color: #1e3a5f; margin-bottom: 6px; font-size: 1.5rem; }
.login-box p { text-align: center; color: #888; font-size: 0.85rem; margin-bottom: 24px; }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: white; border-radius: 12px; padding: 28px; width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.modal h3 { margin-bottom: 18px; color: #1e3a5f; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* NOTA PRINT */
@media print {
  body * { visibility: hidden; }
  #nota-print, #nota-print * { visibility: visible; }
  #nota-print { position: fixed; inset: 0; background: white; padding: 20px; font-family: monospace; font-size: 12px; }
}
#nota-print { display: none; }
.nota-content { font-family: monospace; font-size: 13px; line-height: 1.6; border: 1px dashed #ccc; padding: 16px; border-radius: 6px; background: #fafafa; white-space: pre-wrap; }

/* ALERT */
.alert { padding: 10px 16px; border-radius: 6px; margin-bottom: 14px; font-size: 0.88rem; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* LAYOUT */
.two-col { display: grid; grid-template-columns: 1fr 360px; gap: 20px; align-items: start; }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr 320px; }
  .topbar-brand span { display: none; }
}

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .topbar-nav { display: none; }
  .topbar-toggle { display: flex; align-items: center; }
  .topbar-user span { display: none; }
  .container { margin: 16px auto; padding: 0 12px; }
  .card { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card .value { font-size: 1.1rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); max-height: 360px; }
  .search-bar input { min-width: 0; }
}

@media (max-width: 600px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .value { font-size: 1rem; }
  .stat-card .label { font-size: 0.72rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  .product-card { padding: 10px 8px; }
  .product-card .prod-icon { font-size: 1.6rem; }
  .product-card .prod-name { font-size: 0.75rem; }
  .product-card .prod-price { font-size: 0.7rem; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 7px 8px; }
  .btn { padding: 8px 12px; font-size: 0.85rem; }
  .btn-group { flex-direction: column; }
  .btn-group .btn { width: 100%; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar input, .search-bar select { width: 100%; min-width: 0; }
  .cart-item .item-total { min-width: 70px; font-size: 0.82rem; }
  .login-box { padding: 28px 20px; margin: 16px; }
  .modal { padding: 20px 16px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
