/* ========== SHARED STYLES ========== */
/* CSS ร่วมสำหรับทั้ง 2 หน้า */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Prompt', sans-serif;
  background: linear-gradient(135deg, #e2f2f4 0%, #f0f7ff 100%);
  margin: 0;
  color: #333;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== CONTAINER ========== */
.container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* ========== TYPOGRAPHY ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
  color: #000242;
}

p {
  line-height: 1.6;
  margin-bottom: 1em;
}

/* ========== BUTTON BASE STYLES ========== */
button {
  font-family: 'Prompt', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  outline: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button:focus-visible {
  outline: 2px solid #0066ff;
  outline-offset: 2px;
}

/* ========== INPUT BASE STYLES ========== */
input, select, textarea {
  font-family: 'Prompt', sans-serif;
  outline: none;
  transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
}

/* ========== CUSTOM DIALOG SYSTEM ========== */
.dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
  padding: 20px;
}

.dialog.hidden {
  display: none;
}

.dialog-content {
  background: linear-gradient(135deg, #ffffff, #f8faff);
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
  max-width: 400px;
  width: 100%;
  animation: scaleIn 0.3s ease;
  border: 2px solid #0066ff;
  position: relative;
}

.dialog-icon {
  font-size: 48px;
  margin-bottom: 16px;
  animation: bounce 1s ease;
}

.dialog-content p {
  margin-bottom: 24px;
  font-size: 18px;
  font-weight: 600px;
  line-height: 1.6;
  color: #17bd5f;
  text-align: center;
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.dialog-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-family: 'Prompt', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 100px;
  flex: 1;
}

.dialog-btn.hidden {
  display: none;
}

.cancel-btn {
  background: #6b7280;
  color: white;
  box-shadow: 0 2px 6px rgba(107, 114, 128, 0.3);
}

.cancel-btn:hover {
  background: #4b5563;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(107, 114, 128, 0.4);
}

.confirm-btn {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: white;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.confirm-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.close-btn {
  background: linear-gradient(135deg, #0066ff, #0048cc);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 102, 255, 0.3);
}

.close-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.4);
}

/* Preview Content in Dialog */
.preview-content {
  background: #f8fafc;
  color: #1e293b;
  padding: 16px;
  border-radius: 8px;
  margin: 16px 0;
  border-left: 4px solid #ff7b00;
  max-height: 500px;
  overflow-y: auto;
  text-align: left;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
 font-family: 'Prompt', sans-serif;
}

.preview-content::-webkit-scrollbar {
  width: 6px;
}

.preview-content::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 3px;
}

.preview-content::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 3px;
}

.preview-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* ========== UTILITY CLASSES ========== */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

.flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.justify-center {
  justify-content: center;
}

.align-center {
  align-items: center;
}

.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

.mb-0 {
  margin-bottom: 0;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.p-1 {
  padding: 0.5rem;
}

.p-2 {
  padding: 1rem;
}

/* ========== LOADING STATES ========== */
.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #0066ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ========== ACCESSIBILITY ========== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid #0066ff;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ========== SCROLLBAR STYLING ========== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========== PRINT STYLES ========== */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white !important;
  }
  
  .container {
    max-width: none !important;
    box-shadow: none !important;
  }
}

/* ========== REDUCED MOTION SUPPORT ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========== HIGH CONTRAST SUPPORT ========== */
@media (prefers-contrast: high) {
  .dialog-content {
    border: 3px solid #000;
  }
  
  .branch-card,
  .add-branch-card {
    border: 2px solid #000;
  }
  
  input,
  select {
    border: 2px solid #000;
  }
}

/* ========== DARK MODE SUPPORT ========== */
@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #f1f5f9;
  }
  
  .dialog-content {
    background: linear-gradient(135deg, #374151, #4b5563);
    color: #79bcff;
    border-color: #60a5fa;
  }
  
  .preview-content {
    background: #1f2937;
    color: #f1f5f9;
    border-left-color: #f59e0b;
  }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {
  button:hover {
    transform: none;
  }
  
  .branch-card:hover {
    transform: none;
  }
  
  /* Increase tap targets for mobile */
  .dialog-btn {
    min-height: 44px;
  }
  
  .branch-actions button {
    min-height: 44px;
  }
}

/* ========== ERROR STATES ========== */
.input-error {
  border-color: #dc2626 !important;
  background: #fef2f2 !important;
}

.error-message {
  color: #dc2626;
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.success-message {
  color: #059669;
  font-size: 12px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ========== TRANSITION GROUPS ========== */
.fade-enter {
  opacity: 0;
}

.fade-enter-active {
  opacity: 1;
  transition: opacity 0.3s ease;
}

.fade-exit {
  opacity: 1;
}

.fade-exit-active {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ========== Z-INDEX SCALE ========== */
:root {
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ========== PWA INSTALL BANNER (MODIFIED) ========== */
.install-banner {
  position: fixed;
  top: 20px; /* moved to top */
  left: 50%;
  transform: translateX(-50%) translateY(0);
  width: 90%;
  max-width: 400px;
  background: linear-gradient(135deg, #ffffff, #f8faff);
  border: 2px solid #0066ff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 102, 255, 0.3);
  z-index: 9999;
  /* use transitions for smooth show/hide */
  transition: transform 0.45s cubic-bezier(.2,.9,.2,1), opacity 0.45s ease;
  opacity: 1;
  pointer-events: auto;
}

/* Hidden state now uses opacity + translate so transitions animate smoothly */
.install-banner.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-18px); /* slight upward offset while hidden */
  pointer-events: none;
  /* keep layout visually out but still able to animate */
}

.install-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  position: relative;
}

.install-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.install-text {
  flex: 1;
}

.install-title {
  font-weight: 700;
  color: #0066ff;
  font-size: 16px;
  margin-bottom: 2px;
}

.install-desc {
  color: #666;
  font-size: 13px;
}

.install-btn {
  background: linear-gradient(135deg, #00c043, #00a038);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.install-btn:hover {
  background: linear-gradient(135deg, #00a038, #00852f);
  transform: translateY(-1px);
}

.close-banner-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 18px;
  color: #666;
  cursor: pointer;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.close-banner-btn:hover {
  background: #f1f5f9;
}

/* Responsive: keep at top on small screens */
@media (max-width: 480px) {
  .install-banner {
    top: 10px;
    width: 95%;
  }
  
  .install-content {
    padding: 14px;
    gap: 10px;
  }
  
  .install-icon {
    font-size: 28px;
  }
  
  .install-title {
    font-size: 15px;
  }
  
  .install-desc {
    font-size: 12px;
  }
  
  .install-btn {
    padding: 8px 14px;
    font-size: 13px;
  }
}