/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #4f8ef7;
  --accent-hover: #6aa3ff;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #8892a4;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ===== STATUS BAR ===== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s;
}
.status-bar.disconnected { background: #2a1f1f; border: 1px solid #5c2a2a; color: #fc8181; }
.status-bar.connected    { background: #1a2e1a; border: 1px solid #2a5c2a; color: var(--success); }

.badge {
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 12px;
  animation: pulse 1.5s infinite;
}
.badge.hidden { display: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--accent);
}

/* ===== FORM GRID ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="password"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 11px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
input:focus { border-color: var(--accent); }

/* ===== BUTTONS ===== */
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--accent);   color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover { filter: brightness(1.1); }
.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-lg  { padding: 12px 28px; font-size: 16px; }

/* ===== ORDER ROWS ===== */
.order-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.order-row .inp-id  { flex: 2; min-width: 120px; }
.order-row .inp-jml { flex: 1; min-width: 70px; }
.order-row .inp-bot { flex: 2; min-width: 120px; }

/* ===== LOG BOX ===== */
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.log-header h2 { margin-bottom: 0; }

#log-box {
  background: #0a0c14;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 12px;
  height: 320px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  scroll-behavior: smooth;
}

.log-line { margin-bottom: 2px; }
.log-line.INFO    { color: #a0aec0; }
.log-line.SUCCESS { color: var(--success); }
.log-line.ERROR   { color: var(--danger); }
.log-line.WARNING { color: var(--warning); }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}
.modal-box h3 { font-size: 17px; color: var(--accent); }
.modal-box p  { color: var(--text-muted); font-size: 13px; }

/* ===== HISTORY TABLE ===== */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.history-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

.history-table tr:last-child td { border-bottom: none; }

.history-table tr:hover td {
  background: var(--surface2);
}

/* status badge di dalam tabel */
.badge-success {
  background: rgba(34,197,94,.15);
  color: var(--success);
  border: 1px solid rgba(34,197,94,.3);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-error {
  background: rgba(239,68,68,.15);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  header { flex-direction: column; align-items: flex-start; }
  .btn-lg { width: 100%; justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
}
