/* -----------------------------------------------------------
 * style.css – Refactored after design-review (v2.1)
 * -----------------------------------------------------------
 * Changelog v2.1 (fix-mobile-width)
 * • Container nutzt jetzt die komplette Viewport-Breite auf kleinen Geräten
 * • Body-Padding auf Smartphones deutlich reduziert (8 px)
 * • Buttons & Toggle erhalten kleinere Offsets, damit nichts abgeschnitten wird
 * Changelog v2.2 (mobile-spacing-fix)
 * • Body horizontal padding on mobile reduced to 0 for less space on sides.
 * Changelog v2.3 (mobile-full-width-fix)
 * • HTML and Body horizontal padding on mobile reduced to 0.
 * • Container margin explicitly set to 0 on mobile.
 * ----------------------------------------------------------- */

/* ============ 1. Design Tokens ============ */
:root {
  /* Light gradient background  */
  --bg-gradient-light: linear-gradient(
    73deg,
    #e9f1ff 10%,
    #f5efff 50%,
    #fff0f3 90%
  );
  --bg-gradient-dark: linear-gradient(
    73deg,
    #1a2a45 10%,
    #2a1f3d 50%,
    #3d1e23 90%
  );

  /* Typography & Base */
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --radius: 0.75rem;
  --ease: 150ms ease-in-out;

  /* Neutrals (light) */
  --gray-100: #f8f8f8;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-700: #374151;
  --gray-900: #1f2937;

  /* Neutrals (dark) */
  --gray-800: #2a2a2a;
  --gray-850: #303030;
  --gray-950: #0f172a;

  /* Brand */
  --violet-500: #7b4bff;
  --violet-600: #7040f4;
  --violet-700: #6335e8;
  --brand-gradient: linear-gradient(72deg, #7b4bff 0%, #9b72cb 100%);

  /* Feedback */
  --success-bg-light: #e8f5e9;
  --success-bg-dark: rgba(27, 94, 32, 0.8);
  --error-bg-light: #ffebee;
  --error-bg-dark: rgba(183, 28, 28, 0.8);
  --success-border-light: #a5d6a7;
  --success-border-dark: #2e7d32;
  --error-border-light: #ef9a9a;
  --error-border-dark: #c62828;
  --success-text-light: #1b5e20;
  --success-text-dark: #c8e6c9;
  --error-text-light: #b71c1c;
  --error-text-dark: #ffcdd2;
}

/* Dark mode overrides */
body.dark-mode {
  --bg-gradient: var(--bg-gradient-dark);
  --text-color: #f1f3f9;
  --container-bg: #414244;
  --textarea-bg: var(--gray-800);
  --textarea-border: var(--gray-700);
  --placeholder: #a5abb6;
  --button-bg: var(--gray-850);
  --button-border: #a5abb6;
  --reset-text: #a5abb6;
  --output-bg: var(--gray-800);
  --output-border: var(--gray-700);
  --copy-info: #bdbdbd;
  --toggle-bg: #414244;
  --toggle-icon: #f1f3f9;
}

/* Light mode defaults */
body {
  --bg-gradient: var(--bg-gradient-light);
  --text-color: var(--gray-900);
  --container-bg: #ffffff;
  --textarea-bg: var(--gray-100);
  --textarea-border: var(--gray-300);
  --placeholder: var(--gray-400);
  --button-bg: #e0e0e0;
  --button-border: var(--gray-300);
  --reset-text: var(--gray-700);
  --output-bg: var(--gray-100);
  --output-border: var(--gray-300);
  --copy-info: #666;
  --toggle-bg: #e0e0e0;
  --toggle-icon: var(--gray-900);
}

/* ============ 2. Global Layout ============ */
html,
body {
  margin: 0;
  padding: 20px; /* Default padding for larger screens, overridden on small screens */
  font-family: var(--font-base);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  background-size: cover;
  color: var(--text-color);
  transition: background-image var(--ease), color var(--ease);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  box-sizing: border-box;
  width: 100%; /* Ensure html and body attempt to use full viewport width */
  overflow-x: hidden; /* Prevent accidental horizontal scroll */
}

.container {
  background: var(--container-bg);
  width: 600px;
  max-width: 100%;
  box-sizing: border-box;
  padding: 24px 24px 28px;
  border-radius: var(--radius);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  backdrop-filter: saturate(150%) blur(4px);
  transition: background var(--ease), box-shadow var(--ease);
  margin: 0 auto; /* Center container on desktop */
}
body.dark-mode .container {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.45);
}

h1 {
  margin-bottom: 24px;
  font-size: 1.6rem;
  font-weight: 700;
  background-image: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
}

/* ============ 3. Form Controls ============ */
textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  border: 1px solid var(--textarea-border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--textarea-bg);
  color: var(--text-color);
  font-size: 1rem;
  resize: vertical;
  transition: border-color var(--ease), box-shadow var(--ease),
    background var(--ease);
  margin-bottom: 20px;
  box-sizing: border-box;
}
textarea::placeholder {
  color: var(--placeholder);
}
textarea:hover {
  border-color: var(--violet-500);
}
textarea:focus {
  border-color: var(--violet-500);
  outline: none;
  box-shadow: 0 0 0 3px rgba(155, 114, 203, 0.35);
}

/* ============ 4. Buttons ============ */
.button-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 24px;
  justify-content: center;
}
button {
  flex: 1 1 120px;
  max-width: 160px;
  padding: 12px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--button-border);
  background: var(--button-bg);
  transition: background var(--ease), box-shadow var(--ease),
    transform var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
#sendButton {
  background: var(--brand-gradient);
  border: none;
  color: #fff;
}
#sendButton:hover {
  filter: brightness(1.1);
}
#sendButton:active {
  transform: scale(0.97);
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
#resetButton {
  background: transparent;
  border: 1px solid var(--button-border);
  color: var(--reset-text);
}
#resetButton:hover {
  background: var(--button-bg);
}
#resetButton:active {
  transform: scale(0.97);
}

/* ============ 5. Output Area ============ */
#outputArea {
  padding: 16px;
  min-height: 80px;
  border: 1px solid var(--output-border);
  border-radius: calc(var(--radius) - 2px);
  background: var(--output-bg);
  color: var(--text-color);
  font-family: "Menlo", "Consolas", "Monaco", monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  transition: background var(--ease), border-color var(--ease),
    color var(--ease);
  box-sizing: border-box;
}
#outputArea.success {
  background: var(--success-bg-light);
  border-color: var(--success-border-light);
  color: var(--success-text-light);
}
body.dark-mode #outputArea.success {
  background: var(--success-bg-dark);
  border-color: var(--success-border-dark);
  color: var(--success-text-dark);
}
#outputArea.error {
  background: var(--error-bg-light);
  border-color: var(--error-border-light);
  color: var(--error-text-light);
}
body.dark-mode #outputArea.error {
  background: var(--error-bg-dark);
  border-color: var(--error-border-dark);
  color: var(--error-text-dark);
}

.copy-info {
  font-size: 0.8em;
  color: var(--copy-info);
  margin-top: 8px;
  display: block;
  font-style: italic;
}

/* ============ 6. Theme Toggle ============ */
#theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 46px;
  height: 46px;
  padding: 8px;
  border-radius: 50%;
  background: var(--toggle-bg);
  border: 1px solid var(--button-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease),
    transform var(--ease);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.22);
  z-index: 1000;
}
#theme-toggle:hover {
  transform: scale(1.08);
}
#theme-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(155, 114, 203, 0.45);
}
#theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: var(--toggle-icon);
}

/* ============ 7. Responsiveness ============ */
@media (max-width: 480px) {
  html {
    padding: 0; /* Remove HTML element's default padding on mobile */
  }
  body {
    padding: 8px 0; /* 8px top/bottom, 0 left/right for body on mobile */
    /* min-width: 100vw; /* Ensures body tries to fill viewport width if content is narrower */
    /* width: 100% is already set globally and should suffice with html padding 0 */
  }
  .container {
    padding: 20px 16px; /* Internal padding for content */
    width: 90%;
    max-width: 100%;
    margin: 0; /* Remove auto margins on mobile */
    border-radius: var(--radius); /* Keep rounded corners by default */
    /* If a truly edge-to-edge container background is desired, uncomment below: */
    /* border-radius: 0; */
    /* box-shadow: none; /* Optional: remove shadow on mobile for flatter look */
  }
  h1 {
    font-size: 1.35rem;
  }
  .button-container {
    gap: 10px;
  }
  button {
    flex-basis: 100%;
    max-width: none;
  }
  #theme-toggle {
    bottom: 15px;
    right: 15px;
    width: 42px;
    height: 42px;
  }
  #theme-toggle svg {
    width: 22px;
    height: 22px;
  }
}
