/* Estilos Gerais */
:root {
  --bg-dark: #0d1117;
  --container-dark: #161b22;
  --button-dark: #21262d;
  --button-hover: #30363d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-red: #f85149;
  --accent-orange: #db6d28;
  --border-color: #30363d;
  --shadow-color: rgba(0, 0, 0, 0.5);
  --glow-color: rgba(88, 166, 255, 0.15);
  --input-bg: #0d1117;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'JetBrains Mono', monospace;
  user-select: none;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  background-color: var(--bg-dark);
  transition: all 0.3s ease;
  padding: 20px 0;
}

/* Tema Claro */
body:not(.dark) {
  --bg-dark: #f0f2f5;
  --container-dark: #ffffff;
  --button-dark: #f8f9fa;
  --button-hover: #e9ecef;
  --text-primary: #24292e;
  --text-secondary: #586069;
  --border-color: #d0d7de;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --glow-color: rgba(88, 166, 255, 0.1);
  --input-bg: #ffffff;
}

/* Tema */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 25px;
  background: var(--button-dark);
  border-radius: 30px;
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 3px;
  box-shadow: 0 2px 10px var(--shadow-color);
  transition: all 0.3s ease;
  z-index: 1000;
}

.toggle-icon {
  width: 19px;
  height: 19px;
  background: var(--accent-blue);
  border-radius: 50%;
  transform: translateX(25px);
  transition: transform 0.3s ease;
}

body:not(.dark) .toggle-icon {
  transform: translateX(0);
}

/* Container Principal */
.container {
  position: relative;
  width: 100%;
  max-width: 500px;
  background: var(--container-dark);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 
    0 20px 50px var(--shadow-color),
    0 0 40px var(--glow-color);
  overflow: hidden;
}

.brand {
  text-align: center;
  padding: 20px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
  text-shadow: 0 0 10px var(--glow-color);
  border-bottom: 1px solid var(--border-color);
}

.brand span {
  color: var(--accent-blue);
}

/* Input Section */
.input-container {
  padding: 30px 20px;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  flex-direction: column;
}

#secretInput {
  width: 100%;
  padding: 15px;
  background: var(--input-bg);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.3s ease;
  outline: none;
}

#secretInput:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--glow-color);
}

#secretInput::placeholder {
  color: var(--text-secondary);
}

.generate-btn {
  width: 100%;
  padding: 15px;
  background: var(--accent-blue);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.generate-btn:hover {
  background: #4993e5;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(88, 166, 255, 0.3);
}

.generate-btn:active {
  transform: translateY(0);
}

.generate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Result Section */
.result-container {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border-color);
}

.result-display {
  background: var(--button-dark);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  margin-bottom: 15px;
}

.result-label {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 10px;
}

.result-code {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent-green);
  margin-bottom: 15px;
  letter-spacing: 3px;
  user-select: text;
}

.result-timer {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}

.timer-bar {
  flex: 1;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.timer-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent-green);
  border-radius: 2px;
  transition: width 1s linear;
  width: 100%;
}

.timer-text {
  color: var(--text-secondary);
  font-size: 14px;
  min-width: 30px;
}

.copy-btn {
  width: 100%;
  padding: 12px;
  background: var(--button-dark);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.copy-btn:hover {
  background: var(--button-hover);
  border-color: var(--accent-blue);
}

.copy-btn.copied {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}

/* History Section */
.history-section {
  padding: 20px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.history-header h3 {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
}

.clear-history-btn {
  padding: 8px 12px;
  background: var(--accent-red);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.clear-history-btn:hover {
  background: #e5424d;
}

.history-list {
  max-height: 300px;
  overflow-y: auto;
}

.history-empty {
  text-align: center;
  color: var(--text-secondary);
  font-style: italic;
  padding: 20px;
}

.history-item {
  background: var(--button-dark);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
  transition: all 0.3s ease;
  position: relative;
}

.history-item:hover {
  border-color: var(--accent-blue);
  transform: translateY(-2px);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.history-name {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
  margin-right: 10px;
}

.history-name:hover {
  color: var(--accent-blue);
}

.history-actions {
  display: flex;
  gap: 8px;
}

.history-edit-btn, .history-delete-btn {
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-edit-btn {
  background: var(--accent-blue);
  color: white;
}

.history-edit-btn:hover {
  background: #4993e5;
}

.history-delete-btn {
  background: var(--accent-red);
  color: white;
}

.history-delete-btn:hover {
  background: #e5424d;
}

.history-code-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 8px;
}

.history-code {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-green);
  letter-spacing: 2px;
  user-select: text;
}

.history-copy-btn {
  padding: 6px 12px;
  background: var(--button-dark);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-copy-btn:hover {
  background: var(--button-hover);
  border-color: var(--accent-blue);
}

.history-copy-btn.copied {
  background: var(--accent-green);
  color: white;
  border-color: var(--accent-green);
}

.history-timer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.history-timer-bar {
  flex: 1;
  height: 3px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.history-timer-progress {
  height: 100%;
  background: var(--accent-green);
  border-radius: 2px;
  transition: width 1s linear;
  width: 100%;
}

.history-timer-text {
  color: var(--text-secondary);
  font-size: 11px;
  min-width: 25px;
}

.history-secret-preview {
  color: var(--text-secondary);
  font-size: 11px;
  font-family: monospace;
  margin-top: 8px;
  opacity: 0.7;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--container-dark);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 50px var(--shadow-color);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 0;
  margin-bottom: 15px;
}

.modal-header h3 {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

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

.modal-body {
  padding: 0 20px 20px;
}

#nameInput {
  width: 100%;
  padding: 12px;
  background: var(--input-bg);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.3s ease;
  outline: none;
}

#nameInput:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px var(--glow-color);
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 0 20px 20px;
}

.modal-btn {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-btn.cancel {
  background: var(--button-dark);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.modal-btn.cancel:hover {
  background: var(--button-hover);
}

.modal-btn.save {
  background: var(--accent-blue);
  color: white;
}

.modal-btn.save:hover {
  background: #4993e5;
}

/* Animações */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-container {
  animation: slideIn 0.5s ease;
}

/* Efeito 3D no container */
.container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
  opacity: 0.7;
}

/* Responsividade */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }
  
  .container {
    margin: 0 10px;
  }
  
  .brand {
    font-size: 20px;
    padding: 15px 0;
  }
  
  .input-container {
    padding: 20px 15px;
  }
  
  .result-container {
    padding: 0 15px 15px;
  }
  
  .history-section {
    padding: 15px;
  }
  
  .result-code {
    font-size: 28px;
  }
  
  .input-wrapper {
    gap: 8px;
  }
  
  .generate-btn {
    margin-top: 8px;
  }
}

@media (max-width: 400px) {
  .container {
    margin: 0 5px;
  }
  
  .result-code {
    font-size: 24px;
    letter-spacing: 2px;
  }
  
  .history-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }
}

/* Scrollbar personalizada */
.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: var(--button-dark);
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}