/* ── Encurtador de URLs — CSS Acessível (WCAG AA) ── */

/* Reset e base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Cores com contraste WCAG AA garantido */
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #e8e8e8;       /* contraste ~12:1 sobre bg-primary */
  --text-secondary: #b0b0c0;     /* contraste ~7:1 sobre bg-primary */
  --accent: #4fc3f7;             /* contraste ~5.5:1 sobre bg-primary */
  --accent-hover: #81d4fa;
  --success: #66bb6a;            /* contraste ~5.2:1 */
  --error: #ef5350;              /* contraste ~5.4:1 */
  --border: #2a2a4a;
  --focus-ring: #4fc3f7;
  --radius: 8px;
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Skip link para acessibilidade por teclado */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--bg-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 var(--radius) var(--radius);
  font-weight: 600;
  text-decoration: none;
  z-index: 1000;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Focus visível para todos os elementos interativos */
*:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Header */
header {
  background: var(--bg-secondary);
  padding: 2rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Main */
main {
  flex: 1;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Seções */
section {
  margin-bottom: 2.5rem;
}

section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
  border-left: 3px solid var(--accent);
  padding-left: 0.75rem;
}

/* Formulário */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-size: 0.95rem;
}

input[type="url"] {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="url"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.25);
  outline: none;
}

input[type="url"]::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

input[type="url"][aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 83, 80, 0.25);
}

.hint {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

.error-message {
  display: block;
  font-size: 0.85rem;
  color: var(--error);
  font-weight: 600;
  margin-top: 0.35rem;
  min-height: 1.2em;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition), transform var(--transition);
}

button:active {
  transform: scale(0.97);
}

#shorten-btn {
  background: var(--accent);
  color: var(--bg-primary);
  width: 100%;
}

#shorten-btn:hover {
  background: var(--accent-hover);
}

#shorten-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Resultado */
.result-label {
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
}

.result-box {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 0.5rem;
  border: 1px solid var(--border);
}

#short-url-output {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: 'Courier New', Courier, monospace;
  color: var(--accent);
  word-break: break-all;
  display: flex;
  align-items: center;
}

#copy-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  white-space: nowrap;
  padding: 0.75rem 1.25rem;
}

#copy-btn:hover {
  background: var(--border);
}

.status-message {
  font-size: 0.85rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

.status-message.success {
  color: var(--success);
}

.status-message.error {
  color: var(--error);
}

/* Lista de URLs recentes */
#recent-list {
  list-style: none;
  padding: 0;
}

#recent-list li {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
  transition: border-color var(--transition);
}

#recent-list li:hover {
  border-color: var(--accent);
}

.recent-item-short {
  font-family: 'Courier New', Courier, monospace;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
}

.recent-item-short a {
  color: var(--accent);
  text-decoration: underline;
}

.recent-item-short a:hover {
  color: var(--accent-hover);
}

.recent-item-original {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  word-break: break-all;
}

.recent-item-meta {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 0.35rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* Responsivo */
@media (max-width: 480px) {
  header h1 {
    font-size: 1.4rem;
  }

  main {
    padding: 1.5rem 0.75rem;
  }

  .result-box {
    flex-direction: column;
  }

  #copy-btn {
    width: 100%;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* High contrast mode */
@media (forced-colors: active) {
  button, input {
    border: 2px solid ButtonText;
  }
}
