/* ==========================================================================
   APLIKASI NOTA MANDIRI88 - MODERN APP STYLES
   ========================================================================== */

:root {
  --primary: #0a3371;
  --primary-hover: #07234f;
  --primary-light: #e8f1fc;
  --accent-red: #e51b24;
  --accent-red-hover: #c4121a;
  
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #0f172a;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  --font-family: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* ==========================================================================
   SIDEBAR NAVIGATION
   ========================================================================== */
.app-sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #1e293b;
  z-index: 10;
}

.sidebar-header {
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1e293b;
}

.sidebar-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  background: white;
  padding: 3px 6px;
  border-radius: var(--radius-sm);
}

.sidebar-title-group h2 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
  line-height: 1.2;
}

.sidebar-title-group p {
  font-size: 11px;
  color: #94a3b8;
}

.sidebar-menu {
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.nav-item.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(10, 51, 113, 0.4);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e293b;
  font-size: 11px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */
.app-main {
  flex-grow: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.app-topbar {
  height: 60px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}

.topbar-title h1 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(10, 51, 113, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(10, 51, 113, 0.35);
}

.btn-accent {
  background-color: var(--accent-red);
  color: #ffffff;
}

.btn-accent:hover {
  background-color: var(--accent-red-hover);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-success {
  background-color: #10b981;
  color: #ffffff;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: #fee2e2;
  color: #dc2626;
}

.btn-danger:hover {
  background-color: #fecaca;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 4px;
}

.btn-sm svg {
  width: 13px;
  height: 13px;
}

.btn-icon {
  padding: 7px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   VIEW CONTAINERS (Editor, Riwayat, Master Barang, Settings)
   ========================================================================== */
.view-section {
  display: none;
  flex-grow: 1;
  height: calc(100vh - 60px);
  overflow: hidden;
}

.view-section.active {
  display: flex;
}

/* ==========================================================================
   EDITOR & LIVE PREVIEW SPLIT SCREEN
   ========================================================================== */
.editor-split-container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.app-editor-pane {
  width: 48%;
  min-width: 460px;
  height: 100%;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px 24px;
  gap: 20px;
}

.app-preview-pane {
  flex-grow: 1;
  height: 100%;
  background-color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 30px 20px;
  position: relative;
  background-image: radial-gradient(#475569 1px, transparent 1px);
  background-size: 20px 20px;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-lg);
}

.preview-zoom-label {
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 500;
  margin-left: 4px;
}

.doc-switcher {
  display: flex;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 3px;
  gap: 3px;
}

.doc-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.doc-tab-btn:hover {
  color: #ffffff;
}

.doc-tab-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Form Styles */
.form-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 10px;
  margin-bottom: 2px;
}

.form-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.form-control {
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: #ffffff;
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 56px;
}

/* Dynamic Items Table in Form */
.form-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.form-items-table th {
  background: #f8fafc;
  padding: 8px 6px;
  font-weight: 700;
  color: #475569;
  border-bottom: 2px solid var(--border-color);
  text-align: left;
}

.form-items-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.item-input {
  width: 100%;
  padding: 6px 8px;
  font-size: 12.5px;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.item-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.item-subtotal-text {
  font-weight: 700;
  color: var(--primary);
  text-align: right;
  padding-right: 4px;
}

/* ==========================================================================
   MANAGEMENT VIEWS (RIWAYAT & MASTER BARANG)
   ========================================================================== */
.view-content-wrapper {
  padding: 24px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.data-table-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.data-table-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  gap: 14px;
}

.search-box {
  position: relative;
  max-width: 320px;
  width: 100%;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 13px;
  font-family: inherit;
}

.search-box svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #94a3b8;
}

.crud-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.crud-table th {
  background-color: #f8fafc;
  padding: 12px 16px;
  font-weight: 700;
  color: #475569;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.crud-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
  vertical-align: middle;
}

.crud-table tbody tr:hover {
  background-color: #f8fafc;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
}

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* Empty state */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: #cbd5e1;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.show {
  display: flex;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease-out;
  border-left: 4px solid var(--primary);
}

.toast.toast-success { border-left-color: #10b981; }
.toast.toast-error { border-left-color: #ef4444; }

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   PIN LOCK SCREEN OVERLAY
   ========================================================================== */
.pin-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: radial-gradient(circle at 50% 35%, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(16px);
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
}

.pin-lock-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  pointer-events: none;
}

.pin-lock-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), 0 0 30px rgba(56, 189, 248, 0.1);
  text-align: center;
  color: #ffffff;
  animation: pinCardPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pinCardPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.pin-lock-brand {
  margin-bottom: 20px;
}

.pin-lock-logo {
  height: 56px;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3));
}

.pin-lock-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #f8fafc;
  margin: 0;
}

.pin-lock-subtitle {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

.pin-display-wrapper {
  margin: 24px 0 16px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pin-dot.filled {
  background: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
  transform: scale(1.15);
}

.pin-dot.success {
  background: #22c55e;
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.8);
}

.pin-dot.error {
  background: #ef4444;
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
}

.pin-feedback-msg {
  min-height: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #ef4444;
  margin-top: 6px;
  transition: opacity 0.2s;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 290px;
  margin: 0 auto;
}

.pin-key {
  height: 56px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.pin-key:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.pin-key:active {
  transform: translateY(1px) scale(0.96);
  background: rgba(56, 189, 248, 0.25);
}

.pin-key-action {
  font-size: 14px;
  color: #94a3b8;
  font-weight: 600;
}

.pin-key-action:hover {
  color: #ffffff;
}

.pin-remember-box {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: #94a3b8;
}

.pin-remember-box input[type="checkbox"] {
  cursor: pointer;
  accent-color: #38bdf8;
}

.shake {
  animation: shakeKey 0.4s ease-in-out;
}

@keyframes shakeKey {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.btn-lock-sidebar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 0 12px 10px 12px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lock-sidebar:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #ffffff;
  border-color: #ef4444;
}

