/* =====================================================
   BIVA PORTAL — GLOBAL APP MODAL
   FULL REPLACEMENT
===================================================== */


/* =====================================================
   BACKDROP
===================================================== */

.app-modal-backdrop {
  position: fixed;

  inset: 0;

  z-index: 9999;

  padding: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  background:
    rgba(3, 10, 24, 0.72);

  backdrop-filter:
    blur(8px);

  overflow-y: auto;

  opacity: 1;

  transition:
    opacity 0.16s ease;
}

.app-modal-backdrop.is-closing {
  opacity: 0;

  pointer-events: none;
}


/* =====================================================
   MODAL CARD
===================================================== */

.app-modal-card {
  width: min(520px, 100%);
  max-height:
    calc(100vh - 48px);

  display: flex;
  flex-direction: column;

  border:
    1px solid
    rgba(255, 255, 255, 0.12);

  border-radius: 22px;

  background:
    #ffffff;

  box-shadow:
    0 34px 100px
    rgba(2, 8, 23, 0.38);

  overflow: hidden;

  animation:
    app-modal-enter
    0.22s ease;
}

@keyframes app-modal-enter {

  from {
    opacity: 0;

    transform:
      translateY(12px)
      scale(0.985);
  }

  to {
    opacity: 1;

    transform:
      translateY(0)
      scale(1);
  }

}

.app-modal-backdrop.is-closing
.app-modal-card {
  transform:
    translateY(7px)
    scale(0.99);

  transition:
    transform 0.16s ease;
}


/* =====================================================
   HEADER
===================================================== */

.app-modal-header {
  position: relative;

  min-height: 122px;

  padding:
    23px 24px;

  display: flex;
  align-items: flex-start;
  justify-content: space-between;

  gap: 18px;

  color:
    #ffffff;

  background:
    radial-gradient(
      circle at 92% 4%,
      rgba(37, 99, 235, 0.42),
      transparent 40%
    ),
    radial-gradient(
      circle at 7% 100%,
      rgba(251, 191, 36, 0.08),
      transparent 33%
    ),
    linear-gradient(
      145deg,
      #071324,
      #10233f 58%,
      #173675
    );

  overflow: hidden;
}

.app-modal-header::before {
  content: "";

  position: absolute;

  inset:
    0 0 auto 0;

  height: 4px;

  background:
    linear-gradient(
      90deg,
      #2563eb,
      #fbbf24,
      transparent 84%
    );
}

.app-modal-header::after {
  content: "";

  position: absolute;

  width: 170px;
  height: 170px;

  right: -70px;
  bottom: -130px;

  border:
    1px solid
    rgba(255, 255, 255, 0.05);

  border-radius: 50%;

  box-shadow:
    0 0 0 32px
    rgba(255, 255, 255, 0.018),

    0 0 0 64px
    rgba(255, 255, 255, 0.009);

  pointer-events: none;
}

.app-modal-header > * {
  position: relative;

  z-index: 1;
}


/* =====================================================
   HEADER CONTENT
===================================================== */

.app-modal-header-content {
  min-width: 0;

  display: grid;

  grid-template-columns:
    46px
    minmax(0, 1fr);

  align-items: center;

  gap: 13px;
}

.app-modal-header-content > div {
  min-width: 0;
}


/* =====================================================
   ICON
===================================================== */

.app-modal-icon {
  width: 46px;
  height: 46px;

  display: grid;
  place-items: center;

  border:
    1px solid
    rgba(255, 255, 255, 0.14);

  border-radius: 14px;

  color:
    #ffffff;

  background:
    rgba(255, 255, 255, 0.09);

  backdrop-filter:
    blur(9px);
}

.app-modal-icon svg {
  width: 22px;
  height: 22px;

  fill: none;

  stroke:
    currentColor;

  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* =====================================================
   TYPE-SPECIFIC ICONS
===================================================== */

.app-modal-info
.app-modal-icon {
  color:
    #dbeafe;

  background:
    rgba(37, 99, 235, 0.24);
}

.app-modal-success
.app-modal-icon {
  color:
    #d1fae5;

  background:
    rgba(16, 185, 129, 0.22);
}

.app-modal-warning
.app-modal-icon {
  color:
    #fef3c7;

  background:
    rgba(245, 158, 11, 0.22);
}

.app-modal-danger
.app-modal-icon {
  color:
    #fee2e2;

  background:
    rgba(239, 68, 68, 0.23);
}


/* =====================================================
   TITLE
===================================================== */

.app-modal-eyebrow {
  display: block;

  margin-bottom: 5px;

  color:
    #fbbf24;

  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.app-modal-header h2 {
  margin: 0;

  overflow-wrap: anywhere;

  color:
    #ffffff;

  font-size:
    clamp(1.35rem, 2.8vw, 1.85rem);

  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.04em;
}


/* =====================================================
   CLOSE BUTTON
===================================================== */

.app-modal-close-btn {
  width: 38px;
  height: 38px;

  flex:
    0 0 38px;

  display: grid;
  place-items: center;

  border:
    1px solid
    rgba(255, 255, 255, 0.15);

  border-radius: 11px;

  color:
    #ffffff;

  background:
    rgba(255, 255, 255, 0.08);

  cursor: pointer;

  transition:
    border-color 0.18s ease,
    background-color 0.18s ease,
    transform 0.18s ease,
    opacity 0.18s ease;
}

.app-modal-close-btn:hover {
  border-color:
    rgba(255, 255, 255, 0.3);

  background:
    rgba(255, 255, 255, 0.15);

  transform:
    rotate(4deg);
}

.app-modal-close-btn:disabled {
  opacity: 0.45;

  cursor: not-allowed;

  transform: none;
}

.app-modal-close-btn svg {
  width: 17px;
  height: 17px;

  fill: none;

  stroke:
    currentColor;

  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* =====================================================
   BODY
===================================================== */

.app-modal-body {
  padding:
    23px 24px;

  overflow-y: auto;

  scrollbar-width: thin;

  scrollbar-color:
    #cbd5e1
    transparent;
}

.app-modal-body::-webkit-scrollbar {
  width: 8px;
}

.app-modal-body::-webkit-scrollbar-track {
  background:
    transparent;
}

.app-modal-body::-webkit-scrollbar-thumb {
  border:
    2px solid
    #ffffff;

  border-radius: 999px;

  background:
    #cbd5e1;
}


/* =====================================================
   MESSAGE
===================================================== */

.app-modal-message {
  margin: 0;

  color:
    #526176;

  font-size: 12px;
  line-height: 1.72;

  white-space: pre-line;
}


/* =====================================================
   CUSTOM CONTENT
===================================================== */

.app-modal-content {
  margin-top: 18px;

  color:
    #334155;

  font-size: 12px;
  line-height: 1.6;
}

.app-modal-content:first-child {
  margin-top: 0;
}


/* =====================================================
   FIELDS INSIDE MODAL CONTENT
===================================================== */

.app-modal-content label {
  display: block;

  margin-bottom: 7px;

  color:
    #334155;

  font-size: 10px;
  font-weight: 820;
}

.app-modal-content input,
.app-modal-content select,
.app-modal-content textarea {
  width: 100%;

  border:
    1px solid #dbe4ee;

  border-radius: 11px;

  color:
    #0f172a;

  background:
    #ffffff;

  font: inherit;

  font-size: 12px;

  outline: none;

  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
}

.app-modal-content input,
.app-modal-content select {
  min-height: 44px;

  padding:
    0 13px;
}

.app-modal-content textarea {
  min-height: 105px;

  padding:
    12px 13px;

  line-height: 1.6;

  resize: vertical;
}

.app-modal-content input:focus,
.app-modal-content select:focus,
.app-modal-content textarea:focus {
  border-color:
    #2563eb;

  box-shadow:
    0 0 0 3px
    rgba(37, 99, 235, 0.13);
}

.app-modal-content input:disabled,
.app-modal-content select:disabled,
.app-modal-content textarea:disabled {
  color:
    #94a3b8;

  background:
    #f1f5f9;

  cursor: wait;
}


/* =====================================================
   FEEDBACK MESSAGE
===================================================== */

.app-modal-feedback {
  margin-top: 17px;

  padding:
    11px 13px;

  border:
    1px solid #fecaca;

  border-radius: 10px;

  color:
    #b91c1c;

  background:
    #fff1f2;

  font-size: 10px;
  font-weight: 730;
  line-height: 1.5;
}

.app-modal-feedback[hidden] {
  display: none;
}

.app-modal-feedback[data-type="success"] {
  border-color:
    #bbf7d0;

  color:
    #047857;

  background:
    #ecfdf5;
}

.app-modal-feedback[data-type="warning"] {
  border-color:
    #fde68a;

  color:
    #92400e;

  background:
    #fffbeb;
}

.app-modal-feedback[data-type="info"] {
  border-color:
    #bfdbfe;

  color:
    #1d4ed8;

  background:
    #eff6ff;
}


/* =====================================================
   ACTIONS
===================================================== */

.app-modal-actions {
  padding:
    16px 24px;

  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 9px;

  border-top:
    1px solid #e2e8f0;

  background:
    #f8fafc;
}


/* =====================================================
   BUTTONS
===================================================== */

.app-modal-primary-btn,
.app-modal-secondary-btn {
  min-height: 42px;

  padding:
    0 16px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  gap: 8px;

  border-radius: 11px;

  font: inherit;

  font-size: 10px;
  font-weight: 850;
  line-height: 1;

  white-space: nowrap;

  cursor: pointer;

  transition:
    color 0.18s ease,
    border-color 0.18s ease,
    background-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease,
    opacity 0.18s ease;
}


/* =====================================================
   PRIMARY BUTTON
===================================================== */

.app-modal-primary-btn {
  border:
    1px solid #2563eb;

  color:
    #ffffff;

  background:
    #2563eb;

  box-shadow:
    0 7px 18px
    rgba(37, 99, 235, 0.2);
}

.app-modal-primary-btn:hover {
  background:
    #1d4ed8;

  transform:
    translateY(-1px);
}


/* =====================================================
   TYPE-SPECIFIC PRIMARY BUTTON
===================================================== */

.app-modal-success
.app-modal-primary-btn {
  border-color:
    #059669;

  background:
    #059669;

  box-shadow:
    0 7px 18px
    rgba(5, 150, 105, 0.2);
}

.app-modal-success
.app-modal-primary-btn:hover {
  background:
    #047857;
}

.app-modal-warning
.app-modal-primary-btn {
  border-color:
    #d97706;

  background:
    #d97706;

  box-shadow:
    0 7px 18px
    rgba(217, 119, 6, 0.2);
}

.app-modal-warning
.app-modal-primary-btn:hover {
  background:
    #b45309;
}

.app-modal-danger
.app-modal-primary-btn {
  border-color:
    #dc2626;

  background:
    #dc2626;

  box-shadow:
    0 7px 18px
    rgba(220, 38, 38, 0.2);
}

.app-modal-danger
.app-modal-primary-btn:hover {
  background:
    #b91c1c;
}


/* =====================================================
   SECONDARY BUTTON
===================================================== */

.app-modal-secondary-btn {
  border:
    1px solid #cbd5e1;

  color:
    #334155;

  background:
    #ffffff;
}

.app-modal-secondary-btn:hover {
  border-color:
    #94a3b8;

  color:
    #0f172a;

  background:
    #f1f5f9;
}


/* =====================================================
   DISABLED BUTTONS
===================================================== */

.app-modal-primary-btn:disabled,
.app-modal-secondary-btn:disabled {
  opacity: 0.52;

  cursor: wait;

  transform: none;

  box-shadow: none;
}


/* =====================================================
   PROCESSING STATE
===================================================== */

.app-modal-backdrop.is-processing
.app-modal-card {
  cursor: progress;
}

.app-modal-button-spinner {
  width: 15px;
  height: 15px;

  flex:
    0 0 15px;

  border:
    2px solid
    rgba(255, 255, 255, 0.35);

  border-top-color:
    #ffffff;

  border-radius: 50%;

  animation:
    app-modal-button-spin
    700ms linear infinite;
}

@keyframes app-modal-button-spin {

  to {
    transform:
      rotate(360deg);
  }

}


/* =====================================================
   FOCUS
===================================================== */

.app-modal-backdrop
button:focus-visible,
.app-modal-backdrop
input:focus-visible,
.app-modal-backdrop
select:focus-visible,
.app-modal-backdrop
textarea:focus-visible {
  outline: 0;

  box-shadow:
    0 0 0 3px
    rgba(37, 99, 235, 0.2);
}


/* =====================================================
   TABLET
===================================================== */

@media (max-width: 700px) {

  .app-modal-backdrop {
    padding: 16px;
  }

  .app-modal-card {
    max-height:
      calc(100vh - 32px);

    border-radius: 19px;
  }

  .app-modal-header {
    min-height: 112px;

    padding:
      21px 20px;
  }

  .app-modal-body {
    padding:
      20px;
  }

  .app-modal-actions {
    padding:
      14px 20px;
  }

}


/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 520px) {

  .app-modal-backdrop {
    padding: 0;

    align-items: flex-end;
  }

  .app-modal-card {
    width: 100%;
    max-height: 94vh;

    border-radius:
      20px 20px 0 0;
  }

  .app-modal-header {
    min-height: auto;

    padding:
      20px 17px;
  }

  .app-modal-header-content {
    grid-template-columns:
      42px
      minmax(0, 1fr);

    gap: 11px;
  }

  .app-modal-icon {
    width: 42px;
    height: 42px;

    border-radius: 12px;
  }

  .app-modal-icon svg {
    width: 20px;
    height: 20px;
  }

  .app-modal-close-btn {
    width: 36px;
    height: 36px;

    flex-basis: 36px;
  }

  .app-modal-body {
    padding:
      19px 17px;
  }

  .app-modal-message {
    font-size: 11px;
  }

  .app-modal-actions {
    padding:
      13px 17px;

    display: grid;

    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .app-modal-primary-btn,
  .app-modal-secondary-btn {
    width: 100%;

    min-height: 44px;
  }

  .app-modal-actions
  .app-modal-primary-btn:only-child {
    grid-column:
      1 / -1;
  }

}


/* =====================================================
   VERY SMALL MOBILE
===================================================== */

@media (max-width: 360px) {

  .app-modal-header {
    gap: 10px;
  }

  .app-modal-header-content {
    grid-template-columns: 1fr;
  }

  .app-modal-icon {
    width: 40px;
    height: 40px;
  }

  .app-modal-actions {
    grid-template-columns: 1fr;
  }

}


/* =====================================================
   REDUCED MOTION
===================================================== */

@media (prefers-reduced-motion: reduce) {

  .app-modal-backdrop,
  .app-modal-card,
  .app-modal-close-btn,
  .app-modal-primary-btn,
  .app-modal-secondary-btn,
  .app-modal-content input,
  .app-modal-content select,
  .app-modal-content textarea {
    animation: none;

    transition: none;
  }

  .app-modal-button-spinner {
    animation: none;
  }

}