/**
 * Delzone Logistics - Mobile UX & PWA Enhancements
 */

/* Safe area support for notch and gesture bars */
:root {
  --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);
}

body {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

/* Prevent unwanted horizontal scrolls on mobile */
html, body {
  overflow-x: hidden;
  width: 100%;
}

/* Better mobile form inputs - prevents iOS auto-zoom jump */
@media (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  input[type="tel"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Make tables horizontally scrollable without breaking page layout */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    border: none;
    margin-bottom: 1rem;
  }

  /* Card padding adjust for compact mobile screen */
  .card-body {
    padding: 1rem !important;
  }
}

/* Floating PWA Install Banner */
#delzone-install-banner {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  margin: 0 auto;
  max-width: 480px;
  background: #ffffff;
  color: #1e293b;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22), 0 0 1px rgba(0,0,0,0.1);
  padding: 12px 16px;
  z-index: 999999;
  border: 1px solid rgba(13, 110, 253, 0.2);
  animation: dzSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dzSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes dzSlideDown {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(30px) scale(0.96); }
}

.dz-pwa-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dz-pwa-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dz-pwa-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dz-pwa-content {
  flex: 1;
  min-width: 0;
}

.dz-pwa-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.dz-pwa-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dz-pwa-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.dz-pwa-btn-install {
  background: #0d6efd;
  color: #ffffff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.35);
  transition: background 0.2s;
}

.dz-pwa-btn-install:active {
  background: #0b5ed7;
  transform: scale(0.98);
}

.dz-pwa-btn-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
}

/* Floating Action Button (FAB) for Quick Install */
#dz-pwa-fab {
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
  z-index: 999990;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0d6efd 0%, #0052cc 100%);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: 50px;
  box-shadow: 0 6px 20px rgba(13, 110, 253, 0.45);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.25s ease;
  animation: dzPulse 2.5s infinite;
}

#dz-pwa-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 8px 24px rgba(13, 110, 253, 0.55);
}

#dz-pwa-fab:active {
  transform: translateY(0) scale(0.98);
}

@keyframes dzPulse {
  0% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0.6); }
  70% { box-shadow: 0 0 0 14px rgba(13, 110, 253, 0); }
  100% { box-shadow: 0 0 0 0 rgba(13, 110, 253, 0); }
}

/* PWA Instruction Modal */
#dz-pwa-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: dzFadeIn 0.2s ease-out;
}

@keyframes dzFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dz-pwa-modal-box {
  background: #ffffff;
  color: #1e293b;
  border-radius: 20px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  border: 1px solid rgba(226, 232, 240, 0.8);
  animation: dzModalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dzModalPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.dz-modal-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}

.dz-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dz-modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.dz-step-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.dz-step-icon {
  font-size: 24px;
  line-height: 1;
}

.dz-step-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 3px;
}

.dz-step-text {
  font-size: 12px;
  color: #475569;
  line-height: 1.4;
  margin: 0;
}

.dz-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  background: #ffffff;
}

.dz-modal-footer .dz-btn-primary {
  background: #0d6efd;
  color: #fff;
  border: none;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 8px;
  cursor: pointer;
}

/* Automatically hide install buttons inside installed standalone PWA or Android App */
@media all and (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .dz-install-btn-container,
  #dz-login-install-box,
  #dz-sidebar-install-box,
  [data-dz-install] {
    display: none !important;
  }
}

