/* === LAYOUT — Monitor ML v2 === */

/* === HEADER === */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: 56px;
  background: var(--bg-header);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; padding: 0 var(--sp-6);
  z-index: 1000;
  transition: background var(--t-theme);
}

.header-title {
  font-weight: 700; font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: var(--sp-3);
}

.header-empresa {
  font-size: 13px; color: var(--color-text-muted); font-weight: 500;
}

.connection-status {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--color-text-muted); font-size: 13px;
}

.status-indicator {
  width: 8px; height: 8px; border-radius: 50%;
  background-color: #6B7280;
  transition: all var(--t-fast);
}

.status-indicator.connected {
  background-color: var(--color-positive);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.status-indicator.error {
  background-color: var(--color-negative);
}

.header-actions {
  display: flex; align-items: center; gap: 0.75rem;
}

.header-btn {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--t-fast) var(--ease-out);
}
.header-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}
.header-btn:active { transform: scale(0.92); }
.header-btn svg { width: 18px; height: 18px; }
.header-btn.spin-active svg { animation: spin 0.8s linear infinite; }

.sync-status-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); color: var(--color-text-muted);
  cursor: default; white-space: nowrap;
}
.sync-status-indicator .sync-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.sync-dot.ok { background: var(--color-positive); }
.sync-dot.warn { background: var(--color-warm); }
.sync-dot.fail { background: var(--color-negative); }
.sync-dot.none { background: var(--color-text-muted); opacity: 0.4; }

/* === THEME TOGGLE === */
.theme-toggle {
  width: 52px; height: 28px;
  background: var(--toggle-bg);
  border-radius: var(--r-full);
  position: relative; cursor: pointer;
  transition: background var(--t-theme);
  border: 1px solid var(--color-border);
}

.theme-toggle-knob {
  width: 22px; height: 22px;
  background: var(--toggle-knob);
  border-radius: 50%;
  position: absolute; top: 2px; left: 2px;
  transition: transform var(--t-base) var(--ease-spring), background var(--t-theme);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.theme-toggle-knob svg { width: 13px; height: 13px; color: var(--toggle-icon); }
[data-theme="dark"] .theme-toggle-knob { transform: translateX(24px); }

/* === TAB STRIP === */
.tab-strip {
  position: fixed; top: 56px; left: 220px; right: 0; height: 40px;
  background: var(--tab-bar-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: stretch;
  padding: 0 var(--sp-4); gap: 0;
  z-index: 800;
  transition: background var(--t-theme), border-color var(--t-theme), left var(--t-slow) var(--ease-out);
  overflow-x: auto; overflow-y: hidden;
}
.tab-strip.drop-active { background: var(--tab-drop-bg); }

.tab-strip-tab {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-4);
  font-size: 12px; font-weight: 500; color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--t-fast) var(--ease-out);
  white-space: nowrap; cursor: pointer;
  position: relative; user-select: none;
}
.tab-strip-tab:hover { color: var(--color-text-primary); background: var(--color-surface-hover); }
.tab-strip-tab.active { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 600; }
.tab-strip-tab svg { width: 14px; height: 14px; }

.tab-strip-tab .tab-close {
  width: 16px; height: 16px; border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity var(--t-fast), background var(--t-fast);
  margin-left: var(--sp-1);
}
.tab-strip-tab:hover .tab-close { opacity: 0.6; }
.tab-strip-tab .tab-close:hover { opacity: 1; background: var(--color-surface-hover); }
.tab-strip-tab .tab-close svg { width: 10px; height: 10px; }

/* Drag states */
.tab-strip-tab.dragging { opacity: 0.4; }
.sidebar-nav-item.dragging { opacity: 0.3; transform: scale(0.95); }
.drag-ghost {
  position: fixed; z-index: 10000; pointer-events: none;
  padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md);
  background: var(--color-accent); color: #fff;
  font-size: 12px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; gap: var(--sp-2);
  opacity: 0.9; transform: translate(-50%, -50%);
}
.drag-ghost svg { width: 14px; height: 14px; }

.tab-strip-drop-hint {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  display: none; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--color-accent);
  letter-spacing: 0.02em; pointer-events: none;
}
.tab-strip.drop-active .tab-strip-drop-hint { display: flex; }

/* Remove zone */
.remove-zone {
  position: fixed; top: 56px; left: 220px; right: 0; height: 0;
  z-index: 900; overflow: hidden;
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.12) 0%, transparent 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--color-negative);
  transition: height 0.2s var(--ease-out), opacity 0.2s;
  opacity: 0; pointer-events: none;
}
.remove-zone.active { height: 40px; opacity: 1; pointer-events: auto; }
.remove-zone svg { width: 14px; height: 14px; margin-right: var(--sp-2); }

/* === SIDEBAR === */
#sidebar {
  position: fixed; top: 56px; left: 0; bottom: 0;
  width: 220px; background: var(--bg-sidebar);
  border-right: 1px solid var(--color-border);
  padding: var(--sp-4) var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-1);
  overflow-y: auto; z-index: 900;
  transition: background var(--t-theme), border-color var(--t-theme);
}

.sidebar-nav {
  display: flex; flex-direction: column; gap: 0;
}

.sidebar-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-text-disabled);
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.sidebar-nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--t-fast) var(--ease-out);
  border-left: 2px solid transparent;
  width: 100%; text-align: left;
  cursor: grab; user-select: none;
  font-family: var(--font-family);
}
.sidebar-nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-nav-item:hover { background: var(--sidebar-hover-bg); color: var(--color-text-primary); }
.sidebar-nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--color-accent);
  border-left-color: var(--sidebar-active-border);
  font-weight: 600;
}
.sidebar-nav-item.placeholder { opacity: 0.4; pointer-events: none; cursor: default; }
.sidebar-nav-item.pinned::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-accent); margin-left: auto; flex-shrink: 0; opacity: 0.5;
}

.badge-soon {
  margin-left: auto;
  font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--color-text-disabled);
  background: var(--bg-badge);
  padding: 1px 6px; border-radius: var(--r-full);
}

/* === MAIN CONTENT === */
.app-body {
  display: flex;
  min-height: calc(100vh - 56px);
}

main {
  margin-left: 220px; margin-top: 96px;
  padding: var(--sp-8);
  min-height: calc(100vh - 96px);
  transition: margin-left var(--t-slow) var(--ease-out);
  flex: 1;
}

/* === SECTIONS === */
.section-view {
  animation: sectionIn 0.5s var(--ease-out) both;
  width: 100%;
}

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

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-8);
}

.section-header h2 {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: var(--sp-3);
  color: var(--color-text-primary);
}
.section-header h2 i,
.section-header h2 svg {
  width: 22px; height: 22px; color: var(--color-accent);
}

/* === LOGIN SCREEN === */
.db-config-section {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; align-items: center;
  background: var(--login-gradient);
  z-index: 1050;
}

.db-config-card {
  background-color: var(--color-surface);
  padding: 2.5rem;
  border-radius: var(--r-xl);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 550px;
}

.db-config-header {
  text-align: center; margin-bottom: 2rem;
}

.db-config-icon {
  color: var(--color-accent);
  width: 48px; height: 48px; margin-bottom: 1rem;
}

.db-config-header h2 {
  font-size: 1.5rem; font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 0.5rem;
}

.db-config-header p {
  color: var(--color-text-muted); font-size: 1rem;
}

/* === SECTION PLACEHOLDER (Próximamente) === */
.section-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
}
.placeholder-icon {
  width: 48px; height: 48px;
  color: var(--color-text-disabled);
  margin-bottom: var(--sp-4);
}

/* === DRAG HINT TOAST === */
.drag-hint {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-full);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-card-hover);
  font-size: 12px; color: var(--color-text-secondary); font-weight: 500;
  display: flex; align-items: center; gap: var(--sp-2);
  opacity: 0; transform: translateX(-50%) translateY(12px);
  transition: opacity 0.3s, transform 0.3s var(--ease-out);
  z-index: 2000; pointer-events: none;
}
.drag-hint.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.drag-hint svg { width: 14px; height: 14px; color: var(--color-accent); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .header {
    padding: 0 var(--sp-4);
  }

  .tab-strip {
    left: 0;
  }

  .remove-zone {
    left: 0;
  }

  #sidebar {
    position: fixed; top: 56px; left: 0; right: 0;
    width: 100%; bottom: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: var(--sp-2) var(--sp-3);
    flex-direction: row;
    overflow-x: auto; overflow-y: visible;
    z-index: 850;
  }

  .sidebar-nav {
    flex-direction: row;
  }

  .sidebar-nav-item {
    flex-shrink: 0;
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: var(--sp-2) var(--sp-3);
  }
  .sidebar-nav-item.active {
    border-left: none;
    border-bottom-color: var(--color-accent);
  }

  .sidebar-label { display: none; }

  main {
    margin-left: 0;
    margin-top: 140px;
    padding: var(--sp-4);
  }

  .app-body {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .header-empresa { display: none; }
  .header-btn.add-btn span { display: none; }
}
