/* =============================================================
   design-system.css — LHP Invoice Tracking
   Custom components beyond Tailwind utility classes
   ============================================================= */

/* --- CSS Custom Properties --- */
:root {
  --color-ink-navy: #1B2838;
  --color-stamp-blue: #2563EB;
  --color-stamp-red: #DC2626;
  --color-stamp-amber: #D97706;
  --color-ledger-green: #047857;
  --color-paper: #ffffff;
  --color-typewriter: #374151;
  --color-manila: #faf8f4;
}

/* --- Base --- */
html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
}

/* --- Stamp Badges --- */
.stamp {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.75rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transform: rotate(-1deg);
  border: 1.5px solid currentColor;
  background: transparent;
  white-space: nowrap;
  transition: transform 0.15s ease;
  line-height: 1.4;
}
.stamp:hover {
  transform: rotate(0deg) scale(1.05);
}
.stamp--lengkap,
.stamp--lunas,
.stamp--delivered,
.stamp--success {
  color: var(--color-ledger-green);
  border-color: var(--color-ledger-green);
}
.stamp--pending,
.stamp--received {
  color: var(--color-stamp-amber);
  border-color: var(--color-stamp-amber);
}
.stamp--batal,
.stamp--rejected {
  color: var(--color-stamp-red);
  border-color: var(--color-stamp-red);
}
.stamp--blank {
  color: #9CA3AF;
  border-color: #9CA3AF;
}
.stamp--active,
.stamp--dibuat {
  color: var(--color-stamp-blue);
  border-color: var(--color-stamp-blue);
}

/* --- Pill Badge (alternative for inline metadata) --- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill--lengkap { background: rgba(4, 120, 87, 0.1); color: var(--color-ledger-green); }
.pill--pending  { background: rgba(217, 119, 6, 0.1); color: var(--color-stamp-amber); }
.pill--batal    { background: rgba(220, 38, 38, 0.1); color: var(--color-stamp-red); }
.pill--blank    { background: rgba(156, 163, 175, 0.15); color: #6B7280; }

/* --- Table Improvements --- */

/* Sticky first column */
.sticky-first {
  position: sticky;
  left: 0;
  z-index: 15;
  background: inherit;
}
.sticky-first::after {
  content: '';
  position: absolute;
  top: 0;
  right: -6px;
  bottom: 0;
  width: 6px;
  background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
  pointer-events: none;
}

/* Sticky second column */
.sticky-second {
  position: sticky;
  left: 48px;
  z-index: 14;
  background: inherit;
}

/* Scroll fade indicator on the right of scrollable tables */
.scroll-fade-right {
  mask-image: linear-gradient(to right, black 90%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
}

/* Table row minimum height for touch */
.touch-row {
  min-height: 44px;
}
.touch-row td,
.touch-row th {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

/* Column visibility by viewport */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}
@media (max-width: 1023px) {
  .hide-tablet {
    display: none !important;
  }
}

/* --- Responsive Table Wrapper --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}
.table-wrap table {
  min-width: 600px;
}

/* --- Column visibility by viewport --- */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}
@media (max-width: 1023px) {
  .hide-tablet {
    display: none !important;
  }
}

/* --- Form Input --- */
.form-input {
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: #fff;
  color: #374151;
  font-family: inherit;
  line-height: 1.5;
}
.form-input:focus {
  border-color: #2563EB;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.form-input::placeholder {
  color: #9ca3af;
}
textarea.form-input {
  min-height: 80px;
  resize: vertical;
}

/* --- Transitions --- */
.hover-lift {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.press-effect {
  transition: transform 0.1s ease;
}
.press-effect:active {
  transform: scale(0.97);
}

/* --- Mobile Bottom Nav --- */
@media (max-width: 767px) {
  .bottom-nav-safe {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* --- Document Timeline --- */
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.timeline-dot--active {
  background: var(--color-ledger-green);
  box-shadow: 0 0 0 3px rgba(4, 120, 87, 0.2);
}
.timeline-dot--inactive {
  background: #D1D5DB;
}
.timeline-dot--current {
  background: var(--color-stamp-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* --- Smooth scroll for tab containers --- */
.smooth-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.smooth-scroll-x::-webkit-scrollbar {
  display: none;
}

/* --- Segmented Control (mobile tabs) --- */
.segmented-control {
  display: flex;
  gap: 0.25rem;
  background: #F3F4F6;
  padding: 0.25rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.segmented-control::-webkit-scrollbar {
  display: none;
}
.segmented-control .seg-item {
  white-space: nowrap;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 0.625rem;
  color: #6B7280;
  transition: all 0.15s ease;
  text-decoration: none;
  flex-shrink: 0;
}
.segmented-control .seg-item.active {
  background: white;
  color: var(--color-stamp-blue);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.segmented-control .seg-item:hover:not(.active) {
  color: #374151;
}

/* --- Desktop Tabs --- */
@media (min-width: 768px) {
  .desktop-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #E5E7EB;
    overflow-x: visible;
    background: transparent;
    padding: 0;
    border-radius: 0;
  }
  .desktop-tabs .seg-item {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    border-radius: 0;
    color: #6B7280;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    box-shadow: none;
  }
  .desktop-tabs .seg-item.active {
    background: transparent;
    color: var(--color-stamp-blue);
    border-bottom-color: var(--color-stamp-blue);
    box-shadow: none;
  }
  .desktop-tabs .seg-item:hover:not(.active) {
    color: #374151;
    border-bottom-color: #D1D5DB;
  }
}

/* --- Tab Pane System --- */
.tab-pane:not(.active) {
  display: none !important;
}
.tab-pane iframe {
  width: 100%;
  border: 0;
}

/* --- Customer Form Tabs --- */
.cf-pane {
  display: none;
}
.cf-pane.active {
  display: block;
}

/* Mobile segmented tab items (standalone, without .segmented-control parent) */
.seg-item {
  white-space: nowrap;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 0.625rem;
  color: #6B7280;
  transition: all 0.15s ease;
  text-decoration: none;
  flex-shrink: 0;
}
.seg-item.active {
  background: white;
  color: var(--color-stamp-blue);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.seg-item:hover:not(.active) {
  color: #374151;
}

/* Tab close button */
.tab-close {
  font-size: 14px;
  line-height: 1;
}

/* --- Loading Skeleton --- */
.skeleton {
  background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 0.5rem;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- SweetAlert2 Override (tailwind-compatible) --- */
.swal2-popup {
  font-family: 'Inter', system-ui, sans-serif !important;
  border-radius: 1rem !important;
  padding: 2rem !important;
}
.swal2-title {
  font-family: 'DM Serif Display', serif !important;
  font-weight: 400 !important;
  color: var(--color-typewriter) !important;
}
.swal2-confirm {
  border-radius: 0.5rem !important;
  font-weight: 600 !important;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    scroll-behavior: auto !important;
  }
  .stamp:hover {
    transform: rotate(-1deg) !important;
  }
}

/* --- Focus Styles --- */
input:focus-visible,
button:focus-visible,
a:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-stamp-blue);
  outline-offset: 2px;
}
