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

:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Glassmorphism & Cards */
.glass-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.gradient-blue-card {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
}

.gradient-dark-card {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-paid, .badge-active, .badge-safe {
  background-color: #dcfce7;
  color: #15803d;
}

.badge-partial, .badge-expiring, .badge-due {
  background-color: #fef3c7;
  color: #b45309;
}

.badge-unpaid, .badge-expired, .badge-inactive, .badge-overdue {
  background-color: #ffe4e6;
  color: #be123c;
}

.badge-neutral {
  background-color: #f1f5f9;
  color: #475569;
}

/* Transitions & Animations */
.fade-in {
  animation: fadeIn 0.2s ease-in-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal Overlay backdrop */
.modal-backdrop {
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  padding: 0.875rem 1.25rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-success {
  background-color: #10b981;
  color: #ffffff;
}

.toast-error {
  background-color: #ef4444;
  color: #ffffff;
}

.toast-info {
  background-color: #3b82f6;
  color: #ffffff;
}

/* A4 Print Layout CSS Optimization */
.a4-page {
  width: 210mm;
  min-height: 297mm;
  background: white;
}

/* Screen View Width Constraints - Prevent Right Side Page Stretching */
html, body, main {
  max-width: 100vw;
  overflow-x: hidden;
}

@media (max-width: 1279px) {
  #invoice-template, #view-modal-template {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    box-shadow: none !important;
  }

  #builder-preview-panel {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
}

/* Mobile Responsiveness & Touch Optimizations */
@media (max-width: 768px) {
  input[type="date"], input[type="number"], select, input[type="text"], input[type="email"], textarea {
    font-size: 14px;
  }

  #invoice-template, #view-modal-template {
    padding: 0.875rem !important;
  }

  /* Table Cell Padding Reduction on Mobile */
  table th, table td {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
  }

  /* Prevent fixed height header clipping */
  header {
    height: auto !important;
    min-height: 4rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  /* Modal Dialog Padding on Mobile */
  .modal-backdrop > div {
    padding: 1rem !important;
    max-height: 94vh !important;
  }
}

/* Custom Utilities */
.truncate-multiline {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pay-inv-row {
  transition: all 0.2s ease;
}

.pay-inv-row:hover {
  border-color: #cbd5e1;
  background-color: #ffffff;
}

.pay-inv-checkbox:checked ~ div {
  color: #0f172a;
}

@media print {
  body {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  
  body * {
    visibility: hidden;
  }

  /* Printable targets */
  #invoice-template, #invoice-template *,
  #view-modal-template, #view-modal-template * {
    visibility: visible;
  }

  #invoice-template, #view-modal-template {
    position: fixed;
    left: 0;
    top: 0;
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 12mm 15mm !important;
    box-shadow: none !important;
    border: none !important;
    background: white !important;
    font-size: 12px !important;
    z-index: 99999 !important;
  }
}
