/* ═══════════════════════════════════════════════════════════════════════════
   Crewer – CSS3 Stylesheet (Mobile-first PWA)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Reset & Variables ──────────────────────────────────────────────────── */
:root {
  --bg:        #0f172a;
  --bg-card:   #1e293b;
  --bg-input:  #334155;
  --text:      #f1f5f9;
  --text-dim:  #94a3b8;
  --primary:   #3b82f6;
  --primary-h: #2563eb;
  --success:   #22c55e;
  --danger:    #ef4444;
  --danger-h:  #dc2626;
  --warning:   #f59e0b;
  --masuk:     #22c55e;
  --keluar:    #ef4444;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  zoom: 1.25;
  -webkit-text-size-adjust: 100%;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  touch-action: pan-x pan-y;
  -ms-touch-action: pan-x pan-y;
}

/* ─── Screens ────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ─── Login ──────────────────────────────────────────────────────────────── */
#loginScreen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px 28px 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-logo  { font-size: 56px; margin-bottom: 8px; }
.login-title { font-size: 28px; font-weight: 800; letter-spacing: 4px; }
.login-subtitle { color: var(--text-dim); margin-bottom: 28px; font-size: 16px; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
  text-align: left;
}
.form-group label {
  display: block;
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-group textarea { resize: vertical; }

.form-row {
  display: flex;
  gap: 12px;
}
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}
.form-actions .btn { flex: 1; }

.error-msg {
  margin-top: 14px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: rgba(239,68,68,.15);
  color: var(--danger);
  font-size: 15px;
  text-align: center;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: var(--danger-h); }
.btn-outline   { background: transparent; color: var(--text); border: 1px solid var(--bg-input); }
.btn-block     { width: 100%; }
.btn-sm        { padding: 8px 14px; font-size: 15px; }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background .2s;
}
.btn-icon:hover { background: var(--bg-input); }

/* ─── App Header ─────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) calc(16px + var(--safe-right)) 12px calc(16px + var(--safe-left));
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
  width: 100%;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo   { font-size: 28px; }
.header-title  { font-size: 18px; font-weight: 700; line-height: 1.2; }
.header-vessel { font-size: 14px; color: var(--text-dim); }
.header-right  { display: flex; align-items: center; gap: 6px; }

.sync-badge {
  font-size: 14px;
  transition: color .3s;
}
.sync-badge.online  { color: var(--success); }
.sync-badge.offline { color: var(--danger); }
.sync-badge.syncing { color: var(--warning); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}

/* ─── Summary Cards ──────────────────────────────────────────────────────── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
}
.card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.card-label { font-size: 13px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.card-value { font-size: 18px; font-weight: 700; }
.card-masuk  .card-value { color: var(--masuk); }
.card-keluar .card-value { color: var(--keluar); }
.card-saldo  .card-value { color: var(--primary); }

/* ─── Search Bar ─────────────────────────────────────────────────────────── */
.search-bar {
  padding: 12px 16px 0;
}
.input-search {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--bg-input);
  border-radius: 50px;
  color: var(--text);
  font-size: 16px;
  transition: border-color .2s;
}
.input-search:focus {
  outline: none;
  border-color: var(--primary);
}
.input-search::placeholder {
  color: var(--text-dim);
}

/* ─── Filter Bar ─────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}
.filter-sep { color: var(--text-dim); font-size: 15px; }
.input-sm {
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--bg-input);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  flex: 1;
  min-width: 0;
}
.input-sm:focus { outline: none; border-color: var(--primary); }

/* ─── Transaction List ───────────────────────────────────────────────────── */
.trx-list {
  flex: 1;
  padding: 0 16px 100px;
  overflow-y: auto;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 16px;
}

.trx-item {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform .15s;
  position: relative;
}
.trx-item:active { transform: scale(.985); }

.trx-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}
.trx-badge.masuk  { background: rgba(34,197,94,.15);  color: var(--masuk); }
.trx-badge.keluar { background: rgba(239,68,68,.15);  color: var(--keluar); }

.trx-body { flex: 1; min-width: 0; }
.trx-desc {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trx-meta {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 3px;
}

.trx-amount {
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
}
.trx-amount.masuk  { color: var(--masuk); }
.trx-amount.keluar { color: var(--keluar); }

.trx-offline-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
  background: var(--warning);
  color: #000;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ─── PWA Install Banner ─────────────────────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 12px;
  right: 12px;
  z-index: 89;
  animation: slideUp .3s ease-out;
}
.install-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #1e3a5f, #1e293b);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 4px 20px rgba(59,130,246,.3);
}
.install-banner-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.install-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}
.install-banner-text strong {
  font-size: 16px;
  color: var(--text);
}
.install-banner-text small {
  font-size: 13px;
  color: var(--text-dim);
}
.install-banner-dismiss {
  font-size: 16px;
  opacity: .6;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ─── FAB ────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  border: none;
  box-shadow: 0 4px 16px rgba(59,130,246,.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  transition: transform .2s, background .2s;
}
.fab:hover   { background: var(--primary-h); }
.fab:active  { transform: scale(.9); }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal[hidden] { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px calc(20px + var(--safe-bottom));
  overflow-y: auto;
  animation: slideUp .25s ease-out;
}
.modal-sm { max-width: 340px; border-radius: var(--radius); margin: auto; text-align: center; padding: 28px 24px; }
.modal-sm h3 { margin-bottom: 8px; }
.modal-sm p  { color: var(--text-dim); font-size: 16px; margin-bottom: 20px; }

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 20px; font-weight: 700; }
.modal-close { font-size: 22px; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  z-index: 300;
  animation: fadeInUp .3s ease-out;
  white-space: nowrap;
}
.toast[hidden] { display: none; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--primary); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
[hidden] { display: none !important; }

/* ─── Scrollbar (desktop) ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-input); border-radius: 3px; }

/* ─── Desktop wider layout ───────────────────────────────────────────────── */
@media (min-width: 1024px) {
  .modal-content {
    border-radius: var(--radius);
    margin: auto;
  }
  .modal {
    align-items: center;
  }
}
