@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-color: #080c16;
  --panel-bg: #0f172a;
  --panel-border: #1e293b;
  --input-bg: #030712;
  --input-border: #334155;
  --input-focus-border: #06b6d4;
  --primary-cyan: #06b6d4;
  --primary-blue: #2563eb;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-label: #cbd5e1;
  --danger-color: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --success-color: #10b981;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(37, 99, 235, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
}

/* Header */
.vault-header {
  width: 100%;
  padding: 2.2rem 1.5rem 1.2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.brand-container {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 0.55rem 1.3rem;
  border-radius: 9999px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.brand-logo {
  color: var(--primary-cyan);
  display: flex;
}

.vault-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.vault-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 620px;
  line-height: 1.5;
}

/* Selector de Modo */
.mode-selector-bar {
  display: flex;
  gap: 0.5rem;
  background-color: #0c1322;
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  margin-top: 0.5rem;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.6rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: #ffffff;
}

.mode-btn.active {
  background-color: #1e293b;
  color: #38bdf8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Contraseña Maestra Global */
.master-pass-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem 0.5rem;
}

.pass-wrapper {
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pass-wrapper label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #e2e8f0;
}

/* Layout Principal */
.vault-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  flex: 1;
}

@media (min-width: 1024px) {
  .vault-container {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }
}

/* Tarjetas */
.card {
  background-color: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  min-width: 0;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.85rem;
}

.title-with-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-header h2 {
  font-size: 1.18rem;
  font-weight: 700;
  color: #ffffff;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.output-header-bar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Inputs & Textareas */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  flex: 1;
}

.field-help {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  color: #ffffff;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 0.95rem;
  padding: 0.8rem 1rem;
  outline: none;
  transition: all 0.2s ease;
}

input[type="password"],
input[type="text"] {
  padding-right: 2.75rem;
}

textarea {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  min-height: 250px;
  resize: vertical;
}

input:focus,
textarea:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
  background-color: #02050d;
}

.btn-ghost-icon {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s;
}

.btn-ghost-icon:hover {
  color: var(--primary-cyan);
}

/* Botones y Toolbars */
.actions-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.72rem 1.3rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background-color: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background-color: #0369a1;
}

.btn-secondary {
  background-color: #0d9488;
  color: #ffffff;
  border-color: #2dd4bf;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

.btn-secondary:hover:not(:disabled) {
  background-color: #0f766e;
}

.btn-danger-outline {
  background-color: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  margin-left: auto;
  padding: 0.72rem 1.15rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger-outline:hover {
  background-color: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
}

/* Botón Cargar Archivo de Texto */
.btn-file-upload {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 600;
  background-color: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #38bdf8;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.2s;
}

.btn-file-upload input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.btn-file-upload:hover {
  background-color: #334155;
  color: #ffffff;
}

/* Pestañas y Controles de Salida */
.output-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tab-group {
  display: inline-flex;
  background-color: #030712;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  padding: 3px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.38rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background-color: #1e293b;
  color: #ffffff;
}

.btn-action-sm {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  background-color: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-action-sm:hover {
  background-color: #334155;
}

/* Vistas de Salida */
.output-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.output-view.hidden,
.vault-container.hidden {
  display: none !important;
}

#outputRaw {
  flex: 1;
  min-height: 250px;
  background-color: var(--input-bg);
  color: #38bdf8;
  border: 1px solid var(--input-border);
}

.markdown-content {
  flex: 1;
  min-height: 250px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 1.25rem;
  overflow-y: auto;
  max-height: 500px;
  line-height: 1.7;
}

.placeholder-text {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.88rem;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
  color: #ffffff;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

.markdown-content code {
  background: rgba(255, 255, 255, 0.1);
  color: #38bdf8;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

/* Dropzones */
.dropzone {
  position: relative;
  border: 2px dashed var(--input-border);
  background-color: rgba(3, 7, 18, 0.6);
  border-radius: 12px;
  padding: 2.2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary-cyan);
  background-color: rgba(6, 182, 212, 0.05);
}

.dropzone-file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  color: var(--primary-cyan);
  margin-bottom: 0.75rem;
}

.dropzone-text {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.dropzone-text strong {
  color: var(--primary-cyan);
}

.dropzone-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.selected-file-badge {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #1e293b;
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
}

.selected-file-badge.hidden {
  display: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  max-width: 420px;
  padding: 0.85rem 1.2rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  animation: slideIn 0.25s ease-out forwards;
}

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast.hidden {
  display: none;
}

.toast.success {
  background-color: #064e3b;
  border: 1px solid #059669;
  color: #6ee7b7;
}

.toast.error {
  background-color: #450a0a;
  border: 1px solid #b91c1c;
  color: #fca5a5;
}

/* Footer */
.vault-footer {
  width: 100%;
  padding: 1.4rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--panel-border);
  background-color: rgba(8, 12, 22, 0.95);
  margin-top: auto;
}

@media (max-width: 640px) {
  .actions-toolbar {
    flex-direction: column;
  }
  .btn, .btn-danger-outline {
    width: 100%;
    margin-left: 0;
  }
  .mode-selector-bar {
    flex-direction: column;
    width: 100%;
  }
}