/* Custom Styles untuk Sistem Manajemen Stok */

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

* {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Tab Active State */
.tab-button.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background-color: #eff6ff;
}

/* Tab Content Animation */
.tab-content {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Table Hover Effect */
tbody tr {
  transition: background-color 0.2s ease;
}

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

/* Badge Styles */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background-color: #dcfce7;
  color: #166534;
}

.badge-danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-info {
  background-color: #dbeafe;
  color: #1e40af;
}

/* Modal Animation */
#modalStock.flex,
#modalPrintLabel.flex {
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

#modalStock .bg-white,
#modalPrintLabel .bg-white {
  animation: modalSlideUp 0.3s ease-out;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Toast Animation */
#toast.show {
  transform: translateY(0) !important;
  opacity: 1 !important;
}

/* Scanner Input Highlight */
#scanInputIn:focus,
#scanInputOut:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Barcode Container */
.barcode-container {
  background: white;
  padding: 1rem;
  border-radius: 0.5rem;
  border: 2px dashed #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Print Label Styles */
@media print {
  body * {
    visibility: hidden;
  }

  #printArea,
  #printArea * {
    visibility: visible;
  }

  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  .label-item {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* Label Item - Enhanced for Print */
.label-item {
  border: 2px solid #1e293b;
  border-radius: 6px;
  padding: 0;
  background: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
  height: 180px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.label-content {
  width: 100%;
  height: 100%;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.label-nama {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  color: #0f172a;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 8px;
  max-height: 36px;
}

.label-barcode-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 6px 0;
  min-height: 70px;
}

.label-barcode-img {
  max-width: 100%;
  max-height: 100%;
  height: auto;
  width: auto;
  display: block;
}

.label-info {
  width: 100%;
  font-size: 11px;
  color: #475569;
  line-height: 1.4;
  margin-top: 6px;
}

.label-kode {
  font-family: "Courier New", monospace;
  font-weight: 700;
  font-size: 12px;
  color: #0f172a;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.label-details {
  font-size: 9px;
  color: #64748b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.label-item svg {
  margin: 0.5rem 0;
}

.label-item .label-info {
  font-size: 0.75rem;
  color: #475569;
  margin-top: 0.5rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Loading Spinner */
.spinner {
  border: 3px solid #f3f4f6;
  border-top: 3px solid #2563eb;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* Button Hover Effects */
button {
  transition: all 0.2s ease;
}

button:active {
  transform: scale(0.98);
}

/* Input Focus Effects */
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

/* Card Hover Effect */
.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Status Indicator */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 0.5rem;
}

.status-dot.active {
  background-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.status-dot.inactive {
  background-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}

.empty-state svg {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  opacity: 0.5;
}

/* Responsive Table */
@media (max-width: 768px) {
  table {
    font-size: 0.75rem;
  }

  th,
  td {
    padding: 0.5rem !important;
  }
}

/* Gradient Background */
.gradient-bg {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Glass Morphism Effect */
.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Pulse Animation for Scanner */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.scanner-active {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Success Animation */
@keyframes successPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.scan-success {
  animation: successPulse 0.6s ease-out;
}

/* Error Animation */
@keyframes errorShake {
  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

.scan-error {
  animation: errorShake 0.5s ease-out;
}

/* Number Input Arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  opacity: 1;
}

/* Checkbox Custom Style */
input[type="checkbox"]:checked {
  background-color: #2563eb;
  border-color: #2563eb;
}

/* Select Arrow */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

/* Utility Classes */
.text-currency::before {
  content: "Rp ";
}

.font-mono {
  font-family: "Courier New", Courier, monospace;
}

/* Print Styles */
@page {
  margin: 1cm;
}

/* Barcode SVG Styling */
svg[id^="barcode"] {
  max-width: 100%;
  height: auto;
}

/* Transition for all interactive elements */
a,
button,
input,
select,
textarea {
  transition: all 0.2s ease;
}

/* Focus visible for accessibility */
*:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ===== NAVBAR IMPROVEMENTS ===== */

/* Header Styling */
header {
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.15);
}

/* Navigation Tab Styling */
.tab-button {
  position: relative;
  overflow: hidden;
}

/* Tab Active State */
.tab-button.active {
  color: #2563eb;
  background-color: #eff6ff;
}

.tab-button.active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
}

/* Underline Animation */
.tab-button .absolute {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Alert Badge */
#stockAlertCount {
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

/* Dropdown Alert Styling */
#stockAlertDropdown {
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar Hide Utility */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* Responsive Navbar */
@media (max-width: 768px) {
  header {
    padding: 0.75rem 1rem;
  }

  header h1 {
    font-size: 1.5rem;
  }

  header p {
    font-size: 0.75rem;
  }

  .tab-button {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  .tab-button svg {
    width: 1.25rem;
    height: 1.25rem;
  }
}

/* ===== COMPREHENSIVE MOBILE RESPONSIVE STYLES ===== */

/* ===== MOBILE BOTTOM NAVIGATION BAR ===== */

/* Bottom Navigation - Show on mobile only */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  z-index: 9999;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

@media screen and (max-width: 640px) {
  .mobile-bottom-nav {
    display: flex !important;
  }
}

/* Navigation Item */
.mobile-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  padding: 8px 4px;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 12px;
  margin: 4px 2px;
}

.mobile-bottom-nav-item:hover {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}

.mobile-bottom-nav-item.active {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
}

.mobile-bottom-nav-item.active svg {
  transform: scale(1.1);
}

.mobile-bottom-nav-item svg {
  transition: transform 0.2s ease;
}

.mobile-bottom-nav-item span {
  font-size: 10px;
  font-weight: 500;
  margin-top: 2px;
}

/* ===== MOBILE BREAKPOINT: 640px (Smartphone) ===== */
@media (max-width: 640px) {
  /* Hide desktop navigation tabs on mobile */
  nav {
    display: none !important;
  }

  /* Header adjustments */
  header h1 {
    font-size: 1.125rem;
  }

  header p {
    font-size: 0.625rem;
  }

  /* Hide date/time on mobile */
  #currentDate,
  #currentTime {
    display: none !important;
  }

  /* Container padding */
  .container {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Dashboard Statistics Cards */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Dashboard stat cards smaller */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 > div {
    padding: 1rem;
  }

  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 h3 {
    font-size: 1.75rem;
  }

  /* Dashboard content grid */
  .grid.grid-cols-1.lg\\:grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Form grids - stack vertically */
  .grid.grid-cols-1.md\\:grid-cols-2,
  .grid.grid-cols-1.md\\:grid-cols-3,
  .grid.grid-cols-1.md\\:grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Button groups - stack on mobile */
  .flex.space-x-2,
  .flex.space-x-3 {
    flex-direction: column;
    gap: 0.5rem;
  }

  .flex.space-x-2 > *,
  .flex.space-x-3 > * {
    margin-left: 0 !important;
  }

  /* Action buttons in headers - stack */
  .flex.justify-between {
    flex-direction: column;
    gap: 1rem;
  }

  .flex.justify-between h2 {
    margin-bottom: 0.5rem;
  }

  /* Full width buttons on mobile */
  .flex.justify-between button,
  .flex.space-x-2 button {
    width: 100%;
    justify-content: center;
  }

  /* Table responsive */
  .overflow-x-auto {
    margin: 0 -1rem;
    padding: 0 1rem;
    position: relative;
  }

  table {
    font-size: 0.75rem;
    min-width: 600px;
  }

  th, td {
    padding: 0.5rem 0.375rem !important;
    white-space: nowrap;
  }

  /* Hide less important columns on mobile */
  th:nth-child(5),
  td:nth-child(5),
  th:nth-child(6),
  td:nth-child(6) {
    display: none;
  }

  /* Modal full screen on mobile */
  #modalStock .bg-white,
  #modalPrintLabel .bg-white,
  #modalRestore .bg-white,
  #modalEditTransaction .bg-white,
  #modalConfirmDelete .bg-white {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    min-height: 100vh;
    max-height: 100vh;
  }

  /* Print label modal grid */
  .grid.grid-cols-1.lg\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  #labelPreview {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Filter sections - compact */
  .bg-slate-50.p-4 {
    padding: 1rem !important;
  }

  /* Summary cards in reports */
  .grid.grid-cols-1.md\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }

  /* Export buttons */
  .flex.space-x-3.mb-6 {
    flex-direction: column !important;
  }

  .flex.space-x-3.mb-6 button {
    width: 100%;
  }

  /* Quick filter buttons - wrap */
  .flex.flex-wrap.items-center.gap-2 {
    flex-wrap: wrap;
  }

  .quick-filter-btn {
    flex: 1 1 auto;
    min-width: 45%;
    text-align: center;
  }

  /* Scanner input area */
  #scanInputIn,
  #scanInputOut {
    font-size: 1rem;
    padding: 1rem;
  }

  /* Card padding reduced */
  .bg-white.rounded-lg.shadow-md.p-6 {
    padding: 1rem !important;
  }

  /* Main content area */
  main.container {
    padding: 1rem !important;
  }

  /* Alert dropdown */
  #stockAlertDropdown {
    position: fixed !important;
    right: 0.5rem !important;
    left: 0.5rem !important;
    width: auto !important;
    max-height: 70vh;
  }
}

/* ===== TABLET BREAKPOINT: 768px ===== */
@media (min-width: 641px) and (max-width: 768px) {
  /* Dashboard 2 columns on tablet */
  .grid.grid-cols-1.md\\:grid-cols-2.lg\\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Form 2 columns on tablet */
  .grid.grid-cols-1.md\\:grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Modal sizing */
  #modalStock .bg-white,
  #modalPrintLabel .bg-white {
    max-width: 90% !important;
  }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  button, 
  .tab-button,
  input[type="checkbox"],
  select {
    min-height: 44px;
  }

  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important; /* Prevent zoom on iOS */
  }

  /* Larger action buttons */
  button.px-4.py-2,
  button.px-6.py-2 {
    padding: 0.75rem 1rem !important;
  }

  /* Pagination touch-friendly */
  .pagination button {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-width: 896px) and (orientation: landscape) {
  /* Reduce header height in landscape */
  header {
    padding: 0.5rem 1rem !important;
  }

  /* Modal scrollable in landscape */
  #modalStock .bg-white,
  #modalPrintLabel .bg-white {
    max-height: 100vh;
    overflow-y: auto;
  }
}

/* ===== PRINT IMPROVEMENTS ===== */
@media print {
  .hamburger-menu,
  .mobile-nav,
  .mobile-nav-overlay,
  nav {
    display: none !important;
  }
}

/* ===== RESPONSIVE TABLE OPTIMIZATIONS (NO CARDS) ===== */
@media (max-width: 640px) {
  /* Reduce cell padding & font size */
  #tab-stock-data td, 
  #tab-stock-data th {
      padding: 0.75rem 0.5rem;
      font-size: 0.8rem;
      white-space: nowrap;
  }

  /* --- STICKY COLUMNS SETUP --- */
  
  /* Shared sticky styles */
  #tab-stock-data th:nth-child(1), #tab-stock-data td:nth-child(1),
  #tab-stock-data th:nth-child(2), #tab-stock-data td:nth-child(2),
  #tab-stock-data th:nth-child(3), #tab-stock-data td:nth-child(3) {
      position: sticky;
      z-index: 20;
      background: white;
  }

  /* Header background fix */
  #tab-stock-data thead th:nth-child(1),
  #tab-stock-data thead th:nth-child(2),
  #tab-stock-data thead th:nth-child(3) {
      background: #f8fafc;
      color: #0f172a;
  }

  /* 1. Checkbox */
  #tab-stock-data th:nth-child(1), 
  #tab-stock-data td:nth-child(1) {
      left: 0;
      width: 30px !important;
      min-width: 30px !important;
      max-width: 30px !important;
      padding-left: 0.25rem;
      padding-right: 0.25rem;
      text-align: center;
  }

  /* 2. Kode */
  #tab-stock-data th:nth-child(2),
  #tab-stock-data td:nth-child(2) {
      left: 30px; /* Width of Checkbox */
      width: 80px !important;
      min-width: 80px !important;
      max-width: 80px !important;
      overflow: hidden;
      text-overflow: ellipsis;
      font-family: monospace;
      font-size: 0.75rem; 
      color: #64748b;
  }

  /* 3. Nama */
  #tab-stock-data th:nth-child(3),
  #tab-stock-data td:nth-child(3) {
      left: 110px; /* 30px + 80px */
      width: 130px !important;
      min-width: 130px !important;
      max-width: 150px !important;
      overflow: hidden;
      text-overflow: ellipsis;
      font-weight: 600;
      box-shadow: 4px 0 6px -2px rgba(0,0,0,0.1); /* Drop shadow on right edge */
      border-right: 1px solid #e2e8f0;
  }

  /* Adjust Action column width */
  #tab-stock-data th:last-child, #tab-stock-data td:last-child {
      min-width: 100px;
  }
}

