/* =============================================================================
   SERVICIONET VAULT - HOJA DE ESTILOS CSS v2.1
   Multiplataforma (Mac / iOS / Android) • Modo Claro y Oscuro • Diseño Nativo
   ============================================================================= */

/* Variables Modo Oscuro (Por Defecto) */
:root, [data-theme="dark"] {
  --bg-main: #000000;
  --bg-surface: #1c1c1e;
  --bg-surface-hover: #2c2c2e;
  --bg-card: #1c1c1e;
  --bg-header: rgba(28, 28, 30, 0.94);
  --border-color: #38383a;
  --border-focus: #0a84ff;
  
  --primary: #0a84ff;
  --primary-hover: #0070e0;
  --primary-glow: rgba(10, 132, 255, 0.25);
  
  --accent: #5ac8fa;
  --success: #34c759;
  --warning: #ff9f0a;
  --danger: #ff453a;
  
  --text-main: #ffffff;
  --text-muted: #8e8e93;
  --text-faint: #636366;
  --input-bg: #2c2c2e;
  
  --shadow-card: 0 16px 36px rgba(0, 0, 0, 0.6);
  --shadow-dropdown: 0 12px 32px rgba(0, 0, 0, 0.75);
  --sidebar-w: 290px;
  --list-w: 360px;
  --top-bar-h: 56px;
  --bottom-bar-h: 58px;
}

/* Variables Modo Claro */
[data-theme="light"] {
  --bg-main: #f2f2f7;
  --bg-surface: #ffffff;
  --bg-surface-hover: #e5e5ea;
  --bg-card: #ffffff;
  --bg-header: rgba(248, 248, 248, 0.95);
  --border-color: #d1d1d6;
  --border-focus: #007aff;
  
  --primary: #007aff;
  --primary-hover: #0056b3;
  --primary-glow: rgba(0, 122, 255, 0.2);
  
  --accent: #32ade6;
  --success: #34c759;
  --warning: #ff9500;
  --danger: #ff3b30;
  
  --text-main: #000000;
  --text-muted: #3c3c43;
  --text-faint: #8e8e93;
  --input-bg: #e5e5ea;
  
  --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.08);
  --shadow-dropdown: 0 12px 30px rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Inter', "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  height: -webkit-fill-available;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* =============================================================================
   PANTALLA DE BLOQUEO / INGRESO MAESTRO
   ============================================================================= */
#lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lock-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 36px 28px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(20px);
  text-align: center;
  animation: fadeIn 0.25s ease-out;
}

.lock-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.18), rgba(90, 200, 250, 0.12));
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.lock-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.lock-title span {
  color: var(--primary);
}

.lock-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 6px;
  margin-bottom: 24px;
  line-height: 1.4;
}

/* Campos con Ojito */
.password-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-field-wrapper input {
  width: 100%;
  padding-right: 44px;
}

.password-toggle-btn {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
}

.password-toggle-btn:hover {
  transform: scale(1.1);
  opacity: 0.8;
}

/* =============================================================================
   APLICACIÓN PRINCIPAL (CONTENEDOR GLOBAL)
   ============================================================================= */
#app-layout {
  display: flex;
  flex-direction: column !important;
  width: 100vw;
  height: 100vh;
  height: -webkit-fill-available;
  overflow: hidden;
}

/* =============================================================================
   TOP BAR PRINCIPAL ÚNICA (DESKTOP & MÓVIL)
   ============================================================================= */
.vault-top-bar {
  width: 100%;
  height: var(--top-bar-h);
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.top-bar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.logo-shield {
  font-size: 1.3rem;
}

.logo-text {
  letter-spacing: -0.3px;
}

.mobile-back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: opacity 0.15s;
}

.mobile-back-btn:active {
  opacity: 0.6;
}

.mobile-back-btn .back-chevron {
  font-size: 1.6rem;
  line-height: 1;
  font-weight: 300;
  margin-top: -2px;
}

.mobile-back-btn .back-text {
  font-size: 0.95rem;
  font-weight: 500;
}

.top-bar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 8px;
  min-width: 0;
}

.user-sync-pill {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  padding: 5px 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-email-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.pill-separator {
  color: var(--text-faint);
  font-size: 0.75rem;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
}

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

.status-indicator.offline {
  color: var(--danger);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* =============================================================================
   BOTÓN DESPLEGABLE NUEVO (ENTRADA / GRUPO)
   ============================================================================= */
.dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.dropdown-arrow {
  font-size: 0.65rem;
  margin-left: 4px;
  transition: transform 0.2s;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-dropdown);
  z-index: 300;
  padding: 6px;
  animation: slideDownMenu 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s;
}

.dropdown-item:hover, .dropdown-item:active {
  background: var(--bg-surface-hover);
}

.dropdown-icon {
  font-size: 1.35rem;
  width: 30px;
  text-align: center;
  flex-shrink: 0;
}

.dropdown-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.dropdown-item-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 2px;
}

@keyframes slideDownMenu {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* =============================================================================
   ESPACIO DE TRABAJO (DESKTOP: 3 COLUMNAS)
   ============================================================================= */
.vault-workspace {
  flex: 1;
  display: flex;
  flex-direction: row;
  width: 100%;
  overflow: hidden;
  background: var(--bg-main);
}

/* 1. SIDEBAR / CATEGORÍAS */
aside.vault-sidebar {
  width: var(--sidebar-w);
  border-right: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 14px 12px;
  flex-shrink: 0;
}

.sidebar-search-box {
  margin-bottom: 14px;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.btn-sm-add {
  width: 24px;
  height: 24px;
  font-size: 1rem;
  border-radius: 6px;
}

/* Filas Estilo iOS */
.ios-list-group {
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  margin-bottom: 12px;
}

.ios-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.12s;
}

.ios-list-row:last-child {
  border-bottom: none;
}

.ios-list-row:hover, .ios-list-row:active {
  background: var(--bg-surface-hover);
}

.ios-list-row.active {
  background: rgba(10, 132, 255, 0.12);
}

.ios-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.ios-row-icon {
  font-size: 1.25rem;
  width: 26px;
  text-align: center;
  flex-shrink: 0;
}

.ios-row-title {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ios-row-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ios-row-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.ios-chevron {
  font-size: 1.1rem;
  color: var(--text-faint);
  font-weight: 300;
}

/* Botón Editar Grupo ✏️ */
.btn-edit-group {
  background: none;
  border: none;
  font-size: 0.9rem;
  color: var(--text-faint);
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.btn-edit-group:hover {
  color: var(--primary);
  background: var(--input-bg);
}

.ios-footer-count {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-faint);
  padding: 14px 0 10px;
}

/* 2. LISTA DE ELEMENTOS */
section.vault-list-pane {
  width: var(--list-w);
  border-right: 1px solid var(--border-color);
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-top-bar {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-surface);
}

.current-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.current-folder-title {
  font-size: 1.12rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 12px 8px 34px;
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--border-focus);
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 0.85rem;
}

.items-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
}

.vault-item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 5px;
  border: 1px solid transparent;
  background: var(--bg-card);
  transition: all 0.12s ease;
}

.vault-item-card:hover {
  background: var(--bg-surface-hover);
}

.vault-item-card.active {
  background: rgba(10, 132, 255, 0.12);
  border-color: rgba(10, 132, 255, 0.35);
}

.item-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--input-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

/* 3. PANEL DE DETALLE */
section.vault-detail-pane {
  flex: 1;
  background: var(--bg-main);
  overflow-y: auto;
  padding: 24px 32px;
}

.detail-container {
  max-width: 680px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.detail-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.detail-icon-large {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(10, 132, 255, 0.12);
  border: 1px solid rgba(10, 132, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.field-group {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-value {
  font-size: 0.95rem;
  color: var(--text-main);
  word-break: break-all;
}

.field-value.mono {
  font-family: 'SF Mono', 'JetBrains Mono', Menlo, monospace;
  letter-spacing: 0.5px;
}

.btn-icon {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-icon:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.encrypted-image-preview {
  max-width: 100%;
  max-height: 280px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  margin-top: 8px;
  cursor: pointer;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.2);
}

/* =============================================================================
   BOTONES Y FORMULARIOS
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
}

.btn-danger {
  background: rgba(255, 69, 58, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 69, 58, 0.3);
  box-shadow: none;
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

input, select, textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
}

/* =============================================================================
   MODALES
   ============================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  width: 100%;
  max-width: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.icon-choice {
  font-size: 1.4rem;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.icon-choice:hover, .icon-choice.selected {
  background: rgba(10, 132, 255, 0.2);
  transform: scale(1.1);
}

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-focus);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 2000;
  animation: slideUp 0.25s ease-out;
}

/* =============================================================================
   BARRA INFERIOR MÓVIL (FÁCIL Y CÓMODA)
   ============================================================================= */
.mobile-bottom-nav {
  display: none;
  height: var(--bottom-bar-h);
  border-top: 1px solid var(--border-color);
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  flex: 1;
  height: 100%;
  padding: 6px 0;
  gap: 3px;
  transition: all 0.15s;
}

.mobile-nav-btn.active {
  color: var(--primary);
  font-weight: 600;
}

.m-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.m-label {
  font-size: 0.72rem;
}

.btn-m-plus {
  color: var(--primary);
}

.m-icon-plus {
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 700;
}

/* Animaciones */
.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

/* =============================================================================
   RESPONSIVE DESIGN (MÓVILES / TABLETS <= 800px)
   FLUJO DE NAVEGACIÓN SENCILLO Y ELEGANTE
   ============================================================================= */
@media (max-width: 800px) {
  .mobile-bottom-nav {
    display: flex;
  }

  .vault-workspace {
    position: relative;
    padding-bottom: var(--bottom-bar-h);
  }

  /* Control de Vistas Móviles */
  body.m-view-folders aside.vault-sidebar {
    display: flex;
    width: 100%;
    border-right: none;
  }
  body.m-view-folders section.vault-list-pane {
    display: none;
  }
  body.m-view-folders section.vault-detail-pane {
    display: none;
  }

  body.m-view-items aside.vault-sidebar {
    display: none;
  }
  body.m-view-items section.vault-list-pane {
    display: flex;
    width: 100%;
    border-right: none;
  }
  body.m-view-items section.vault-detail-pane {
    display: none;
  }

  body.m-view-detail aside.vault-sidebar {
    display: none;
  }
  body.m-view-detail section.vault-list-pane {
    display: none;
  }
  body.m-view-detail section.vault-detail-pane {
    display: block;
    width: 100%;
    padding: 16px 14px calc(var(--bottom-bar-h) + 16px) 14px;
  }

  .user-email-text {
    max-width: 90px;
  }

  #toast {
    bottom: calc(var(--bottom-bar-h) + 14px);
    right: 14px;
    left: 14px;
    justify-content: center;
  }
}
