/* ==========================================================================
   1. Root and Theme Variables
   ========================================================================== */
/* Defines CSS variables for global theming, including light and dark modes. */

:root {
  --primary-color: #007bff;
  --primary-hover-color: #0056b3;
  --background-color: #f4f7f6;
  --container-bg-color: #ffffff;
  --text-color: #343a40;
  --text-muted-color: #6c757d;
  --border-color: #dee2e6;
  --success-color: #28a745;
  --error-color: #dc3545;
  --error-bg-color: #f8d7da;
  --error-border-color: #f5c6cb;
  --link-item-bg-color: #e9f5ff;
  --link-item-border-color: #b3d7ff;
  --drag-over-bg-color: #e9ecef;
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
}

html.dark-mode {
  --primary-color: #0d8eff;
  --primary-hover-color: #3aa0ff;
  --background-color: #121212;
  --container-bg-color: #1e1e1e;
  --text-color: #e0e0e0;
  --text-muted-color: #868e96;
  --border-color: #3a3a3a;
  --success-color: #4caf50;
  --error-color: #ff5252;
  --error-bg-color: #5d2b30;
  --error-border-color: #a73c46;
  --link-item-bg-color: #2a3a4a;
  --link-item-border-color: #3a5b82;
  --drag-over-bg-color: #2a2a2e;
}

/* ==========================================================================
   2. General Layout & Base Styles
   ========================================================================== */
/* Basic reset, body styling, and main container layout. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--background-color);
  color: var(--text-color);
  margin: 0;
  padding: 1.25rem; /* 20px -> 1.25rem */
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
  width: 100%;
  max-width: 1024px;
  background-color: var(--container-bg-color);
  padding: clamp(1rem, 2.5vw, 1.25rem) clamp(1.25rem, 4vw, 1.875rem); /* Top/Bottom, Left/Right fluid padding */
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: background-color 0.3s ease;
}

/* On very wide screens (e.g., large tablets, desktops), allow the container to be a bit wider. */
@media (min-width: 1440px) {
  .container {
    max-width: 1280px;
  }
}

/* ==========================================================================
   3. Header & Navigation
   ========================================================================== */
/* Styles for the site header, logo, title, theme toggle, and language switcher. */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.9375rem; /* 15px -> 0.9375rem */
  margin-bottom: 1.5625rem; /* 25px -> 1.5625rem */
  transition: border-color 0.3s ease;
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 0.75rem; /* 12px -> 0.75rem */
}

.logo {
  height: 2.5rem; /* 40px -> 2.5rem */
}

header h1 {
  font-size: clamp(1rem, 4.2vw, 1.375rem);
  margin: 0; /* Keep margin 0 */
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.lang-switcher select {
  padding: 0.3125rem 0.5rem; /* 5px 8px -> 0.3125rem 0.5rem */
  border-radius: 5px;
  border: 1px solid var(--border-color);
  font-size: 0.875rem; /* 14px -> 0.875rem */
  background-color: var(--container-bg-color);
  color: var(--text-color);
}

.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  cursor: pointer;
  width: 2.25rem; /* 36px -> 2.25rem */
  height: 2.25rem; /* 36px -> 2.25rem */
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.375rem; /* 6px -> 0.375rem */
  color: var(--text-color);
}

.theme-toggle-btn svg {
  width: 100%;
  height: 100%;
}

.moon-icon {
  display: none;
}
html.dark-mode .sun-icon {
  display: none;
}
html.dark-mode .moon-icon {
  display: block;
}

/* ==========================================================================
   4. Common Components (Forms, Buttons, etc.)
   ========================================================================== */

/* --- Password Visibility Toggle Button Styles --- */
#toggle-password-visibility,
#toggle-main-password-visibility {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 0.75em 0.6em;
  margin-left: 0.5rem;
  cursor: pointer;
  border-radius: 5px;
  font-size: 0.9em;
  vertical-align: middle;
  transition: background-color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

#toggle-password-visibility:hover,
#toggle-main-password-visibility:hover {
  background-color: var(--drag-over-bg-color);
  border-color: var(--primary-color);
}

.password-input-container {
  display: flex;
  align-items: stretch;
}

/* --- Forms & Inputs Styles --- */
.form-group {
  margin-bottom: 1.25rem; /* 20px -> 1.25rem */
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem; /* 8px -> 0.5rem */
  font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem; /* 10px -> 0.625rem */
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 1rem; /* 16px -> 1rem */
  font-family: inherit;
  background-color: var(--container-bg-color);
  color: var(--text-color);
  transition: border-color 0.2s, background-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

/* Custom dropdown arrow for select elements */
.form-group select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem 0.75rem;
  padding-right: 2.5rem;
}

/* Update arrow color in dark mode using theme variables */
html.dark-mode .form-group select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23e0e0e0' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

.form-group textarea {
  resize: vertical;
}

.form-warning-text {
  font-size: 0.8125rem; /* 13px -> 0.8125rem */
  color: #e67e22;
  margin-top: 0.5rem; /* 8px -> 0.5rem */
  padding-left: 0.125rem; /* 2px -> 0.125rem */
}

/* --- Expiry Input Group Styles --- */
.expiry-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* 8px */
}

.expiry-input-group > input,
.expiry-input-group > select {
  width: auto; /* Override base.css width: 100% */
}

.expiry-input-group > input[type='number'] {
  flex: 1 1 0; /* Let the number input grow */
}

/* --- Button Styles --- */
.button-primary {
  width: 100%;
  padding: 0.75rem; /* 12px -> 0.75rem */
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 5px;
  font-size: 1.125rem; /* 18px -> 1.125rem */
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.button-primary:hover {
  background-color: var(--primary-hover-color);
}

.button-primary:disabled {
  background-color: #6c757d;
  cursor: not-allowed;
}

.button-link {
  display: inline-block;
  margin-top: 1.25rem; /* 20px -> 1.25rem */
  padding: 0.625rem 1.25rem; /* 10px 20px -> 0.625rem 1.25rem */
  background-color: var(--primary-color);
  color: white;
  text-decoration: none;
  border-radius: 5px;
}

/* --- Error Message Styles --- */
#error-message {
  color: var(--error-color);
  margin-top: 0.9375rem; /* 15px -> 0.9375rem */
  padding: 0.625rem; /* 10px -> 0.625rem */
  background-color: var(--error-bg-color);
  border: 1px solid var(--error-border-color);
  border-radius: 5px;
  text-align: center;
  display: none;
}

/* ==========================================================================
   5. Utility Classes & Animations
   ========================================================================== */

.text-center {
  text-align: center;
}

.large-logo {
  height: 3.75rem; /* 60px -> 3.75rem */
  margin-bottom: 1.25rem; /* 20px -> 1.25rem */
}

/* --- Animations (Spinner) --- */
.spinner {
  margin: 2.5rem auto; /* 40px -> 2.5rem */
  border: 0.3125rem solid #f3f3f3; /* 5px -> 0.3125rem */
  border-top: 0.3125rem solid var(--primary-color); /* 5px -> 0.3125rem */
  border-radius: 50%;
  width: 3.125rem; /* 50px -> 3.125rem */
  height: 3.125rem; /* 50px -> 3.125rem */
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   7. Footer
   ========================================================================== */
footer {
  text-align: center;
  margin-top: 1.875rem; /* 30px -> 1.875rem */
  font-size: 0.875rem; /* 14px -> 0.875rem */
  color: var(--text-muted-color);
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
}

.footer-separator {
  margin: 0 0.625rem; /* 0 10px -> 0 0.625rem */
}

.deleted-counter {
  color: var(--text-muted-color);
  font-size: 0.875rem; /* 14px -> 0.875rem */
}

.deleted-counter strong {
  color: var(--primary-color);
  font-weight: 600;
  font-size: 1.1em;
}

/* ==========================================================================
   9. Media Queries for Responsiveness (Base Styles)
   ========================================================================== */

@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .container {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.25rem);
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
  }

  .header-controls {
    width: 100%;
    justify-content: flex-end;
  }

  header h1 {
    font-size: clamp(0.9rem, 3.5vw, 1.25rem);
  }

  .form-group input,
  .form-group select,
  .form-group textarea,
  .button-primary,
  .button-secondary,
  .link-item input,
  .link-item button {
    font-size: 0.9375rem; /* 15px */
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: clamp(0.875rem, 4vw, 1.125rem);
  }

  .lang-switcher select,
  .theme-toggle-btn {
    padding: 0.25rem 0.375rem;
    height: 2rem;
    width: auto;
  }

  .theme-toggle-btn {
    width: 2rem;
  }

  .button-primary,
  .button-secondary {
    padding: 0.625rem;
    font-size: 0.9375rem;
  }
}
/* --- Link & Result Display Styles --- */
#progress-container,
#links-container {
  margin-top: 1.25rem;
}

#links-container h3 {
  font-size: 1.125rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.link-item {
  display: flex;
  align-items: center;
  padding: 0.625rem;
  background-color: var(--link-item-bg-color);
  border: 1px solid var(--link-item-border-color);
  border-radius: 5px;
  margin-bottom: 0.625rem;
}

.link-item input {
  flex-grow: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-right: 0.625rem;
  background-color: var(--container-bg-color);
  color: var(--text-color);
}

.copy-btn {
  padding: 0.5rem 0.9375rem;
  background-color: var(--success-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  min-width: 5rem;
}
