/**
 * Saptha Tharanga Beer Shop - Global App Styles
 * Mobile/Desktop friendly, GPU-optimized, App-view strategy
 */

:root {
  --app-primary: #1a5f2a;
  --app-primary-light: #27ae60;
  --app-dark: #2c3e50;
  --app-bg: #f0f2f5;
  --app-card-radius: 25px;
  --app-header-h: 56px;
  --app-nav-h: 64px;
  --app-blur: 8px;
  --app-shadow: 0 4px 20px rgba(0,0,0,0.06);
  --app-shadow-modal: 0 25px 50px rgba(0,0,0,0.15);
}

/* Stock page: brand name row – bold + distinct colour */
.brand-header-cell {
  font-weight: 700 !important;
  font-size: 1.05rem;
  color: var(--app-primary);
  letter-spacing: 0.02em;
}

/* Stock page: only the brand part inside item name – bold + colour; rest normal */
.stock-item-brand {
  font-weight: 700;
  color: var(--app-primary);
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--app-bg);
  padding-top: var(--app-header-h);
  padding-bottom: var(--app-nav-h);
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100vh;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* ----- Fixed Header ----- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--app-header-h);
  background: #fff;
  box-shadow: var(--app-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1001;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

.app-header .back-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--app-dark);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1.25rem;
  transition: transform 0.2s ease, background 0.2s ease;
}
.app-header .back-btn:hover { background: rgba(0,0,0,0.06); transform: translate3d(-2px, 0, 0); }
.app-header .back-btn.hide { visibility: hidden; pointer-events: none; }

.app-header .title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--app-dark);
  margin: 0;
  flex: 1;
  text-align: center;
  padding: 0 8px;
}

.app-header .header-action {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--app-dark);
  border-radius: 12px;
  text-decoration: none;
  font-size: 1.1rem;
}

/* ----- Scrollable Body ----- */
.app-body {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  min-height: calc(100vh - var(--app-header-h) - var(--app-nav-h));
  transform: translate3d(0, 0, 0);
}

/* ----- Bottom Navigation ----- */
.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--app-nav-h);
  background: #fff;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0;
  box-shadow: 0 -2px 15px rgba(0,0,0,0.08);
  z-index: 1000;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translate3d(0, 0, 0);
}

.app-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #6c757d;
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 14px;
  transition: color 0.2s ease, background 0.2s ease;
}
.app-bottom-nav .nav-item i {
  font-size: 22px;
  display: block;
  margin-bottom: 2px;
}
.app-bottom-nav .nav-item.active {
  color: var(--app-primary-light);
  background: rgba(39, 174, 96, 0.1);
}

/* ----- Cards ----- */
.app-card {
  background: #fff;
  border-radius: var(--app-card-radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--app-shadow);
  border: none;
  transform: translate3d(0, 0, 0);
}

/* Staggered card animation */
.app-card.stagger-1 { animation: cardFadeIn 0.4s ease 0.05s both; }
.app-card.stagger-2 { animation: cardFadeIn 0.4s ease 0.1s both; }
.app-card.stagger-3 { animation: cardFadeIn 0.4s ease 0.15s both; }
.app-card.stagger-4 { animation: cardFadeIn 0.4s ease 0.2s both; }
.app-card.stagger-5 { animation: cardFadeIn 0.4s ease 0.25s both; }
.app-card.stagger-6 { animation: cardFadeIn 0.4s ease 0.3s both; }

@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ----- Modals: Overlay & Blur (Bootstrap override + custom) ----- */
/* Bootstrap modal backdrop: dark overlay + blur */
.modal-backdrop {
  background: rgba(0, 0, 0, 0.45) !important;
  backdrop-filter: blur(var(--app-blur));
  -webkit-backdrop-filter: blur(var(--app-blur));
  transition: opacity 0.3s ease;
}
.modal-backdrop.fade { opacity: 0; }
.modal-backdrop.show { opacity: 1; }

/* Bootstrap modal dialog: slide-up + scale, rounded, padding */
.modal .modal-dialog {
  margin: 1rem;
  max-width: calc(100% - 2rem);
  transform: translate3d(0, 30px, 0);
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal.show .modal-dialog {
  transform: translate3d(0, 0, 0);
  opacity: 1;
}
.modal .modal-content {
  border-radius: var(--app-card-radius);
  border: none;
  box-shadow: var(--app-shadow-modal);
  padding: 0;
  overflow: hidden;
}
.modal .modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #eee;
  border-radius: var(--app-card-radius) var(--app-card-radius) 0 0;
}
.modal .modal-body {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.modal .modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #eee;
  gap: 10px;
}
.modal .btn-close {
  border-radius: 12px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.modal .btn-close:hover { opacity: 1; }

/* Custom app modal (when not using Bootstrap) */
.modal-dialog-app {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.9) translate3d(0, 20px, 0);
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  z-index: 1051;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s ease;
}
.modal-backdrop.show + .modal-dialog-app,
.modal-dialog-app.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1) translate3d(0, 0, 0);
}

.modal-content-app {
  background: #fff;
  border-radius: var(--app-card-radius);
  padding: 24px;
  box-shadow: var(--app-shadow-modal);
  border: none;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-content-app .modal-header-app { flex-shrink: 0; padding-bottom: 16px; border-bottom: 1px solid #eee; margin-bottom: 16px; }
.modal-content-app .modal-body-app { flex: 1; overflow-y: auto; overflow-x: hidden; }
.modal-content-app .modal-footer-app { flex-shrink: 0; padding-top: 16px; border-top: 1px solid #eee; margin-top: 16px; display: flex; gap: 10px; justify-content: flex-end; }

.btn-close-app {
  width: 40px; height: 40px; border: none; background: #f0f2f5; color: #666; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; transition: opacity 0.2s ease, background 0.2s ease;
}
.btn-close-app:hover { background: #e0e0e0; }

/* ----- Skeleton UI ----- */
.skeleton {
  background: linear-gradient(90deg, #e8e8e8 25%, #f0f0f0 50%, #e8e8e8 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.2s ease-in-out infinite;
  border-radius: 12px;
  min-height: 20px;
}
.skeleton-circle { border-radius: 50%; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-text { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-text.short { width: 40%; }

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

/* ----- Buttons ----- */
.btn-app-primary {
  background: var(--app-primary-light);
  color: #fff;
  border: none;
  padding: 14px 24px;
  border-radius: 14px;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-app-primary:active { transform: scale(0.98) translate3d(0, 0, 0); }
.btn-app-primary:hover { color: #fff; background: #219653; }

/* ----- Form controls ----- */
.form-control-app,
.form-select-app {
  border-radius: 14px;
  border: 1px solid #dee2e6;
  padding: 12px 16px;
  font-size: 1rem;
}
.form-control-app:focus,
.form-select-app:focus {
  border-color: var(--app-primary-light);
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.15);
}

/* ----- Page slide-in (for future SPA-like feel) ----- */
.app-page {
  animation: pageSlideIn 0.35s ease both;
  transform: translate3d(0, 0, 0);
}

@keyframes pageSlideIn {
  from {
    opacity: 0;
    transform: translate3d(20px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ----- Highlight values ----- */
.highlight-val {
  color: var(--app-primary-light);
  font-weight: 800;
  font-size: 1.5rem;
}

/* ----- Reserve / bucket boxes ----- */
.reserve-box {
  background: var(--app-dark);
  color: #fff;
  border-radius: 18px;
  padding: 20px;
}
.reserve-box .reserve-divider {
  border-left: 1px solid rgba(255,255,255,0.2);
  height: 40px;
}

/* ----- Alerts ----- */
.alert-app {
  border-radius: 18px;
  border: none;
  padding: 16px;
}

/* ----- Tables ----- */
.table-app thead {
  background: var(--app-dark);
  color: #fff;
}
.table-app thead th {
  border: none;
  padding: 12px 14px;
  font-weight: 600;
  border-radius: 0;
}
.table-app tbody td { padding: 12px 14px; vertical-align: middle; }

/* ----- Reports ----- */
.report-result { font-size: 0.95rem; }
.nav-pills .nav-link { color: var(--app-dark); font-weight: 500; }
.nav-pills .nav-link.active { background: var(--app-primary-light); color: #fff; border: none; }

/* ----- Utilities ----- */
.user-select-none { user-select: none; }
.gpu { transform: translate3d(0, 0, 0); will-change: transform; }
