/* TIONGKE - Mobile App Style */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables */
:root {
  --primary: #111827;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --light: #f3f4f6;
  --success: #059669;
  --success-bg: #d1fae5;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --topbar-h: 56px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

/* Reset */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* App Layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
}

/* Top App Bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.top-bar h1 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.top-bar-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.2s;
}

.btn-icon:hover {
  background: var(--light);
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

/* Content Area */
.content {
  flex: 1;
  margin-top: var(--topbar-h);
  margin-bottom: calc(var(--nav-h) + var(--safe-bottom));
  padding: 16px;
  overflow-y: auto;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.625rem;
  font-weight: 500;
  transition: color 0.2s;
  min-width: 56px;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item span {
  line-height: 1;
}

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
}

.card-body {
  padding: 16px;
}

/* Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card .stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-card .stat-icon.blue {
  background: var(--accent-light);
  color: var(--accent);
}

.stat-card .stat-icon.green {
  background: var(--success-bg);
  color: var(--success);
}

.stat-card .stat-icon.yellow {
  background: var(--warning-bg);
  color: var(--warning);
}

.stat-card .stat-icon.red {
  background: var(--danger-bg);
  color: var(--danger);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--muted);
}

/* List */
.list {
  padding: 0;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-left {
  flex: 1;
  min-width: 0;
}

.list-item-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.list-item-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.list-item-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.list-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  height: 44px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--light);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #047857;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* FAB (Floating Action Button) */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  right: calc(50% - 240px + 16px);
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 90;
}

.fab svg {
  width: 24px;
  height: 24px;
}

.fab:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}

.fab:active {
  transform: scale(0.95);
}

@media (max-width: 480px) {
  .fab {
    right: 16px;
  }
}

/* Tables */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tr:last-child td {
  border-bottom: none;
}

table tr:hover td {
  background: var(--light);
}

.table-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s;
}

.form-group textarea {
  height: auto;
  min-height: 100px;
  padding: 12px 14px;
  resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--muted);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.badge-pending {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-approved, .badge-verified {
  background: var(--success-bg);
  color: var(--success);
}

.badge-rejected {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-active {
  background: var(--success-bg);
  color: var(--success);
}

.badge-inactive {
  background: var(--light);
  color: var(--muted);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: 20px 20px 0 0;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h3 {
  font-size: 1.0625rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.2s;
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-close:hover {
  background: var(--border);
}

.modal-body {
  padding: 16px;
}

.modal-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
}

.modal-footer .btn {
  flex: 1;
}

/* Alerts */
.alert {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.alert-success {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fde68a;
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.page-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Login Page */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 360px;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo .logo-icon {
  width: 64px;
  height: 64px;
  background: var(--accent);
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.login-logo .logo-icon svg {
  width: 32px;
  height: 32px;
  color: white;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.login-logo p {
  font-size: 0.875rem;
  color: var(--muted);
}

.login-form .form-group input {
  height: 48px;
  font-size: 1rem;
}

.login-form .btn {
  height: 48px;
  font-size: 1rem;
  margin-top: 8px;
}

/* Action List (for pages like stock_out) */
.action-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.action-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.action-item-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.action-item-sub {
  font-size: 0.8125rem;
  color: var(--muted);
}

.action-item-actions {
  display: flex;
  gap: 8px;
}

/* Section Title */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--border);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--muted);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* User Info in Bottom Nav */
.user-info {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 99;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Utility */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }
