/**
 * MiniMart IMS — shared polish styles
 * Works alongside Tailwind CDN
 */

:root {
  --mm-primary: #16a34a;
  --mm-primary-dark: #15803d;
  --mm-primary-light: #dcfce7;
  --mm-radius: 0.75rem;
  --mm-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --mm-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --mm-transition: 150ms ease;
}

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

body {
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Safe area for notched phones */
.safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.safe-top {
  padding-top: env(safe-area-inset-top, 0);
}

/* Focus rings — consistent keyboard accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--mm-primary);
  outline-offset: 2px;
}

/* Cards */
.mm-card {
  background: #fff;
  border: 1px solid #f3f4f6;
  border-radius: var(--mm-radius);
  box-shadow: var(--mm-shadow);
}

.mm-card-hover:hover {
  box-shadow: var(--mm-shadow-md);
  border-color: #e5e7eb;
  transition: box-shadow var(--mm-transition), border-color var(--mm-transition);
}

/* Buttons polish */
.mm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  border-radius: 0.5rem;
  transition: background-color var(--mm-transition), transform 100ms ease, opacity var(--mm-transition);
}

.mm-btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

/* Form inputs */
input[type="text"],
input[type="search"],
input[type="number"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
select,
textarea {
  transition: border-color var(--mm-transition), box-shadow var(--mm-transition);
}

input:disabled,
select:disabled,
textarea:disabled {
  background-color: #f9fafb;
  cursor: not-allowed;
}

/* Tables */
table {
  border-collapse: collapse;
}

.mm-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Sticky table header on long lists */
.mm-table-sticky thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #f9fafb;
}

/* Flash messages */
.mm-flash {
  animation: mm-slide-down 0.25s ease;
}

.mm-flash-dismiss {
  cursor: pointer;
  opacity: 0.7;
}

.mm-flash-dismiss:hover {
  opacity: 1;
}

@keyframes mm-slide-down {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Sidebar transitions */
#sidebar {
  transition: transform 0.2s ease;
  will-change: transform;
}

#sidebarOverlay {
  transition: opacity 0.2s ease;
}

#sidebarOverlay:not(.hidden) {
  animation: mm-fade-in 0.2s ease;
}

@keyframes mm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Bottom nav active indicator */
.mm-bottom-nav a {
  transition: color var(--mm-transition);
  position: relative;
}

.mm-bottom-nav a.mm-nav-active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1.25rem;
  height: 2px;
  background: var(--mm-primary);
  border-radius: 0 0 2px 2px;
}

/* Loading spinner */
.mm-spinner {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mm-spin 0.6s linear infinite;
}

.mm-spinner-dark {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--mm-primary);
}

@keyframes mm-spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.mm-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  color: #9ca3af;
}

.mm-empty svg {
  margin: 0 auto 0.75rem;
  opacity: 0.45;
}

/* Badge helpers */
.mm-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  font-weight: 500;
}

.mm-badge-success { background: #dcfce7; color: #166534; }
.mm-badge-warning { background: #fef3c7; color: #92400e; }
.mm-badge-danger  { background: #fee2e2; color: #991b1b; }
.mm-badge-info    { background: #e0f2fe; color: #075985; }
.mm-badge-muted   { background: #f3f4f6; color: #4b5563; }

/* POS cart polish */
#cartItems {
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

#cartItems::-webkit-scrollbar {
  width: 4px;
}

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

/* Receipt / print */
@media print {
  .no-print,
  header,
  aside,
  .mm-bottom-nav,
  nav {
    display: none !important;
  }

  body {
    background: #fff !important;
  }

  main {
    padding: 0 !important;
  }
}

/* Skeleton loading (optional use) */
.mm-skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: mm-shimmer 1.2s ease-in-out infinite;
  border-radius: 0.375rem;
}

@keyframes mm-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Utility: truncate multi-line */
.mm-line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Number inputs — hide spinners where desired */
.mm-no-spin::-webkit-outer-spin-button,
.mm-no-spin::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.mm-no-spin {
  -moz-appearance: textfield;
}

/* Subtle page enter */
main > .max-w-7xl {
  animation: mm-fade-up 0.2s ease;
}

@keyframes mm-fade-up {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
