/* Reset básico */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: #121212;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Pantallas */
.screen {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 900px;
  background-color: #121212;
  position: relative;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

/* LOGIN */
.login-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.login-container h1 {
  font-size: 2.5rem;
  color: #bb86fc;
  margin-bottom: 0.5rem;
}

.login-container p {
  color: #aaa;
  margin-bottom: 2rem;
}

#loginForm {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

#loginForm input {
  padding: 0.8rem 1rem;
  border: none;
  border-radius: 8px;
  background-color: #2a2a2a;
  color: #e0e0e0;
  font-size: 1rem;
}

#loginForm input::placeholder {
  color: #888;
}

#loginForm button {
  padding: 0.8rem;
  border: none;
  border-radius: 8px;
  background-color: #bb86fc;
  color: #121212;
  font-weight: bold;
  font-size: 1.1rem;
  cursor: pointer;
}

#loginForm button:hover {
  background-color: #a372e8;
}

.error {
  color: #cf6679;
  text-align: center;
  font-size: 0.9rem;
  min-height: 1.5rem;
}

/* CABECERA PRINCIPAL */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background-color: #1e1e1e;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

header h2 {
  font-size: 1.2rem;
  color: #e0e0e0;
}

.logout-btn {
  background: none;
  border: none;
  color: #bb86fc;
  font-size: 0.9rem;
  cursor: pointer;
}

/* LISTA DE ITEMS */
#mainContent {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 1rem 5rem;
}

#itemsList {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.item-card {
  background-color: #1e1e1e;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  cursor: pointer;
  border-left: 4px solid #bb86fc;
  transition: background-color 0.2s;
}

.item-card:active {
  background-color: #2a2a2a;
}

.item-card h4 {
  font-size: 1rem;
  margin-bottom: 0.2rem;
  color: #e0e0e0;
}

.item-card p {
  font-size: 0.85rem;
  color: #aaa;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-card .meta {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.3rem;
}

/* NAVEGACIÓN INFERIOR */
#bottomNav {
  display: flex;
  background-color: #1e1e1e;
  border-top: 1px solid #333;
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
}

.tab-btn {
  flex: 1;
  padding: 0.8rem 0;
  background: none;
  border: none;
  color: #888;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s, border-bottom 0.2s;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: #bb86fc;
  border-bottom-color: #bb86fc;
}

/* BOTÓN FLOTANTE */
.fab {
  position: absolute;
  bottom: 5rem;
  right: 1.2rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: #bb86fc;
  color: #121212;
  font-size: 2rem;
  font-weight: bold;
  border: none;
  box-shadow: 0 4px 12px rgba(187, 134, 252, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.fab:active {
  transform: scale(0.95);
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 100;
  justify-content: center;
  align-items: flex-end;
  overflow: hidden;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: #1e1e1e;
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  border-radius: 20px 20px 0 0;
  padding: 1.2rem 1.2rem 2rem;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-header h3 {
  font-size: 1.2rem;
  color: #e0e0e0;
}

.close-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.8rem;
  cursor: pointer;
}

.close-btn:hover {
  color: #e0e0e0;
}

/* Formulario del modal */
.form-group {
  margin-bottom: 1.2rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 0.3rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #333;
  border-radius: 8px;
  background-color: #2a2a2a;
  color: #e0e0e0;
  font-size: 0.95rem;
}

.form-group textarea {
  resize: vertical;
}

.array-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  background-color: #2a2a2a;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
}

.array-item input {
  flex: 1;
  border: none;
  background: none;
  color: #e0e0e0;
  padding: 0.3rem 0;
}

.array-item .remove-btn {
  background: none;
  border: none;
  color: #cf6679;
  font-size: 1.2rem;
  cursor: pointer;
}

.add-array-btn {
  background: none;
  border: 1px dashed #555;
  color: #aaa;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
}

.add-array-btn:hover {
  border-color: #bb86fc;
  color: #bb86fc;
}

.form-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.save-btn,
.delete-btn {
  flex: 1;
  padding: 0.7rem;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

.save-btn {
  background-color: #bb86fc;
  color: #121212;
}

.save-btn:hover {
  background-color: #a372e8;
}

.delete-btn {
  background-color: #cf6679;
  color: #121212;
}

.delete-btn:hover {
  background-color: #b85a6b;
}

/* Campos dinámicos específicos */
.dynamic-field {
  margin-bottom: 0.8rem;
}

.dynamic-field label {
  display: block;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.2rem;
}

.dynamic-field input,
.dynamic-field select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid #333;
  border-radius: 6px;
  background-color: #2a2a2a;
  color: #e0e0e0;
}

/* Visibilidad del item en modo vista */
.item-view .dynamic-field {
  margin-bottom: 0.5rem;
}

.item-view .dynamic-field label {
  font-weight: bold;
  color: #bbb;
}

.item-view .dynamic-field .field-value {
  padding: 0.2rem 0;
  color: #e0e0e0;
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: #1e1e1e;
}
::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #666;
}
