/* ==================================
   MODAL COMPONENTS
   ================================== */

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Modal Overlay (backward compatibility) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Modal Container */
.modal {
  background: #FFFFFF;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

/* Modal Content (for modal-backdrop structure) */
.modal-content {
  background: #FFFFFF;
  border-radius: 12px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-content {
  transform: scale(1);
}

/* Modal Header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px;
  border-bottom: 1px solid #E8E8E8;
}

.modal-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 20px;
  line-height: 28px;
  color: #333333;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.modal-close:hover {
  background-color: #F5F5F5;
}

.modal-close svg {
  width: 20px;
  height: 20px;
  stroke: #595959;
}

/* Modal Body */
.modal-body {
  padding: 24px;
}

/* Modal Footer */
.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 24px;
  border-top: 1px solid #E8E8E8;
}

/* ==================================
   NOTIFICATION MODAL STYLES
   ================================== */

/* Alert Modal - Smaller, centered modal for notifications */
.alert-modal .modal-content {
  max-width: 480px;
  width: 90%;
}

.alert-modal .modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #E8E8E8;
}

.alert-modal .modal-body {
  padding: 24px;
  text-align: center;
}

.alert-modal .modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #E8E8E8;
  justify-content: center;
}

/* Alert Types */
.alert-modal.alert-success .modal-header {
  background-color: #10B981;
  color: white;
  border-bottom: none;
}

.alert-modal.alert-success .modal-title {
  color: white;
}

.alert-modal.alert-error .modal-header {
  background-color: #EF4444;
  color: white;
  border-bottom: none;
}

.alert-modal.alert-error .modal-title {
  color: white;
}

.alert-modal.alert-warning .modal-header {
  background-color: #F59E0B;
  color: white;
  border-bottom: none;
}

.alert-modal.alert-warning .modal-title {
  color: white;
}

.alert-modal.alert-info .modal-header {
  background-color: #3B82F6;
  color: white;
  border-bottom: none;
}

.alert-modal.alert-info .modal-title {
  color: white;
}

/* Alert Icon */
.alert-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.alert-success .alert-icon {
  background-color: #D1FAE5;
  color: #10B981;
}

.alert-error .alert-icon {
  background-color: #FEE2E2;
  color: #EF4444;
}

.alert-warning .alert-icon {
  background-color: #FEF3C7;
  color: #F59E0B;
}

.alert-info .alert-icon {
  background-color: #DBEAFE;
  color: #3B82F6;
}

/* Alert Message */
.alert-message {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 24px;
  color: #333333;
  margin: 0;
}

/* White close button for colored headers */
.alert-modal.alert-success .modal-close,
.alert-modal.alert-error .modal-close,
.alert-modal.alert-warning .modal-close,
.alert-modal.alert-info .modal-close {
  color: white;
}

.alert-modal.alert-success .modal-close:hover,
.alert-modal.alert-error .modal-close:hover,
.alert-modal.alert-warning .modal-close:hover,
.alert-modal.alert-info .modal-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Download Invoice Modal Specific */
.download-modal .modal {
  max-width: 550px;
}

.download-icon {
  text-align: center;
  margin-bottom: 24px;
}

.download-icon img {
  width: 120px;
  height: auto;
}

.download-message {
  text-align: center;
  margin-bottom: 24px;
}

.download-message p {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 24px;
  color: #333333;
  margin-bottom: 12px;
}

.download-message p strong {
  font-weight: 600;
}

.download-details {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 22px;
  color: #595959;
  text-align: center;
  margin-bottom: 8px;
}

/* Invoice Summary Box */
.invoice-summary {
  background-color: #F9F9F9;
  border: 1px solid #E8E8E8;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
}

.summary-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 22px;
  color: #333333;
  margin-bottom: 16px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 22px;
}

.summary-label {
  color: #595959;
}

.summary-value {
  color: #333333;
  font-weight: 500;
}

/* New Template Modal Specific */
.template-modal .modal {
  max-width: 800px;
}

.modal-tabs {
  display: flex;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid #E8E8E8;
  margin-top: -1px;
}

.modal-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  border: none;
  background: none;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 22px;
  color: #595959;
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.modal-tab:hover {
  color: #333333;
}

.modal-tab.active {
  color: #2F5AA8;
}

.modal-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: #2F5AA8;
}

.modal-tab svg {
  width: 18px;
  height: 18px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.form-grid.full {
  grid-template-columns: 1fr;
}

/* Upload Area */
.upload-area {
  border: 2px dashed #D1D1D1;
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  cursor: pointer;
}

.upload-area:hover {
  border-color: #2F5AA8;
  background-color: #F9FBFE;
}

.upload-icon {
  margin-bottom: 12px;
}

.upload-icon svg {
  width: 32px;
  height: 32px;
  stroke: #595959;
}

.upload-text {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 22px;
  color: #333333;
  margin-bottom: 4px;
}

.upload-hint {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  line-height: 18px;
  color: #7A7A7A;
}

/* Section Heading */
.section-heading {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 16px;
  line-height: 24px;
  color: #333333;
  margin-bottom: 16px;
  margin-top: 24px;
}

.section-heading:first-child {
  margin-top: 0;
}

/* Responsive */
@media (max-width: 768px) {
  .modal {
    width: 95%;
    max-height: 95vh;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-footer {
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
  }

  .modal-tabs {
    overflow-x: auto;
    gap: 16px;
  }

  .modal-tab {
    white-space: nowrap;
  }
}

/* ============================================
   MODALS — MOBILE  (≤768px)
   ============================================ */

@media (max-width: 768px) {
  .modal-backdrop,
  .modal-overlay {
    padding: var(--spacing-md);
    align-items: flex-end;
  }

  .modal-content,
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    overflow-y: auto;
  }

  .modal-header {
    padding: var(--spacing-lg);
  }

  .modal-body {
    padding: var(--spacing-lg);
  }

  .modal-footer {
    padding: var(--spacing-lg);
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}
