html {
  all: unset;
  margin: 0;
  padding: 0;
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  display: block;
  text-size-adjust: none;
  font-size: 16px;
  scroll-behavior: smooth;
  overflow: hidden;
  box-sizing: border-box;
}

body {
  all: unset;
  background: var(--background);
  color: var(--text-color);
  font-family: var(--font-main), sans-serif;
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: block;
  font-size: 16px;
  scroll-behavior: smooth;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
}

div.root#root {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

div.root#root:has(app-main) {
  display: block;
  align-items: stretch;
  justify-content: flex-start;
}

* {
  box-sizing: border-box;
  font-family: var(--font-main), sans-serif;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* ============================================================
   TOAST NOTIFICATIONS - Modern Card Design
   ============================================================ */

/* ==================== Base Container ==================== */
#toast.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  min-width: 320px;
  max-width: 420px;

  /* Card Styling */
  background: var(--background);
  border: var(--border);
  border-radius: 12px;
  box-shadow: var(--box-shadow);

  /* Glass Effect */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  /* Initial Hidden State */
  transform: translateX(calc(100% + 40px)) scale(0.95);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

/* Success Background */
#toast.success {
  background: var(--success-background);
  border-color: var(--success-border);
}

/* Error Background */
#toast.error {
  background: var(--error-background);
  border-color: var(--error-border);
}

/* ==================== Animation States ==================== */
#toast.toast-container.show {
  transform: translateX(0) scale(1);
  opacity: 1;
}

#toast.toast-container.hide {
  transform: translateX(calc(100% + 40px)) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.55, 0.085, 0.68, 0.53);
}

/* ==================== Content Layout ==================== */
.toast-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  position: relative;
}

/* ==================== Icon Styling ==================== */
.toast-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: iconBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Success Icon */
#toast.success .toast-icon {
  background: var(--success-background);
  color: var(--success-color);
  border: var(--success-border);
}

/* Error Icon */
#toast.error .toast-icon {
  background: var(--error-background);
  color: var(--error-color);
  border: var(--error-border);
}

.toast-icon svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ==================== Message Area ==================== */
.toast-message {
  flex: 1;
  min-width: 0;
  /* Critical for text truncation */
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

/* Message Title */
.toast-title {
  font-family: var(--font-main), sans-serif;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--title-color);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

/* Message Text */
.toast-text {
  font-family: var(--font-text), sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-color);
  line-height: 1.5;

  /* Text Truncation */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* ==================== Close Button ==================== */
.toast-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-color);
  transition: all 0.2s ease;
  padding: 0;
  margin: -4px -4px 0 0;
}

.toast-close:hover {
  background: var(--gray-background);
  color: var(--text-color);
}

.toast-close:active {
  transform: scale(0.9);
  background: var(--tab-background);
}

.toast-close svg {
  width: 16px;
  height: 16px;
}

/* ==================== Progress Bar ==================== */
.toast-progress {
  height: 3px;
  background: var(--gray-background);
  position: relative;
  overflow: hidden;
}

.toast-progress::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  transform-origin: left;
  transition: transform 4s linear;
}

/* Progress Bar Colors */
#toast.success .toast-progress::before {
  background: var(--success-color);
}

#toast.error .toast-progress::before {
  background: var(--error-color);
}

/* Progress Animation */
#toast.show .toast-progress::before {
  transform: scaleX(0);
}

#toast.hide .toast-progress::before {
  transform: scaleX(0);
  transition: none;
}

/* ==================== Keyframe Animations ==================== */
@keyframes iconBounce {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }

  50% {
    transform: scale(1.15) rotate(10deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* ============================================================
   MOBILE RESPONSIVE - 700px and Below
   ============================================================ */
@media screen and (max-width: 700px) {
  /* Container Adjustments */
  #toast.toast-container {
    /* Full width with margins */
    top: 10px;
    right: 10px;
    left: 10px;
    min-width: auto;
    max-width: none;
    width: calc(100% - 20px);

    /* Slide from top on mobile instead of right */
    transform: translateY(-120%) scale(0.95);
  }

  /* Mobile Show State */
  #toast.toast-container.show {
    transform: translateY(0) scale(1);
  }

  /* Mobile Hide State */
  #toast.toast-container.hide {
    transform: translateY(-120%) scale(0.95);
  }

  /* Content Spacing */
  .toast-content {
    padding: 12px 14px;
    gap: 10px;
  }

  /* Icon Size */
  .toast-icon {
    width: 36px;
    height: 36px;
  }

  .toast-icon svg {
    width: 20px;
    height: 20px;
  }

  /* Text Sizing */
  .toast-title {
    font-size: 0.875rem;
  }

  .toast-text {
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  /* Close Button */
  .toast-close {
    width: 26px;
    height: 26px;
    margin: -2px -2px 0 0;
  }

  .toast-close svg {
    width: 14px;
    height: 14px;
  }
}
